TROUBLESHOOTING · METATRADER 5

MT5 error codes: every trade retcode explained

SYMPTOM

An order failed and the Journal shows a numeric code like 10016 or 10030.

Causes, most likely first

1. Error 10016 — invalid stops

The stop loss or take profit is too close to the current price, on the wrong side of it, or violates the symbol stops level. The most common rejection for EAs on gold. Full diagnosis: invalid stops.

2. Error 10019 — not enough money

The margin required for the requested volume exceeds free margin. Usually a lot size problem rather than a balance problem. See not enough money.

3. Error 10014 — invalid volume

The lot size is below the minimum, above the maximum, or not a multiple of the volume step. See invalid volume.

4. Errors 10026 and 10027 — autotrading disabled by server / by client

Client means a setting on your machine, fixed in one click; server means the broker has blocked it. See AutoTrading disabled.

5. Error 10030 — unsupported filling mode

The order requested a fill policy the symbol does not allow — typical when an EA moves brokers. See unsupported filling mode.

6. Errors 10004, 10015, 10020, 10021 — price problems

Requote, invalid price, price changed, off quotes: the price moved between decision and execution, or no quote was available. See requotes and invalid price.

The full retcode table

CodeNameMeaning
10004REQUOTEPrice changed before execution; broker offers a new price
10006REJECTRequest rejected by the server
10007CANCELRequest cancelled by the trader
10008PLACEDOrder placed — success, not an error
10009DONERequest completed — success, not an error
10010DONE_PARTIALOnly part of the requested volume was filled
10011ERRORRequest processing error on the server
10012TIMEOUTRequest cancelled because it timed out
10013INVALIDMalformed or invalid request
10014INVALID_VOLUMELot size below minimum, above maximum or off the volume step
10015INVALID_PRICEThe price in the request is invalid
10016INVALID_STOPSSL or TP too close, on the wrong side, or inside the stops level
10017TRADE_DISABLEDTrading is disabled for the account or symbol
10018MARKET_CLOSEDThe market for this symbol is closed
10019NO_MONEYNot enough free margin for the requested volume
10020PRICE_CHANGEDPrice changed while the request was being processed
10021PRICE_OFFNo quotes available to process the request (off quotes)
10022INVALID_EXPIRATIONInvalid order expiration in the request
10023ORDER_CHANGEDOrder state changed while the request was in flight
10024TOO_MANY_REQUESTSRequests sent too frequently
10025NO_CHANGESThe request contains no changes
10026SERVER_DISABLES_ATAutotrading disabled by the server
10027CLIENT_DISABLES_ATAutotrading disabled by the client terminal
10028LOCKEDRequest locked — already being processed
10029FROZENOrder or position frozen; too close to execution to modify
10030INVALID_FILLUnsupported order filling mode for this symbol
10031CONNECTIONNo connection with the trade server
10032ONLY_REALOperation allowed only on live accounts
10033LIMIT_ORDERSPending order limit for the account reached
10034LIMIT_VOLUMEVolume limit for the symbol reached
10035INVALID_ORDERIncorrect or prohibited order type
10036POSITION_CLOSEDThe position is already closed
10038INVALID_CLOSE_VOLUMEClose volume exceeds the open position volume
10039CLOSE_ORDER_EXISTA close order for this position already exists
10040LIMIT_POSITIONSOpen position limit for the account reached
10041REJECT_CANCELPending order activation rejected; order cancelled
10042LONG_ONLYOnly long positions allowed on this symbol
10043SHORT_ONLYOnly short positions allowed on this symbol
10044CLOSE_ONLYOnly position closing allowed on this symbol
10045FIFO_CLOSEPositions must be closed in FIFO order (US accounts)
10046HEDGE_PROHIBITEDOpposite positions on the same symbol are prohibited

Take the whole thing as data

All three tables on this page are published as an open dataset under CC BY 4.0, with a permanent identifier: DOI 10.5281/zenodo.22296252. CSV and JSON, also mirrored on Hugging Face. If you are building tooling that has to turn a retcode into a human explanation, take the file rather than scraping this page — it is generated from the same source, so it cannot drift from what you see here.

