Simon Mungwira:
what is wrong with my coding?
I'd say you ought to trap for errors when getting iHighest().
Per the documentation:
The index of the highest value found on
the corresponding chart (shift relative to the current bar) or -1 in
case of an error. For error details, call the GetLastError() function. |
---|
I'd say you ought to trap for errors when getting iHighest().
Per the documentation:
The index of the highest value found on
the corresponding chart (shift relative to the current bar) or -1 in
case of an error. For error details, call the GetLastError() function. |
---|
In addition to this, OP:
You shouldn't be defining the array size when you use an initialization list. Instead only use the initialization to automatically resize the array, that way you can add/remove items from the array and you don't have to worry about creating accidental bugs.
string currencyArray[] = { "USDCHF", "GBPUSD", "EURUSD", "USDJPY", "USDCAD", "AUDUSD", "EURGBP", "EURAUD", "EURCHF", "EURJPY", "GBPCHF", "CADJPY", "GBPJPY", "AUDNZD", "AUDCAD", "AUDCHF", "AUDJPY", "CHFJPY", "EURNZD", "EURCAD", "CADCHF", "NZDJPY", "NZDUSD", "GBPAUD", "GBPCAD", "GBPNZD", "NZDCAD", "NZDCHF" }; int arrayLengthIndex = ArraySize(currencyArray);
Also, you will have more hidden errors because you are using the wrong method for calling data from external pairs. You need to be using iHigh instead of High.
double buyStop = iHigh(currencyArray[k], PERIOD_M30, iHighest(currencyArray[k], PERIOD_M30, MODE_HIGH, dist, 0) ); if(!buyStop) //HANDLE ERRORS!
In addition to this, OP:
You shouldn't be defining the array size when you use an initialization list. Instead only use the initialization to automatically resize the array, that way you can add/remove items from the array and you don't have to worry about creating accidental bugs.
Also, you will have more hidden errors because you are using the wrong method for calling data from external pairs. You need to be using iHigh instead of High.
Thanks @ nicholi shen and Anthony Garot the error is gone

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi All
I am getting an array out of range error when i try to backtest and its pointing to the High[] array , what is wrong with my coding?
Thank you