I am writing a strategy with multiple instruments with End-Of-Day data.
For statistic purposes I write the price data of the instruments into an arraym whenever BarsInProgress=0:
for (int x=0; x<instrumentcount;x++)
{
InstrdataArr[x,CapitalArrCount].Date = Times[x][0];
InstrdataArr[x,CapitalArrCount].Open = Opens[x][0];
InstrdataArr[x,CapitalArrCount].High = Highs[x][0];
InstrdataArr[x,CapitalArrCount].Low = Lows[x][0];
InstrdataArr[x,CapitalArrCount].Close = Closes[x][0];
}
This works fine as long each instrument has on all day price data. But an error is returned, when for one instrument a day is missing.
Example Instrument 0:
22.10.2010: 55.00
23.10.2010: 56.00
24.10.2010: 58.00
Instrument 1:
22.10.2010: 24.50
24.10.2010: 23.00
when OnBarUpdate is on Bar with 23.10.2010 for instrument 0 and I try to access e.g. Times[1][0] for instrument 1, I get an error "ou are accessing an index with a value that is invalid since its out of range."
As I understand Bar 1 is 22.10.2010 for all instruments, Bar 2 is 23.10.2010 for instrument 0 and 24.10.2010 for instrument 1.
Is this correct?
How can I find out and catch the error? In such a case I simply would take on 23.10.2010 for instrument 1 the price data of the previous day.
thanks for your feedback
Comment