MQL5- CopyRates function returning -1 with error 4401

 

Good morning,

I've a strange behaviour using CopyRates function in MQL5. I try to load some Rates using CopyRates function for a specific Symbol. The requested data are on a PERIOD_M1 and represent two months of rates starting from the SERIES_TERMINAL_FIRSTDATE of the Symbol.

The first time I run the script, the function always returns -1 with error "Error while loading data : 4401". When I restart the script, it works perfectly. It's like between the two launchs MT5 loaded the data asynchronously.

Is there a solution to avoid this problem like (loading the rates first) ?

Thanks