Error trying to load ATR

 

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.

Files:
prenos1.png  26 kb
prenos2.png  38 kb
prenos3.png  24 kb
 
reday1324 :

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 ()?

 
Vladimir Karputov:

Where do you create the indicator handle: in OnInit ()?

Yes, I created a function to populate the arrays declared as a global variable. The function is called in OnInnit. The arrays are also resized to the number of pairs before the function is called.
 
reday1324 :
Yes, I created a function to populate the arrays declared as a global variable. The function is called in OnInnit. The arrays are also resized to the number of pairs before the function is called.

You didn't show the code.

 
Vladimir Karputov:

You didn't show the code.

Attached it now..

Files:
template.mq5  30 kb
 
reday1324 :

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);
     }
 
Vladimir Karputov:

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.
 
reday1324 :
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 ...

Create Your Own Expert Advisor in MQL5 Wizard
Create Your Own Expert Advisor in MQL5 Wizard
  • www.mql5.com
The knowledge of programming languages is no longer a prerequisite for creating trading robots. Earlier lack of programming skills was an impassable obstacle to the implementation of one's own trading strategies, but with the emergence of the MQL5 Wizard, the situation radically changed. Novice traders can stop worrying because of the lack of programming experience - with the new Wizard, which allows you to generate Expert Advisor code, it is not necessary.
 
Vladimir Karputov:

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 ...

I see what you mean, but for optimization of parameters a large sample size is important, to determine overfittedd parameters and stuff like that and then test on out of sample data, thats the reason why so many symbols on 7 years, the custom indicators are just something i've been trying out to see how it works, since none of the more known methods worked for me. Now i will probably start over with that error in mind so that all my demands are met by the ea and i can actually backtest it, thanks again for your help.
Reason: