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.

-4RES_E_NOT_FOUND
Yes, after a waitSafe to retry?
Not a tradeCould it have executed?

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 MT5 Python functions

All MetaTrader error codes

All MetaTrader5 Python functions

One API for MT4 and MT5

Clear trade outcomes, idempotent orders and an audit log. Read the error reference or the quickstart.