Check an order
MT5's OrderCheck: whether the order would pass, and the margin it would take. Nothing is sent to the trade server. Takes the same body as Place an order.
Path
The account's id, acc_ and 26 characters, as the dashboard shows it.
Body
Left out: MT5's empty valuesThe symbol exactly as the broker names it, such as EURUSD.
What to send. buy and sell fill now; the others wait at price. close_by is refused here: use Close by.
Lots. MT5 rejects a volume outside the symbol's minimum, maximum and step.
How the order may fill. Required: each symbol allows its own modes (its filling_modes).
Required for pending orders: the price the order waits for. For a market order it is sent as given (0 if left out): brokers with instant or request execution need it, those with market or exchange execution ignore it.
Required for buy_stop_limit and sell_stop_limit: the price of the limit order placed once price is reached.
Stop loss price, set in the same request. 0 or left out: none.
Take profit price, set in the same request. 0 or left out: none.
The largest difference from price MT5 accepts, in points, for instant or request execution.
How long a pending order lasts. gtc if left out.
When a pending order expires: broker server time, seconds since 1970. Required for type_time specified and specified_day.
Your own number for the order, kept by MT5 on the order, its deals and its position.
Up to 31 characters, kept by MT5 on the order. Brokers may replace it.
Response
MT5's MqlTradeRequest, field for field, exactly as recorded to send to the terminal: the request's state and result say whether it reached MT5. Fields the call does not use carry MT5's empty values (0, "", fok, gtc).
Fields of sent
What the request does.
The symbol, exactly as the broker names it.
The order type.
Lots.
The price: a pending order's, or the one instant and request execution trade at.
A stop-limit order's limit price, placed once price is reached.
Stop loss price; 0 for none.
Take profit price; 0 for none.
The largest difference from price MT5 accepts, in points.
How the order may fill.
How long a pending order lasts.
Broker server time, seconds since 1970, as MT5 takes it.
The pending order the request is about (modify, remove).
The position the request is about (close, stops, close by).
The opposite position, for close by.
Your own number, kept by MT5 on the order, its deals and its position.
Up to 31 characters, kept by MT5 on the order.
MT5's MqlTradeCheckResult.
Fields of result
Whether OrderCheck passed the request.
MT5's return code: 0 when the check passed.
The return code's name; UNKNOWN for a code MT5 doesn't document.
The balance after the trade.
The equity after the trade.
The floating profit after the trade.
The margin the trade takes.
The free margin after the trade.
The margin level after the trade, in percent.
The return code's meaning, in a sentence.
Errors
| 401 | invalid_api_key | The key is not a workspace's current key (a rolled key stops working within about a minute). |
| 401 | missing_api_key | No API key: send it as |
| 404 | no_such_account | No such account, or one the key's workspace doesn't have: the two look the same. |
| 422 | invalid_request | A field, query parameter or header is missing, malformed or not allowed, or the body is not JSON. Nothing was sent. |
| 503 | account_not_connected | The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders. |
| 503 | bad_command | The terminal refused the command, for example a negative |
| 503 | bridge_outdated | The account's terminal runs an older bridge that can't trade: restart the account to update it. Nothing was sent. |
| 503 | engine_busy | The account's engine host has too many calls in flight (256). Nothing was done; try again. |
| 503 | engine_unavailable | The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up. |
| 504 | engine_timeout | The account's engine did not answer within 30 seconds. |
| 504 | terminal_timeout | The account's terminal did not answer within 5 seconds. |