Why the data of PERIOD_M1 cannot be received?

 
Using the following statement, the data of PERIOD_M1 cannot be received, but other cycles such as PERIOD_M5 and PERIOD_M15 are normal. Does anyone know the reason,Thank you for your help!
 MqlRates rates[];
 int copied=CopyRates("XAUUSD",PERIOD_M1,D'2021.06.10 14:00:00',D'2021.06.10 19:00:00',rates);
 double n=rates[0].open;
 
Blur Darkness: Using the following statement, the data of PERIOD_M1 cannot be received, 

You asked for zero and got zero. You expect something else?

Now you change the code to invalidate the above response.

 
William Roeder #:

You asked for zero and got zero. You expect something else?

Now you change the code to invalidate the above response.


When I change the period ,I can get a result,but only the PERIOD_M1 can't

 
William Roeder #:

You asked for zero and got zero. You expect something else?

Now you change the code to invalidate the above response.

Where did you see it asked for sero? I see e request for 5 hours of minute bars , well if the start date is before the current date

 
Blur Darkness:
Using the following statement, the data of PERIOD_M1 cannot be received, but other cycles such as PERIOD_M5 and PERIOD_M15 are normal. Does anyone know the reason,Thank you for your help!

The help says same serie as the chart should not be loaded in order to avoid highly probable deadlock because they use the same thread , so those request might be deferred as well.

 
If you request foreign chart history or data from a foreign chart period you have to wait for the request processing in the background. Bail out if you don't get your data right now and retry it on the next call.
 
Carlos Albert Barbero Marcos # :

The help says same serie as the chart should not be loaded in order to avoid highly probable deadlock because they use the same thread , so those request might be deferred as well.


Thank you.

I had reinstalled the old version of MT5, the problem was solved, it should be caused by updating the software.

 
lippmaje # :
If you request foreign chart history or data from a foreign chart period you have to wait for the request processing in the background. Bail out if you don't get your data right now and retry it on the next call.

Thank you!

I reinstalled the old version of MT5 and the problem was solved.

 
Blur Darkness #:

Thank you!

I reinstalled the old version of MT5 and the problem was solved.

You shouldn't do that, it's not the right way to address this issue.

Check the return value and LastError, and redo the call when missing history is indicated.

CopyRates

>> When requesting data from the indicator, if requested timeseries are not yet built or they need to be downloaded from the server, the function will immediately return -1, but the process of downloading/building will be initiated.

   MqlRates rates[];
   ResetLastError();
   int copied=CopyRates("XAUUSD",PERIOD_M1,D'2021.06.10 14:00:00',D'2021.06.10 19:00:00',rates);

   if(copied == -1)
    {
      // check for history issues here and act accordingly
      if(_LastError == ERR_HISTORY_NOT_FOUND) ...
    }
Documentation on MQL5: Timeseries and Indicators Access / CopyRates
Documentation on MQL5: Timeseries and Indicators Access / CopyRates
  • www.mql5.com
CopyRates - Timeseries and Indicators Access - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Reason: