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
| Code | Name | Meaning |
|---|---|---|
| 10004 | REQUOTE | Price changed before execution; broker offers a new price |
| 10006 | REJECT | Request rejected by the server |
| 10007 | CANCEL | Request cancelled by the trader |
| 10008 | PLACED | Order placed — success, not an error |
| 10009 | DONE | Request completed — success, not an error |
| 10010 | DONE_PARTIAL | Only part of the requested volume was filled |
| 10011 | ERROR | Request processing error on the server |
| 10012 | TIMEOUT | Request cancelled because it timed out |
| 10013 | INVALID | Malformed or invalid request |
| 10014 | INVALID_VOLUME | Lot size below minimum, above maximum or off the volume step |
| 10015 | INVALID_PRICE | The price in the request is invalid |
| 10016 | INVALID_STOPS | SL or TP too close, on the wrong side, or inside the stops level |
| 10017 | TRADE_DISABLED | Trading is disabled for the account or symbol |
| 10018 | MARKET_CLOSED | The market for this symbol is closed |
| 10019 | NO_MONEY | Not enough free margin for the requested volume |
| 10020 | PRICE_CHANGED | Price changed while the request was being processed |
| 10021 | PRICE_OFF | No quotes available to process the request (off quotes) |
| 10022 | INVALID_EXPIRATION | Invalid order expiration in the request |
| 10023 | ORDER_CHANGED | Order state changed while the request was in flight |
| 10024 | TOO_MANY_REQUESTS | Requests sent too frequently |
| 10025 | NO_CHANGES | The request contains no changes |
| 10026 | SERVER_DISABLES_AT | Autotrading disabled by the server |
| 10027 | CLIENT_DISABLES_AT | Autotrading disabled by the client terminal |
| 10028 | LOCKED | Request locked — already being processed |
| 10029 | FROZEN | Order or position frozen; too close to execution to modify |
| 10030 | INVALID_FILL | Unsupported order filling mode for this symbol |
| 10031 | CONNECTION | No connection with the trade server |
| 10032 | ONLY_REAL | Operation allowed only on live accounts |
| 10033 | LIMIT_ORDERS | Pending order limit for the account reached |
| 10034 | LIMIT_VOLUME | Volume limit for the symbol reached |
| 10035 | INVALID_ORDER | Incorrect or prohibited order type |
| 10036 | POSITION_CLOSED | The position is already closed |
| 10038 | INVALID_CLOSE_VOLUME | Close volume exceeds the open position volume |
| 10039 | CLOSE_ORDER_EXIST | A close order for this position already exists |
| 10040 | LIMIT_POSITIONS | Open position limit for the account reached |
| 10041 | REJECT_CANCEL | Pending order activation rejected; order cancelled |
| 10042 | LONG_ONLY | Only long positions allowed on this symbol |
| 10043 | SHORT_ONLY | Only short positions allowed on this symbol |
| 10044 | CLOSE_ONLY | Only position closing allowed on this symbol |
| 10045 | FIFO_CLOSE | Positions must be closed in FIFO order (US accounts) |
| 10046 | HEDGE_PROHIBITED | Opposite 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 code | Name | What it means | Where the real reason is |
|---|---|---|---|
| 4752 | ERR_TRADE_DISABLED | Trading by expert advisors is prohibited | Retcode 10027 — the Algo Trading button or EA permission |
| 4753 | ERR_TRADE_POSITION_NOT_FOUND | The position ticket does not exist | Usually a netting account that has already merged the position |
| 4754 | ERR_TRADE_ORDER_NOT_FOUND | The order ticket does not exist | Already filled, cancelled, or the wrong ticket |
| 4755 | ERR_TRADE_DEAL_NOT_FOUND | The deal ticket does not exist | History not yet selected with HistorySelect() |
| 4756 | ERR_TRADE_SEND_FAILED | The trade request was not sent, or was rejected | MqlTradeResult.retcode — any of the codes in the table above |
| 4758 | ERR_TRADE_CALC_FAIL | OrderCalcMargin or OrderCalcProfit failed | Bad symbol, volume or price passed to the calculation |
| 4759 | ERR_TRADE_WRONG_PROPERTY | Wrong trade property requested | A 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 error | MT4 name | MT5 retcode | Diagnosis |
|---|---|---|---|
| 129 | ERR_INVALID_PRICE | 10015 | Invalid price — see invalid price |
| 130 | ERR_INVALID_STOPS | 10016 | Stop too close or wrong side — see invalid stops |
| 131 | ERR_INVALID_TRADE_VOLUME | 10014 | Lot size off the min/max/step — see invalid volume |
| 132 | ERR_MARKET_CLOSED | 10018 | Outside the session — see market closed |
| 133 | ERR_TRADE_DISABLED | 10017 | Trading disabled for the account or symbol |
| 134 | ERR_NOT_ENOUGH_MONEY | 10019 | Free margin — see not enough money |
| 135 | ERR_PRICE_CHANGED | 10020 | Price moved during processing |
| 136 | ERR_OFF_QUOTES | 10021 | No quotes available — see no quotes |
| 138 | ERR_REQUOTE | 10004 | Requote — see requotes |
| 146 | ERR_TRADE_CONTEXT_BUSY | — (10024 is the nearest) | MT5 has no trade context lock; see trade context busy |
| 148 | ERR_TRADE_TOO_MANY_ORDERS | 10033 | Pending order limit reached |
| 4109 | ERR_TRADE_NOT_ALLOWED | 10027 | EA not permitted to trade — see AutoTrading disabled |
| 4112 | AutoTrading disabled by server | 10026 | Broker-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 OrderSend failedThe Journal shows OrderSend failed with a numeric retcode and no obvious reason.…
- MT5 invalid stops errorOrders are rejected with "Invalid stops" or error 130, or positions open without SL and TP.…
- MT5 "not enough money" errorOrders are rejected with "Not enough money" or error 134, even though the balance looks fine.…
Educational information only, not financial advice. Trading leveraged products carries substantial risk of loss. Last updated 2026-09-04.