MT5 error 4401: Requested history not found (ERR_HISTORY_NOT_FOUND)
The terminal has no price history for this symbol, timeframe or date range yet. Wait for it to download, or ask for a range it has.
What it means
You see this code in GetLastError() in MQL5, after a function fails.
Charts and bar data are stored on the terminal. When you ask for bars it doesn't hold, the call can fail with 4401 while the terminal fetches them from the server.
It is common on the first request for a symbol or timeframe, and for dates far in the past.
Common causes
- A first request for a symbol or timeframe the terminal has never loaded.
- A date range older than the broker keeps.
- A range limited by the terminal's "Max bars in chart" setting.
- A symbol that isn't selected in Market Watch.
How to fix it
- Retry after a short wait. The terminal loads history in the background.
- Ask for fewer bars, or a more recent range.
- Check
SeriesInfoInteger(sym, tf, SERIES_SYNCHRONIZED)before reading.
Example in MQL5:
MqlRates rates[];
for(int attempt = 0; attempt < 10; attempt++)
{
ResetLastError();
int got = CopyRates(_Symbol, PERIOD_H1, 0, 500, rates);
if(got > 0) { Print("got ", got, " bars"); break; }
Print("no history yet, error ", GetLastError(), ", waiting");
Sleep(500);
} Is it safe to retry?
Yes, after a short wait for the history to load.
Could the order have executed?
Not a trade code. It is about data, not orders.
Related codes
- MT5 error 4302: Symbol is not selected in Market Watch (ERR_MARKET_NOT_SELECTED)
- MT5 Python error -4: Not found (RES_E_NOT_FOUND)
- MT5 error 4755: Deal not found (ERR_TRADE_DEAL_NOT_FOUND)
Related MT5 Python functions
- mt5.copy_rates_from() in MetaTrader5 Python: get bars back from a date
- mt5.copy_rates_from_pos() in MetaTrader5 Python: get the latest bars by position
- mt5.copy_rates_range() in MetaTrader5 Python: get bars between two dates
- mt5.copy_ticks_from() in MetaTrader5 Python: get ticks forward from a date
- mt5.copy_ticks_range() in MetaTrader5 Python: get ticks between two dates
- mt5.history_orders_get() in MetaTrader5 Python: read past orders
- mt5.history_deals_get() in MetaTrader5 Python: read past deals and fills
One API for MT4 and MT5
Clear trade outcomes, idempotent orders and an audit log. Read the error reference or the quickstart.