I was coding an ea to trade multiple symbols and have encountered a problem; when backtesting i get an error trying to load ATR:
I belive this is the useful part of the code:
Here are the parameters i used to backtest:
The code works fine when i set my custom period to start later:2015 instead of 2007, and it works fine with 5 pairs, now is set to 28. I didn't change anything except the num. of pairs used for trading when the code stopped working. Maybe a relevant info is that i create indictor handles for each pair and store it in an array for later use, I do this with two indicators which means 56 handles, maybe that has something to do with it, maybe too much data because of a long period and a lot of pairs, I have no idea so any help is appreciated.
If i forgot to add any meaningful info please remind me to, and thanks for your help.
Where do you create the indicator handle: in OnInit ()?
Attached it now..
My iATR handles were created without any problems because for me: the maximum number of bars is set in the terminal settings.
I also recommend reading the Help (for a multicurrency test, symbols should be added to the Market Watch window)
//+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int OnInit() { //Populate SymbolArray and determine the number of symbols being traded NumberOfTradeableSymbols = StringSplit(TradeSymbols, '|', SymbolArray); for(int i=0; i<NumberOfTradeableSymbols; i++) { SymbolSelect(SymbolArray[i],true); }
My iATR handles were created without any problems because for me: the maximum number of bars is set in the terminal settings.
I also recommend reading the Help (for a multicurrency test, symbols should be added to the Market Watch window)
I changed my max bars to unlimited, used the function to display max bars and it returned 10 000 000, calculating num of bars for the period tested on all symbols gives 70 000, if there are 365 bars in a year, which should not be a problem. I had all the symbols in the marketwatch and even with the added code still the same error. Would maybe uninstalling MT5 and reinstalling it fix the problem? i read of a simmilar error and this appeared to be the solution. Thaks for all the help, as i clearly don't understand the platform this much.
What date are you starting the test from? Start from 2020.01.01 and select the "every tick" mode. Forget the 'OHLC' mode like a bad dream.
Look at the error - you are missing a history - this can be seen in the error message.
You always need to create Expert Advisors, gradually complicating them. For example: first, throw out all custom indicators, leave only five symbols, not 28, run the test from 2020, not from the time of birth of the dinosaurs ...
- www.mql5.com
Look at the error - you are missing a history - this can be seen in the error message.
You always need to create Expert Advisors, gradually complicating them. For example: first, throw out all custom indicators, leave only five symbols, not 28, run the test from 2020, not from the time of birth of the dinosaurs ...
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I was coding an ea to trade multiple symbols and have encountered a problem; when backtesting i get an error trying to load ATR:
I belive this is the useful part of the code:
Here are the parameters i used to backtest:
The code works fine when i set my custom period to start later:2015 instead of 2007, and it works fine with 5 pairs, now is set to 28. I didn't change anything except the num. of pairs used for trading when the code stopped working. Maybe a relevant info is that i create indictor handles for each pair and store it in an array for later use, I do this with two indicators which means 56 handles, maybe that has something to do with it, maybe too much data because of a long period and a lot of pairs, I have no idea so any help is appreciated.
If i forgot to add any meaningful info please remind me to, and thanks for your help.