Why am i am getting Error 4401

Hello there,

I have developed a customized chart indicator for MT5 and I need to get the previous day close price for it.

Since MT5 doesn’t have a quote field for that information (as far as I know), I’m using these functions to do so: CopyRates(_Symbol,PERIOD_D1,0,2,Buffer) and CopyClose(_Symbol,PERIOD_D1,0,2,Buffer).

But, several times during the day these functions returns error 4401 (Requested history not found).


#1: why this error happens so frequently since the history already exists? (I’m assuming it!)

#2: some other way to get previous day close price?


  1. History does not exist. MT5 only stores M1 data and creates the rest when needed.
  2. On MT5: Unless the chart is that specific pair/TF, you must Synchronize the terminal Data from the Server.
    Timeseries and Indicators Access / Data Access - Reference on algorithmic/automated trading language for MetaTrader 5

It can happen because data are processed and the function returned immediately, just try again on next tick or next milliseconds or whatever.

If you want the previous day close price, then request it once. No need to request current price of the day (index 0), no need to request it “several times during the day”.