MT5 Error Codes Explained: 10027, 10030, 10016 & More
Contents
MT5 / MQL5 Error Codes: Retcodes 10004–10031 and Runtime Errors
MT5 reports two kinds of errors: 5-digit trade retcodes (e.g. 10027 AutoTrading disabled, 10030 unsupported filling mode, 10016 invalid stops, 10019 not enough money) and 4-digit runtime errors from GetLastError() (e.g. 4401, 4756) — the table below maps each to its fix.
Quick Lookup: Code → Meaning → Fix
Numbers and constant names follow the official MQL5 reference (trade server return codes and runtime errors).
Trade retcodes (MqlTradeResult.retcode)
| Code | Constant | Meaning | Fix | Details |
|---|---|---|---|---|
| 10004 | TRADE_RETCODE_REQUOTE | Requote — the price moved before execution | Widen the allowed deviation, or resend at the fresh price | Off quotes & requotes |
| 10006 | TRADE_RETCODE_REJECT | Request rejected | Usually a wide spread or fast market; let the EA retry on a later tick | — |
| 10013 | TRADE_RETCODE_INVALID | Invalid request | A field of the request (action, order type, symbol) is wrong; validate it with OrderCheck() before sending | — |
| 10014 | TRADE_RETCODE_INVALID_VOLUME | Invalid volume in the request | Round the lot to the symbol's minimum, maximum and step (SYMBOL_VOLUME_MIN / MAX / STEP) | — |
| 10015 | TRADE_RETCODE_INVALID_PRICE | Invalid price in the request | Normalize the price to the symbol's digits and tick size; make sure a pending order sits on the correct side of the market | — |
| 10016 | TRADE_RETCODE_INVALID_STOPS | Invalid stops in the request | Keep SL/TP farther away than the broker's stops level and on the correct side of the price | Invalid stops |
| 10017 | TRADE_RETCODE_TRADE_DISABLED | Trade is disabled | Check the symbol's trade mode under Specification and that you are logged in with the trading (not investor) password; otherwise ask the broker | — |
| 10018 | TRADE_RETCODE_MARKET_CLOSED | Market is closed | Wait for the symbol's trading session to open | Market closed |
| 10019 | TRADE_RETCODE_NO_MONEY | Not enough money to complete the request | Reduce the lot size, close positions or deposit funds | Not enough money |
| 10021 | TRADE_RETCODE_PRICE_OFF | No quotes to process the request | Check the connection and whether the symbol is currently quoted, then retry | Off quotes & requotes |
| 10026 | TRADE_RETCODE_SERVER_DISABLES_AT | Autotrading disabled by server | The broker blocks algorithmic trading on this account; contact the broker | AutoTrading disabled |
| 10027 | TRADE_RETCODE_CLIENT_DISABLES_AT | Autotrading disabled by client terminal | Turn on the Algo Trading button and allow algo trading in Options and in the EA's properties | AutoTrading disabled |
| 10030 | TRADE_RETCODE_INVALID_FILL | Invalid order filling type | Set type_filling to a mode the symbol supports (FOK / IOC / Return) | Unsupported filling mode |
| 10031 | TRADE_RETCODE_CONNECTION | No connection with the trade server | Check the connection status bar, the VPS network and the broker's server status | — |
Runtime errors (GetLastError())
| Code | Constant | Meaning | Fix | Details |
|---|---|---|---|---|
| 4001 | ERR_INTERNAL_ERROR | Unexpected internal error | Not specific to one cause: call ResetLastError() before the function you are checking, then restart or update the terminal if it persists | — |
| 4401 | ERR_HISTORY_NOT_FOUND | Requested history not found | Call HistorySelect() for a period that contains the deal or order before reading it | — |
| 4752 | ERR_TRADE_DISABLED | Trading by Expert Advisors prohibited | Turn on Algo Trading and tick "Allow Algo Trading" in the EA's properties | AutoTrading disabled |
| 4756 | ERR_TRADE_SEND_FAILED | Trade request sending failed | OrderSend() returned false; read MqlTradeResult.retcode for the real reason (often 10027, 10030 or 10016) | — |
Coming from MT4? MT4 uses different, mostly 3-digit numbers for the same situations (134, 130, 132, 136, 4109 …). Each section below lists the MT4 equivalent, taken from the official MQL4 reference. Note that in MT5 the number 4109 means ERR_CHART_WRONG_PROPERTY (a chart error), not a trading error.
How to Check the Experts Tab
Click the Experts tab at the bottom of MT5 to see a chronological log of all EA activity.
Log format:
2026.05.18 10:00:01.234 GOLD VIPER XAUUSD,M30: [ERROR] 10016
Timestamp EA Name Symbol Timeframe Message
When an error appears, use the code number to find the cause in the table above.
Common Error Codes and How to Fix Them
10019 — Not enough money (TRADE_RETCODE_NO_MONEY)
MT4 equivalent: 134 ERR_NOT_ENOUGH_MONEY. ERR_NO_MONEY is a widely used shorthand for the same situation.
Example messages: "Order failed: not enough money"
"No money"
Cause: Insufficient margin — the EA cannot open a new position.
Fix:
- Check the current margin level in MT5's Trade tab
- If margin is close to or below 100%, consider depositing additional funds
- Lower the EA's
RiskPercentsetting to reduce position size - Manually close some open positions to free up margin
📖 For why it appears even when the balance looks fine, and the MQL5 code that prevents it, see Not enough money in MT5 — causes and fixes.
10027 — AutoTrading disabled by client (TRADE_RETCODE_CLIENT_DISABLES_AT)
Related MT5 runtime error: 4752 ERR_TRADE_DISABLED. MT4 equivalent: 4109 ERR_TRADE_NOT_ALLOWED.
Example messages: "AutoTrading disabled by client"
"Trade is not allowed"
Cause: Automated trading is turned off in MT5.
Fix:
- Click the Algo Trading button in the MT5 toolbar to enable it (it should turn green)
- Go to Tools → Options → Expert Advisors → enable Allow Algo Trading, then restart MT5
This error often occurs when MT5 auto-starts after a VPS reboot.
📖 For the full permission chain (Options settings, per-chart Allow Algo Trading, investor password, and the 10027 vs 10026 difference), see AutoTrading disabled in MT5 — the complete fix.
10018 — Market closed (TRADE_RETCODE_MARKET_CLOSED)
MT4 equivalent: 132 ERR_MARKET_CLOSED.
Example message: "Market closed"
Cause: The EA attempted to enter a trade outside of market hours (weekend or holiday).
Fix: No action needed. The market is closed over the weekend, and any entry attempt during that window produces this error; the EA resumes automatically when the market reopens.
📖 Seeing it on weekdays? Symbol trading sessions, server time, and close-only mode are covered in Market closed (10018/132) — causes and fixes.
10016 — Invalid stops (TRADE_RETCODE_INVALID_STOPS)
MT4 equivalent: 130 ERR_INVALID_STOPS.
Example message: "Invalid stops"
Cause: The SL (stop loss) or TP (take profit) value violates the broker's minimum stop level requirement.
Fix:
- Check the broker's stop level (minimum SL distance): right-click the symbol in MT5 → Specification → look for the Stops level field
- Ensure the EA's SL distance is greater than the stop level
- This error is most common during low-volatility periods when ATR values are very small
📖 For how stop levels actually work, the 10016 vs 130 difference, and the MQL5 code that prevents it for good, see Invalid stops (10016/130) — the complete fix.
10021 — No quotes (TRADE_RETCODE_PRICE_OFF)
MT4 equivalent: 136 ERR_OFF_QUOTES.
Example message: "Off quotes"
Cause: No price quote received from the broker server — a connectivity issue.
Fix:
- Check the connection status in MT5's status bar at the bottom of the screen
- If disconnected, restart MT5
- Check your broker's server status page for outages
- Verify the network connection on your VPS
📖 For the difference vs requotes (10004/138), deviation tuning, and a retry implementation, see Off quotes & requotes (10021/10004) — the complete fix.
📖 Getting Unsupported filling mode (10030) right after switching brokers? That's a different problem — see Unsupported filling mode (10030) — how to fix it.
10012 — Request timed out (TRADE_RETCODE_TIMEOUT)
MT4 equivalent: 128 ERR_TRADE_TIMEOUT.
Example message: "Request canceled by timeout"
Cause: The order timed out due to server congestion or network latency.
Fix:
- This is most common immediately after major news releases when server load is high
- The EA will typically retry on the next tick — no action required
- If this happens frequently, review your VPS network environment or consider a different broker
10006 — Request rejected (TRADE_RETCODE_REJECT)
Example message: "Request rejected"
Cause: The broker rejected the order — typically due to spread exceeding limits or price moving too fast.
Fix:
- Review the
MaxSpreadPointssetting; this error is common when spreads widen significantly - During and immediately after news releases, this is expected behavior — you can ignore it
- If it occurs frequently, slightly increase the
MaxSpreadPointsvalue
"Margin level too low"
Example message: "Margin level too low. Skip signal."
Cause: The EA's UseMarginCheck = true setting detected that margin level has dropped below MinMarginLevel (e.g. 200%), so new entries are automatically blocked.
Fix:
- This is normal protective behavior — it is not an error
- Entry will resume automatically once the margin level recovers
- Root fix: deposit more funds or lower
RiskPercent
"No signal on this bar" or "Wait for next bar"
These are not errors — they are debug log entries.
"No signal. ATR=1245, EMA(50)=1998.23"
The EA evaluates the chart on every bar and logs when entry conditions are not met. This is normal operation.
Error Priority Classification
| Priority | Error | Action |
|---|---|---|
| Critical | 10019 Not enough money (MT4: 134) | Deposit funds or reduce lot size immediately |
| Critical | 10027 AutoTrading disabled / 4752 (MT4: 4109) | Enable Algo Trading |
| Warning | 10016 Invalid stops (MT4: 130) | Review SL settings |
| Warning | 10030 Invalid filling type | Set a filling mode the symbol supports |
| Warning | 10021 No quotes (MT4: 136) recurring | Check connectivity |
| Normal | 10018 Market closed (MT4: 132) weekends only | No action needed |
| Normal | 10012 Timeout (MT4: 128) occasional | No action needed |
| Normal | Margin level too low | Normal protection at low margin |
How to Read the Experts Tab Efficiently
Filtering Logs
Right-click inside the Experts tab and select Filter to display logs for a specific EA or error type only.
Log File Location
MT5 log files are saved here:
C:\Users\[YourUsername]\AppData\Roaming\MetaQuotes\Terminal\[ID]\MQL5\Logs\
Files are created automatically by date. Open this folder when investigating errors.
Summary
Most EA errors fall into four categories:
- Insufficient margin (10019) — Deposit more funds or reduce lot size
- AutoTrading off (10027 / 4752) — Click the Algo Trading button to enable it
- Connection issues (10021 / 10031) — Restart MT5 or check VPS network
- Normal behavior — No action needed (weekend market close, spread-avoidance, etc.)
Make it a habit to check the Experts tab daily so you can quickly catch critical errors (10019 and 10027) before they cause problems.
FAQ
Q: Where can I look up error codes?
The official MQL5 reference lists every code: trade server return codes for the 10004–10046 range and runtime errors for the 4xxx range. You can also search from MT5's built-in help (press F1).
Q: What is the difference between a retcode and GetLastError()?
A retcode (10004–10046) is the trade server's answer to an order and is stored in MqlTradeResult.retcode. GetLastError() returns a runtime error of the MQL5 program itself (4xxx and 5xxx). When OrderSend() fails you often get both: 4756 from GetLastError() plus a retcode that tells you the actual reason.
Q: Should I stop the EA if errors are appearing frequently?
If 10018 (market closed) or 10012 (timeout) appear occasionally, there is no need to stop the EA. However, if 10019 (not enough money) repeats, pause the EA, review your margin situation, and restart once resolved.
Q: I'm seeing an "Invalid account" error.
Your MT5 login credentials (server name, login ID, or password) may be incorrect. Go to File → Open an Account to log in again.
Q: No errors are showing, but the EA isn't entering any trades.
If there are no errors and no entries, the EA is simply waiting for its entry conditions to be met — this is perfectly normal. EAs do not enter on every candle; they enter only when all conditions align. Give it some time. An H1 EA entering one to three times per day is operating normally.
Related
📧 Free 8-email course + subscriber-only pack of 13 MT5 indicators
Right after you sign up, you get a download link for a subscriber-only pack of our 13 MT5 indicators: compiled files (.ex5), source code and a setup guide. Then 8 emails on algo-trading essentials, reading backtests correctly and choosing a broker (one a day for the first 5 days, then 7, 14 and 30 days after signing up). You also get notified before each price rise of the versions sold on the MQL5 Market (launch pricing that steps up as copies sell). Our EAs are free on this site with a live account at a partner broker.
* Privacy strictly protected. You can unsubscribe at any time.
Have a question about EAs or FX?
You can post it on the Nattzy trading forum (free sign-up). Questions beyond this article are welcome too — EA settings, choosing a broker and more.
Ask on Nattzy ↗