TROUBLESHOOTING · METATRADER 5
MT5 OrderSend failed
SYMPTOM
The Journal shows OrderSend failed with a numeric retcode and no obvious reason.
Causes, most likely first
1. Retcode 10016 — invalid stops
The stop or target violates the broker's minimum distance, sits on the wrong side, or is misaligned with tick size. Full diagnosis at invalid stops.
2. Retcode 10019 — not enough money
Free margin is insufficient for the requested volume. See not enough money.
3. Retcode 10014 — invalid volume
The lot size breaches the symbol minimum, maximum or step. See invalid volume.
4. Retcode 10018 — market closed
The symbol is outside its trading session. Gold has a daily break and is closed at weekends, and the exact times are in the symbol specification. See market closed.
5. Retcode 10013 — invalid request
The request structure itself is malformed, so the server never evaluated price, volume or margin. In practice it is one of four things: an action and order type that do not go together, such as TRADE_ACTION_DEAL with a pending order type; a missing filling mode on a broker that requires one; closing or modifying on a netting account without the position ticket; or a volume of zero left over from a sizing calculation that fell below the minimum and was never caught. Print the whole MqlTradeRequest immediately before OrderSend and compare it field by field against the documentation for that action — the mismatch is usually visible in one line.
6. Retcode 10030 — unsupported filling mode
The EA hardcoded a fill policy the symbol does not permit. Read SYMBOL_FILLING_MODE at runtime rather than assuming Fill or Kill. Full diagnosis at unsupported filling mode.
7. Retcode 10006 — request rejected
The server refused and gave no further reason. It is the code brokers use for account-level rules: a symbol disabled for the account type, a maximum-orders limit, or a dealing-desk decision. Nothing in the EA produces it and nothing in the EA fixes it. Ask the broker which rule the order tripped, quoting the timestamp from the Journal.
8. Retcode 10004 or 10015 — requote or invalid price
Price moved between the request and the server receiving it. Increasing the deviation tolerance allows the order through at a slightly worse price; leaving it tight means orders fail during exactly the volatile conditions the strategy was built for.
Why this happens
Read it in the right place first. The Journal tab of the Toolbox logs every request the terminal sent and what the server answered, each line timestamped — that is where the retcode lives. The Experts tab logs what the EA itself printed, which may or may not include the code. For a rejected order the Journal entry is authoritative, and comparing the two around the same timestamp usually makes the cause obvious on its own: an Experts error with no Journal line means the EA failed before it ever sent anything.
If the failure is intermittent, make the EA tell you what it sent. A Print() immediately before each OrderSend recording price, volume, stop loss, take profit and the current spread turns a rejection into a diagnosis, because the log then shows the values actually used rather than the ones the code was assumed to produce. Most “random” rejections stop looking random at that point.
Every OrderSend failure carries a retcode, and the code is the whole diagnosis. Troubleshooting without reading it is guesswork, and the Journal tab has been recording it the entire time.
If you are reading the failure from inside the EA rather than the Journal, you will see a different number first. _LastError reports the MQL runtime error, not the server retcode: 4756, TRADE_SEND_FAILED, wraps any server rejection at all, and 4752, TRADE_DISABLED, is the client-side twin of retcode 10027. Neither tells you why. The reason is in MqlTradeResult.retcode, which is the number this page is about — log that field, not the runtime error, or the diagnosis stops one step short.
The codes cluster differently depending on what is wrong. Constant 10016 from the first order onward is a configuration mismatch with the broker. Intermittent 10004 during fast markets is normal execution behaviour. A sudden run of 10019 means the account has quietly run low on free margin.
On gold specifically, the two that dominate are 10016 and 10019 — the stop level and margin. Both are properties of the account rather than of the strategy, which is why the same EA behaves differently across brokers.
Common questions
Where do I find the retcode for a failed order?
The Journal tab of the Toolbox logs every request with its numeric retcode. The Experts tab shows what the EA itself printed, which may or may not include the code. For a rejection the Journal entry is the authoritative one — the full list is at MT5 error codes.
Does OrderSend failed mean my EA is broken?
Usually not. Most retcodes describe a condition the server refused rather than a fault in the code: no free margin, market shut, stops too close. The pattern tells you which. Broken code tends to fail identically from the very first order; a condition tends to fail intermittently.
Related problems
- MT5 error codes: every trade retcode explainedAn order failed and the Journal shows a numeric code like 10016 or 10030.…
- 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.…
- MT5 market closed errorOrders are rejected with "Market closed" during hours you expected to be tradeable.…
- MT5 invalid price error (10015)Orders are rejected with "Invalid price" or error 10015.…
- MT5 unsupported filling mode (error 10030)Orders fail with "Unsupported filling mode" or error 10030, often only on one broker.…
- MT5 server request limitsRequests are throttled or rejected after the EA has been running a while, especially on a prop f…
- Position opened with no stop loss or take profitPositions open successfully but appear in the terminal with no stop loss or take profit.…
Further reading
Educational information only, not financial advice. Trading leveraged products carries substantial risk of loss. Last updated 2026-09-04.