MT5 Python error -4: Not found (RES_E_NOT_FOUND)
What you asked for isn't there, for example no history for that symbol and range. The package's own docs call it no history.
What it means
You see this code in mt5.last_error() in Python, after a package call returns None or False.
-4 means the data or object the call asked for wasn't found. The package documentation describes it briefly as no history.
It doesn't mean the connection is broken. The terminal answered; it just had nothing to give.
Common causes
- Bars or ticks asked for before the terminal has loaded that history.
- A date range with no trading, such as a weekend.
- A symbol that isn't in Market Watch.
- Dates built in local time that miss the broker's server time.
How to fix it
- Call
mt5.symbol_select(symbol, True)first. - Retry after a short wait, so the terminal can load the history.
- Widen the range, and remember the broker's server clock is not UTC.
Example in Python:
import time
import MetaTrader5 as mt5
mt5.symbol_select("GBPJPY", True)
for _ in range(5):
rates = mt5.copy_rates_from_pos("GBPJPY", mt5.TIMEFRAME_H1, 0, 1000)
if rates is not None and len(rates):
break
print("not yet:", mt5.last_error())
time.sleep(1) Is it safe to retry?
Yes, after selecting the symbol or waiting for history to load.
Could the order have executed?
Not a trade. A data lookup, not a trade.
How Tickwire handles it
Broker server time is measured per server and never assumed to be UTC. See time zones.
Related codes
- MT5 error 4401: Requested history not found (ERR_HISTORY_NOT_FOUND)
- MT5 error 4302: Symbol is not selected in Market Watch (ERR_MARKET_NOT_SELECTED)
- MT5 Python error -3: Out of memory (RES_E_NO_MEMORY)
Related MT5 Python functions
- mt5.last_error() in MetaTrader5 Python: find out why the last call failed
- mt5.symbol_info() in MetaTrader5 Python: read a symbol's settings and limits
- mt5.symbol_info_tick() in MetaTrader5 Python: get the latest bid and ask
- mt5.symbol_select() in MetaTrader5 Python: add a symbol to Market Watch
- mt5.market_book_get() in MetaTrader5 Python: read the order book of a symbol
One API for MT4 and MT5
Clear trade outcomes, idempotent orders and an audit log. Read the error reference or the quickstart.