TROUBLESHOOTING · UPDATED NOVEMBER 2026

MT5 Error Codes: What They Mean and How to Fix Them

Retcodes 10016, 10014, 10019 and 10021 (the old 130, 131, 134 and 136 of MT4), "Market Buy Error", "Trade Context Busy". Each one has a concrete cause and a concrete fix. What they actually mean, why automated orders hit them more than manual trading, and a 30-second diagnostic at the end.

Short answer

An MT5 error code is the terminal's retcode for a rejected action, and it points at one of three layers: the terminal (wrong login or server), the order itself (invalid stops, volume, margin) or the broker (market closed, trade disabled). The number narrows it down in seconds.

BBenjamin SF · Founder Published Oct 13, 2026 Read 9 min Updated 2026-11-22

Jump to: Where the error comes from · The codes you will actually see · "Market Buy Error" (retracement) · 10016 (invalid stops) · Trade context busy and the double-instance pattern · 30-second diagnostic

01

Where the error comes from: terminal or broker

Two layers report a failed order. When the trade server rejects a request, MT5 returns a retcode in the 10000 range: 10016 invalid stops, 10014 invalid volume, 10019 not enough money, 10021 no quotes, 10018 market closed, 10017 trade disabled. When the EA call itself fails, MQL5 raises a runtime error in the 4000 range, such as 4756 (trade request sending failed). The numbers 130, 131, 134 and 136 are the MT4 codes for the same situations; you meet them in MT4 guides and in EAs ported from MT4, not as MT5 retcodes. Some causes are configuration on your side (stops, volume, AutoTrading); others, such as trade disabled or market closed, are set by the broker.

An automated setup (EA, bridge, alert-driven execution) hits these in volume because it never waits for you to notice. A manual trader gets one ugly message a week; an automated account gets ten a day. That is why reading the code matters more here than anywhere else in MT5.

02

The codes you will actually see

Most order failures in automated accounts fall into a handful of retcodes. Here is what each one means and the fix that works:

Dedicated guides: error 4756, trade request failed, 4109, trade disabled, “No connection”, invalid price and off quotes (10015/10021), “failed to get list of signals” and Position Sizer errors.

10016: Invalid stops (MT4: 130)
SL or TP closer to price than your broker's Stop Level allows, or a spread spike moved the effective stop to the wrong side. Fix: keep stops at or above the broker minimum; with auto-breakeven, keep the trigger far enough from entry. Full section below.
10014: Invalid volume (MT4: 131)
The lot is below the symbol minimum, above its maximum or not a multiple of its volume step. Fix: round the lot to the symbol step and keep it between minimum and maximum; the contract specification in Market Watch lists all three.
10019: Not enough money (MT4: 134)
Free margin does not cover the order. Fix: reduce the lot, close exposure or check leverage. In automation the usual culprit is a risk percentage computed on balance while free margin is already tied up in open positions.
10021: No quotes (MT4: 136, off quotes)
The server has no price to process the request, typically at the session open, during a feed gap or on a symbol that is not quoting. Fix: wait for quotes and retry; the invalid price and off quotes guide covers it in detail.
10004: Requote (MT4: 138)
The price moved between the request and the execution. Fix: a well-built EA retries once after a requote. Persistent requotes at news are an entry-timing problem, not an MT5 problem.
10031: No connection
No connection with the trade server (server list outdated, or the terminal never logged in). Fix: verify the terminal is online and connected to the right server; on cloud terminals, a full reboot usually clears a stale server list.

Also worth knowing: 10017 (trade disabled) and 10018 (market closed) come from the broker side, so check the symbol trading hours and ask the broker whether the symbol is enabled for your account type. 10027 means AutoTrading is switched off in the terminal itself.

03

"Market Buy Error" (retracement): why your buy failed

The classic message of a rejected market order. The broker tried to fill your buy and the market moved enough that the fill would be worse than your order's tolerance. Four causes, in order of frequency:

1. Spread widened at the moment of entry. A news release can multiply the spread several times in one second; a market order sized for a normal spread gets rejected. The fix that actually works for automated trading is a short blackout around high-impact news, not a wider tolerance.

2. Stops below the broker's Stop Level. If the SL/TP distance is under the minimum, the broker rejects the whole order, not just the stops. Check the Stop Level for your symbol in Market Watch before assuming a bug.

3. Symbol filter of your account type. Some account types (swap-free, cent, region-limited) do not accept all symbols or order types. "Invalid account" on one symbol but not another is the fingerprint.

4. Weekend or holiday freeze. Markets close Friday; pending orders resting over the weekend can fail on the Monday gap. Keep no open-risk logic that assumes the market is always reachable.

04

Retcode 10016: the stop is too close (and the breakeven trap)

Invalid stops is the most common failure in automation because spreads are a moving target: what was a 12-point stop at 10:00 is a 6-point stop at the news print. Three situations produce it in practice:

The SL/TP was always under the broker minimum. Easy: measure it once, set your template above the Stop Level with margin for spread, and never below it.

Auto-breakeven moving the stop into the spread. This is the subtler one. When a breakeven trigger fires with the spread wider than usual, the new stop can land on the other side of the price and the broker rejects the modify. If your account shows random 10016 rejections right after a breakeven event, that is the cause: cap the breakeven offset relative to the current spread instead of using a fixed point value.

Partial close + re-modify race. Closing part of a position and re-modifying the remainder in the same tick can collide with the broker's order-book state. Retrying the modify once, a few seconds later, is the standard cure.

The same discipline applies to your risk layer: see the MT5 risk management checklist for keeping stops and lot sizing inside the broker's rules.

05

Trade context busy and the double-instance pattern

"Trade context busy" is an MT4 error (146): the terminal was still handling another request. MT5 has no such retcode; when requests arrive too fast it returns 10024 (too frequent requests). Either way, a retry a few seconds later goes through, and a well-behaved execution layer expects this and retries.

The version that does not go away has one specific cause, and it is more common than you'd think: two terminals running the same account. An EA on your local machine plus an EA on a cloud terminal, both attached to the same broker account, take turns holding the trade context. The symptoms are rejections in bursts and duplicated positions when both sides try to open or close at the same moment.

The fix is not software: one account, one terminal, one EA. Close or log out the second terminal, and if positions were left duplicated, close the extras manually before re-enabling automation. A related quiet culprit: closing the chart window can silently detach an EA, if your signals stopped being executed but the terminal shows no error at all, check that the EA is still attached to a live chart.

06

Diagnose any MT5 error in 30 seconds

1. Open the History tab. Every rejected order is listed with its code in the reason column. That number, not the popup, is your diagnosis. Match it against section 02.

2. Check the Journal tab. Connection events, server renames and reconnections are logged there, not in History. If the Journal says "reconnecting" in a loop, the terminal lost the server, it is not your strategy.

3. If you run SignalForge: read /execution. Every signal shows its exact outcome and the broker's rejection code, so you skip the terminal entirely: which signal failed, which code, at what time. That is the fastest way to separate "my alert is wrong" from "the broker said no".

4. Decide whose problem it is. Invalid stops, volume or margin (10016, 10014, 10019) and AutoTrading off (10027): your configuration. Trade disabled (10017), market closed (10018) or "invalid account": the broker's. Send them the exact code and timestamp, support teams move twice as fast with a code than with "my trades don't open".

Setting everything up from scratch? Start with the TradingView to MT5 connection guide, which includes the demo-test step that catches most of these before they cost you a real fill.

Frequently asked questions

What does "Market Buy Error" mean in MT5?

The broker rejected the buy order at execution time, usually because the spread widened beyond the broker's stop level (often at news), or the stop/TP distance was below the broker minimum. Check the spread before entry, keep stops at or above Stop Level, and avoid entering on high-impact news.

What does MT5 retcode 10016 (Invalid stops) mean?

Your stop loss or take profit is closer to the current price than your broker's Stop Level allows, or a spread spike moved the effective stop to the wrong side. Increase the stop distance or move the level outside the broker minimum. In MT4 the same error is 130.

Why does my EA fail to open trades during news?

During high-impact news the spread widens several times and fills slip, so the broker rejects the order (retracement, re-quote, invalid stops). A news filter or a short blackout around scheduled events is the standard fix for automated setups.

Is "Trade context busy" a bug in my EA?

Usually no. It is an MT4 error (146): the terminal was still handling another request when yours arrived, and it clears once the terminal settles. MT5 reports requests that come too fast as 10024. If rejections persist, check that two terminals or two EA instances are not running on the same account.

Can SignalForge AI fix MT5 order errors automatically?

It retries transient rejections with a short backoff, records the exact error code for every signal and shows it in the /execution panel, so you can diagnose without reading terminal logs. Rejections that come from the broker (invalid account, trade disabled) must be fixed on the broker side.

Why does MT5 keep saying invalid account?

The login does not exist on the server you selected. The usual causes, in order: a demo login on a live server (or the reverse), the client-area password instead of the MT5 trading password, and an account the broker archived. Check the server before you reset the password.

Why is MT5 saying authorization failed?

Authorization failed means the server answered but rejected the credentials or the account state. Typical causes: the password was changed in the client area, the demo expired, a prop account is in breach, or KYC is pending. The journal line names the server, which is the fastest way to confirm you are on the right one.

Written by Benjamin SF, founder of SignalForge. Error codes and behaviour described here come from live operation of automated MT5 accounts across multiple brokers; MetaQuotes' official error list is the final reference for each code.

Stop guessing, start diagnosing

Every rejected signal, with its exact broker code, in one place. Test the whole pipeline on demo with the free 14-day trial.

Start the free trial Read the docs

SignalForge AI is an order-execution tool. Error behaviour depends on your broker's rules and your configuration; past behaviour does not guarantee future results. Trading involves substantial risk of loss.