CopyRates array working Live but fails on Backtesting returning Critical Error

 
The tester ran without a problem for the last few months, but for previous years I get the error


MqlRates lon[];
MqlDateTime structTime;
MqlDateTime endTime;


void OnTick()
  {
//---
   int start = 0;
   int end = 8;
   TimeCurrent(structTime);
   TimeCurrent(endTime);
   structTime.hour = start;
   endTime.hour = end;
   structTime.min = 00;
   endTime.min = 00;
   
   datetime start_time = StructToTime(structTime);
   datetime endT = StructToTime(endTime);
   
   CopyRates(_Symbol,PERIOD_H1,start_time,endT,lon);
  
   Comment(lon[2].low);

   
  }
//+------------------------------------------------------------------+


No compilation errors



Files:
error.png  11 kb
 
niceponaytrader:
The tester ran without a problem for the last few months, but for previous years I get the error




No compilation errors



You need to manage the return values of CopyRates.

Do not assume it works, check the result.
 
Dominik Egert #:
You need to manage the return values of CopyRates.

Do not assume it works, check the result.

The ararry does not receive anything in a distant period, in the near period it does

 
niceponaytrader #:
ararry does not receive anything in a distant period, in the near perio

if everything works fine with shorter periods but not with longer ones, it could be because there is simply no loner period data in your history. See how long a period you can download from the terminal from the broker. Or maybe is faulty. try to reinstall and reload data.

So first see how much data you have in your struct array:  Print("your array size", ArraySize(lon));

If that is not enough then use other ways to get tick-data.  Services such as tick data suite are available.   

 
niceponaytrader #:

The ararry does not receive anything in a distant period, in the near period it does

What is _LastError? What is the return value of CopyRates?

 
Dominik Egert #:
What is _LastError? What is the return value of CopyRates?

how to check?

 
titaanlabidas #:

if everything works fine with shorter periods but not with longer ones, it could be because there is simply no loner period data in your history. See how long a period you can download from the terminal from the broker. Or maybe is faulty. try to reinstall and reload data.

So first see how much data you have in your struct array:  Print("your array size", ArraySize(lon));

If that is not enough then use other ways to get tick-data.  Services such as tick data suite are available.   

How can I reset the information I have regarding the past data of the candles

 
niceponaytrader #:

how to check?

Please refer to the manual on how to print values to the expert journal tab.


And also check this page, please:


If you still don't know how to do it, please consider reading this:


Then continue with this please: