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.
Size:
Color:
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
Size:
Color: