how to code buy the corresponding short ETF instead of shorting the ETF
Author: slin68
Creation Date: 6/1/2010 12:05 AM
profile picture

slin68

#1
Sorry if my subject is confusing. To clarify, I want to test a pair of ETFs, e.g. DIG and DUG. Let's say for some strategy, we have SellAtMarket( bar + 1, p ); ShortAtMarket( bar + 1 ); Instead of doing this, I want to use a pair, when SellAtMarket for one (say DIG), then buy the courterpart (DUG) instead of shorting DIG. Same applies CoverAtMarket( bar + 1, p ); BuyAtMarket( bar + 1 ); I would sell DUG at market and buy DIG at market. I wonder if I can get some code examples on how to do this. I'm thinking put the pair in one dataset, and use rotation strategy to achieve this, but I am not sure how to implement this. Code examples will be really appreciated.
profile picture

Eugene

#2
When a Strategy involves trading rules that depend on price action of other symbols e.g. an inverse ETF (i.e. DUG), you can explicitly creating trades on secondary symbols after calling SetContext(). Take a look in the QuickRef for an example, also you might want to check out this Strategy: Pairs Trading
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).