MetaTrader 4 APIErrors & rate limits
For AI agents: this page is also available as Markdown at /docs/mt4/errors.md. The index of every docs page is /docs/llms.txt.
Errors & rate limits
Every error from the MetaTrader 4 API is machine-readable: one envelope with a fixed code you can branch on, and codes that tell a trade that never ran from one that may have.
Errors
A wrong or missing API key returns HTTP 401 with UNAUTHORIZED (see Authentication). A read-only fxs_ro_ key returns HTTP 403 with READ_ONLY_KEY on the trading routes and on any method other than GET or HEAD. An unknown account ID or path returns a plain 404 from the edge. Everything else comes back in the same envelope: an error code, a message, and a command_id for log correlation. The code is fixed, so branch on it, never on the message:
{
"error": "MRPC_UNKNOWN_SYMBOL",
"message": "SymbolSelect failed — unknown symbol",
"command_id": 19
}| Code | HTTP | Meaning |
|---|---|---|
UNAUTHORIZED | 401 | Missing or wrong API key. |
READ_ONLY_KEY | 403 | A read-only key on a route that trades or changes the terminal. |
MRPC_VALIDATION | 400 | A parameter is missing or malformed. Nothing was sent. |
MRPC_UNKNOWN_TICKET | 400 | No order or position with that ticket. |
MRPC_UNKNOWN_SYMBOL | 400 | The broker has no symbol by that name. Check /symbols for the exact spelling, suffixes included. |
MRPC_BAD_TIMEFRAME | 400 | The timeframe isn't one of the nine the API serves. |
MRPC_UNSUPPORTED | 400 | Something MT4 can't do, such as a stop-limit order. Nothing was sent. |
MRPC_CLIENT_ORDER_ID_REUSED | 409 | The clientOrderId was already used for a different order in the last 10 minutes. Nothing was sent. |
MRPC_SYMBOL_NOT_QUOTING | 500 | The symbol has no price yet. Add it with /SymbolSelect first. |
MRPC_TICKET_BUSY | 500 | Another request for this ticket is still at the broker. Retry shortly. |
MRPC_TRADE_EA_NOT_READY | 503 | The terminal's trade engine isn't up yet, typically right after a start. Nothing was executed; retry. |
MRPC_TRADE_EA_STOPPED | 500 | The trade engine stopped before it sent the request. Nothing was executed; retry. |
MRPC_ABANDONED | 504 | The request timed out before the terminal took it. Not executed, safe to resend. |
MRPC_TIMEOUT | 504 | A read timed out. |
MRPC_TRADE_OUTCOME_UNKNOWN | 504 | A trade timed out after the terminal took it, so it may have executed. Check /OpenedOrders before you send it again, or resend it with the same clientOrderId. |
MRPC_HISTORY_UNAVAILABLE / MRPC_PRICE_HISTORY_UNAVAILABLE / MRPC_CALC_FAILED | 500 | The terminal couldn't produce the data, for example history the broker hasn't delivered yet. Retry later. |
MRPC_INTERNAL / MRPC_UNKNOWN_COMMAND | 500 | A fault in the terminal software. Quote the command_id when you report it. |
Three of these tell you whether a trade ran. MRPC_ABANDONED and MRPC_TRADE_EA_STOPPED mean it didn't, so sending it again is safe. MRPC_TRADE_OUTCOME_UNKNOWN means it may have, so never resend that order blindly. Send every order with a clientOrderId and the question goes away: a repeat with the same id never trades twice and returns the first reply instead (see Trading).
A 5xx response without the envelope means the terminal itself is down or restarting, for example during the brief restart after an API-key rotation. Terminals older than MT4 0.15.0 answer most failures with the generic code MRPC; bridge.version in /status shows which version an account runs.
MT4 Trade Errors and Their Retcodes
A rejected order is not an error response: the request worked, the broker said no. It comes back as HTTP 200 with success: false. MT4 itself only reports an error number for that, so the bridge translates it into the matching MT5 retcode and puts the original number in retcodeDescription. Your code can branch on the same retcodes for MT4 and MT5 accounts, and the MT4 number is still there when you need it:
{
"success": false,
"outcome": "rejected",
"retcode": 10019,
"retcodeDescription": "MT4 error 134: Not enough money",
"deal": 0,
"order": 0,
...
}| MT4 error | Meaning | retcode |
|---|---|---|
| 1 | No result: the order already has these values | 10025 No changes |
| 128 | Trade timeout | 10031 No connection |
| 129 | Invalid price | 10015 Invalid price |
| 130 | Invalid stops | 10016 Invalid stops |
| 131 | Invalid trade volume | 10014 Invalid volume |
| 132 | Market is closed | 10018 Market closed |
| 133 | Trade is disabled | 10017 Trading disabled |
| 134 | Not enough money | 10019 Not enough money |
| 135 | Price changed | 10015 Invalid price |
| 136 | Off quotes | 10021 No quotes |
| 138 | Requote | 10004 Requote |
| 139 | Order is locked | 10013 Invalid request |
| 145 | Modification denied, too close to market | 10016 Invalid stops |
| 146 | Trade context is busy | 10024 Too many requests |
| 148 | Too many open and pending orders | 10033 Order limit reached |
| 4108 | Invalid ticket | 10013 Invalid request |
| 4109 | Trading not allowed | 10017 Trading disabled |
| 4110 / 4111 | Long or short positions not allowed | 10017 Trading disabled |
| any other | Anything not listed above | 10006 Rejected |
A successful market order reports 10009 (Done), a placed pending order 10008 (Placed). outcome sums the result up as applied, no_change (retcode 10025, safe to treat as applied), partial or rejected.
Requests MT4 cannot express at all never reach the broker. A stop-limit order (BuyStopLimit, SellStopLimit) is answered with HTTP 400 and {"error": "MRPC_UNSUPPORTED", "message": "stop-limit orders are not supported on MT4"}. Error 146, trade context busy, means MT4 was still handling another order; MT4 processes one at a time, so retry shortly after.
Rate Limits
Terminal requests are served by your own dedicated terminal, so heavy polling only slows down your own account, nobody else's. Platform routes under /v1 are rate limited per API key: if you exceed a limit you get a 429 with a Retry-After header, so wait that long and retry. For live prices, positions, or account changes, prefer the WebSocket streams over polling: you get pushed updates without burning round-trips.