MQL runtime errors are a different list

If you read the failure from inside the expert advisor with _LastError or GetLastError(), you get a number from a different table: the MQL5 runtime errors in the 4000s, not the server retcodes above. The two are easy to confuse because both describe the same failed order. The runtime code says *that* the trade call failed; the retcode in MqlTradeResult says *why*. Log the retcode.

Runtime codeNameWhat it meansWhere the real reason is
4752ERR_TRADE_DISABLEDTrading by expert advisors is prohibitedRetcode 10027 — the Algo Trading button or EA permission
4753ERR_TRADE_POSITION_NOT_FOUNDThe position ticket does not existUsually a netting account that has already merged the position
4754ERR_TRADE_ORDER_NOT_FOUNDThe order ticket does not existAlready filled, cancelled, or the wrong ticket
4755ERR_TRADE_DEAL_NOT_FOUNDThe deal ticket does not existHistory not yet selected with HistorySelect()
4756ERR_TRADE_SEND_FAILEDThe trade request was not sent, or was rejectedMqlTradeResult.retcode — any of the codes in the table above
4758ERR_TRADE_CALC_FAILOrderCalcMargin or OrderCalcProfit failedBad symbol, volume or price passed to the calculation
4759ERR_TRADE_WRONG_PROPERTYWrong trade property requestedA code error in the EA, not the broker

MetaTrader 4 error numbers and their MT5 equivalents

Most forum answers still quote MT4 error numbers, and most of the people searching for them are now on MT5. The conditions did not change when the platform did; only the numbers did. This is the mapping.

MT4 errorMT4 nameMT5 retcodeDiagnosis
129ERR_INVALID_PRICE10015Invalid price — see invalid price
130ERR_INVALID_STOPS10016Stop too close or wrong side — see invalid stops
131ERR_INVALID_TRADE_VOLUME10014Lot size off the min/max/step — see invalid volume
132ERR_MARKET_CLOSED10018Outside the session — see market closed
133ERR_TRADE_DISABLED10017Trading disabled for the account or symbol
134ERR_NOT_ENOUGH_MONEY10019Free margin — see not enough money
135ERR_PRICE_CHANGED10020Price moved during processing
136ERR_OFF_QUOTES10021No quotes available — see no quotes
138ERR_REQUOTE10004Requote — see requotes
146ERR_TRADE_CONTEXT_BUSY— (10024 is the nearest)MT5 has no trade context lock; see trade context busy
148ERR_TRADE_TOO_MANY_ORDERS10033Pending order limit reached
4109ERR_TRADE_NOT_ALLOWED10027EA not permitted to trade — see AutoTrading disabled
4112AutoTrading disabled by server10026Broker-side flag — see AutoTrading disabled

Why this happens

Two code families look alike and are not. Codes in the 10000s are trade server retcodes — the server answering a specific order request, listed above. Codes in the 4000s are MQL5 runtime errors from inside the EA itself. A retcode appears in the Journal tab attached to the rejected order; runtime errors appear in the Experts tab.

10008 and 10009 are in the table because people look them up as if they were failures. They are the success codes.

The FIFO and hedging codes at the bottom — 10045 and 10046 — only appear on netting or US-regulated accounts, which is why an EA can run for years on an offshore broker and produce them on its first day on a US one. See FIFO and netting rules.

Common questions

Where do I see the error code in MT5?

The Journal tab of the Toolbox window logs every order request with its retcode. The Experts tab logs what the EA itself prints, including MQL5 runtime errors. For a rejected order, the Journal entry is the authoritative one.

What is the difference between retcode 10004 and 10020?

Both mean the price moved. 10004 is a formal requote — the broker offers you a new price to accept or decline. 10020 means the request simply failed because prices changed while it was processed, and the EA must resend.

Related problems

MT5 trading botAll troubleshootingContact support

Educational information only, not financial advice. Trading leveraged products carries substantial risk of loss. Last updated 2026-09-04.