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 envelope
{
  "error": "MRPC_UNKNOWN_SYMBOL",
  "message": "SymbolSelect failed — unknown symbol",
  "command_id": 19
}
CodeHTTPMeaning
UNAUTHORIZED401Missing or wrong API key.
READ_ONLY_KEY403A read-only key on a route that trades or changes the terminal.
MRPC_VALIDATION400A parameter is missing or malformed. Nothing was sent.
MRPC_UNKNOWN_TICKET400No order or position with that ticket.
MRPC_UNKNOWN_SYMBOL400The broker has no symbol by that name. Check /symbols for the exact spelling, suffixes included.
MRPC_BAD_TIMEFRAME400The timeframe isn't one of the nine the API serves.
MRPC_UNSUPPORTED400Something MT4 can't do, such as a stop-limit order. Nothing was sent.
MRPC_CLIENT_ORDER_ID_REUSED409The clientOrderId was already used for a different order in the last 10 minutes. Nothing was sent.
MRPC_SYMBOL_NOT_QUOTING500The symbol has no price yet. Add it with /SymbolSelect first.
MRPC_TICKET_BUSY500Another request for this ticket is still at the broker. Retry shortly.
MRPC_TRADE_EA_NOT_READY503The terminal's trade engine isn't up yet, typically right after a start. Nothing was executed; retry.
MRPC_TRADE_EA_STOPPED500The trade engine stopped before it sent the request. Nothing was executed; retry.
MRPC_ABANDONED504The request timed out before the terminal took it. Not executed, safe to resend.
MRPC_TIMEOUT504A read timed out.
MRPC_TRADE_OUTCOME_UNKNOWN504A 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_FAILED500The terminal couldn't produce the data, for example history the broker hasn't delivered yet. Retry later.
MRPC_INTERNAL / MRPC_UNKNOWN_COMMAND500A 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:

Rejected order on MT4
{
  "success": false,
  "outcome": "rejected",
  "retcode": 10019,
  "retcodeDescription": "MT4 error 134: Not enough money",
  "deal": 0,
  "order": 0,
  ...
}
MT4 errorMeaningretcode
1No result: the order already has these values10025 No changes
128Trade timeout10031 No connection
129Invalid price10015 Invalid price
130Invalid stops10016 Invalid stops
131Invalid trade volume10014 Invalid volume
132Market is closed10018 Market closed
133Trade is disabled10017 Trading disabled
134Not enough money10019 Not enough money
135Price changed10015 Invalid price
136Off quotes10021 No quotes
138Requote10004 Requote
139Order is locked10013 Invalid request
145Modification denied, too close to market10016 Invalid stops
146Trade context is busy10024 Too many requests
148Too many open and pending orders10033 Order limit reached
4108Invalid ticket10013 Invalid request
4109Trading not allowed10017 Trading disabled
4110 / 4111Long or short positions not allowed10017 Trading disabled
any otherAnything not listed above10006 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.