2-dimensional array out of range error
You are ignoring @Dominik Egert's other warning. You are not checking the returned value in the "Data" variable. You are just assuming that enough data was returned by CopyRates but not checking.
Check that "Data" is actually greater or equal than "LookBackPeriodVar" plus one, since you are index at [i+1].
You are ignoring @Dominik Egert's other warning. You are not checking the returned value in the "Data" variable. You are just assuming that enough data was returned by CopyRates but not checking.
Check that "Data" is actually greater or equal than "LookBackPeriodVar" plus one, since you are index at [i+1].
Ok, done that, but still doesn't work (init keeps failing because Data Is not >=LookBackPeriodVar+1), how can I resolve It?
You are ignoring @Dominik Egert's other warning. You are not checking the returned value in the "Data" variable. You are just assuming that enough data was returned by CopyRates but not checking.
Check that "Data" is actually greater or equal than "LookBackPeriodVar" plus one, since you are index at [i+1].
You also need to check "Bars(Symbol(),Period()" and make sure there are in fact enough bars. Also make sure you are doing this only in the OnTick(). Do not use these functions in OnInit().
You are declaring the PriceSTDS with a hardcoded size instead dynamically assigning its size, so make sure that the calculated indexes based on the variables LookBackPeriod, NumStds will be within range.
Remember that you are multiplying NumStdsVar by two and adding one to the index. Arrays start at 0, not 1.
If an array has size "n", then its indexing is 0,1,2 ... n - 1
If an array has size "10", then its indexing is 0,1,2 ... 9
Problem solved, thanks guys :)

- Free trading apps
- Free Forex VPS for 24 hours
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, I'm coding an EA and I have this problem with a 2-dimensional array: when I backtest the EA the "array out of range" error pops up, can anyone help me please?