MT5 error 10004: Requote (TRADE_RETCODE_REQUOTE)
The server offered a new price instead of filling at yours. Nothing was executed; refresh the quote and send again.
What it means
You see this code in the retcode of a trade result, from OrderSend() in MQL5 or order_send() in Python.
A requote means the price in your request was no longer available when the broker processed it, so the server answered with a fresh price instead of a fill.
It shows up on symbols that use instant or request execution, where the request carries a price and a maximum deviation. If the market moves further than that deviation, you get 10004.
Common causes
- A fast market, such as a news release or the session open.
- A
deviationof 0 or a few points on a volatile symbol. - A price taken from an old tick, for example one read before a slow calculation.
- Network delay between your code and the terminal.
How to fix it
- Read a fresh tick right before each send and use its Ask for a buy or its Bid for a sell.
- Allow a realistic
deviationin points for the symbol. - Retry a small number of times, then stop and report, so a moving market can't keep you in a loop.
Example in Python:
import MetaTrader5 as mt5
def buy_market(symbol, volume, attempts=3):
for _ in range(attempts):
tick = mt5.symbol_info_tick(symbol)
r = mt5.order_send({
"action": mt5.TRADE_ACTION_DEAL, "symbol": symbol,
"volume": volume, "type": mt5.ORDER_TYPE_BUY,
"price": tick.ask, "deviation": 20,
})
if r is None:
raise RuntimeError(mt5.last_error())
if r.retcode not in (mt5.TRADE_RETCODE_REQUOTE, mt5.TRADE_RETCODE_PRICE_CHANGED):
return r
return r # still requoted: give up and report Is it safe to retry?
Yes, with a fresh price. The first request was not filled, so a new one can't double your position. Cap the number of tries.
Could the order have executed?
No. A requote is an offer, not a fill. The order did not open.
How Tickwire handles it
For a market order, Tickwire reads a fresh price and sends again, up to 2 more times. If the last answer is still a requote, you get 10004 with outcome rejected.
MT4 error 138 comes back as 10004 too. See trade results.
Related codes
- MT5 error 10020: Prices changed (TRADE_RETCODE_PRICE_CHANGED)
- MT5 error 10021: No quotes to process the request (TRADE_RETCODE_PRICE_OFF)
- MT4 error 138: Requote (ERR_REQUOTE)
- MT4 error 135: Price changed (ERR_PRICE_CHANGED)
Related MT5 Python functions
One API for MT4 and MT5
Clear trade outcomes, idempotent orders and an audit log. Read the error reference or the quickstart.