const int nSyms = 10;
string[] symbols = {"$AUDUSD", "$EURUSD", "$GBPUSD", "$NZDUSD", "$USDCAD", "$USDCHF", "$USDHKD", "$USDJPY", "$USDNOK", "$USDSGD"};
And then add the instruments in the Initialise() function as follows:
protected override void Initialize() { CalculateOnBarClose = true; Print("Instruments.GetLength(0) = " + Instruments.GetLength(0)); for(int i=0; i < Instruments.GetLength(0);i++) { Print("Instruments["+i+"].FullName = " + Instruments[i].FullName); } for (int i=0;i<nSyms;i++) { // only add the non-primary series Print("Attempting to add symbol " + symbols[i]); Print(" primary is " + Instruments[0].FullName); if(0 != String.Compare(symbols[i], Instruments[0].FullName)){ Add(symbols[i], PeriodType.Minute, 5); Print(" added " + symbols[i]); } else { Print(" this is the primary series."); } } Print("Number of instruments is " + Instruments.GetLength(0)); for(int i=0; i < Instruments.GetLength(0);i++) { Print("Instruments["+i+"].FullName = " + Instruments[i].FullName); } }
If I right click on "$AUDUSD" to bring up the backtest dialogue, the Initiase function runs, and the output is:
Instruments[0].FullName = $GBPUSD
Attempting to add symbol $AUDUSD
primary is $GBPUSD
added $AUDUSD
Attempting to add symbol $EURUSD
primary is $GBPUSD
added $EURUSD
Attempting to add symbol $GBPUSD
primary is $GBPUSD
this is the primary series.
Attempting to add symbol $NZDUSD
primary is $GBPUSD
added $NZDUSD
Attempting to add symbol $USDCAD
primary is $GBPUSD
added $USDCAD
Attempting to add symbol $USDCHF
primary is $GBPUSD
added $USDCHF
Attempting to add symbol $USDHKD
primary is $GBPUSD
added $USDHKD
Attempting to add symbol $USDJPY
primary is $GBPUSD
added $USDJPY
Attempting to add symbol $USDNOK
primary is $GBPUSD
added $USDNOK
Attempting to add symbol $USDSGD
primary is $GBPUSD
added $USDSGD
Number of instruments is 10
Instruments[0].FullName = $GBPUSD
Instruments[1].FullName = $AUDUSD
Instruments[2].FullName = $EURUSD
Instruments[3].FullName = $NZDUSD
Instruments[4].FullName = $USDCAD
Instruments[5].FullName = $USDCHF
Instruments[6].FullName = $USDHKD
Instruments[7].FullName = $USDJPY
Instruments[8].FullName = $USDNOK
Instruments[9].FullName = $USDSGD
Thanks,
Matthew.
Comment