作者: William Harris · 最后审核
Why Is My EA Not Trading in MT5? (Diagnostic Flowchart)
您需要准备
- • MT5 with the affected EA attached
- • MT5 → View → Toolbox to see Experts and Journal tabs
分步说明
第 1 步:Check the smiley face on the chart
The chart's top-right corner shows the EA name and a small smiley face. Three states:
• Green smiley — EA running, trading allowed. If you're here and no trades happen, skip to step 3.
• Red sad face — EA loaded but trading disabled. Hover over the EA name to see the reason. Common reasons: - 'Trading not allowed in EA properties' — open EA Properties → Common tab → tick 'Allow live trading'. - 'AutoTrading button disabled' — click the AutoTrading button in the toolbar so it turns green. - 'No connection' — broker connection dropped; check status bar. - 'Account is in read-only mode' — you logged in with the investor password; switch to master.
• No icon — EA not loaded. Re-drag from Navigator or check if it was removed.
The smiley is your single best first-pass diagnostic. 80% of 'EA not trading' issues resolve at this step.
第 2 步:Read the Experts tab
View → Toolbox (Ctrl+T) → Experts tab shows every message printed by every EA, time-stamped, scrollable. This is your second-best diagnostic.
What to look for: • 'EAName,EURUSD M5: initialised' — EA loaded successfully. Good sign. • 'EAName,EURUSD M5: OnInit error code XYZ' — EA failed to initialise. Look up the error code in the MQL5 documentation or vendor docs. Common: code 4001 (No connection), 130 (Invalid stops), 4109 (Trading not allowed). • Messages like 'Waiting for first signal' or 'Outside trading window' — EA is healthy but intentionally not trading right now. • Repeated 'Insufficient margin' or 'Off quotes' — broker-side rejection; see step 5. • Absolutely silent for hours — likely the EA's OnTick isn't being called (no ticks arriving) or the EA is mute by design. Check the broker connection.
Filter the log by your EA's chart in the dropdown at the top. The combined log across all EAs can be overwhelming with multiple EAs running.
第 3 步:Check if the EA is signalling but doing nothing
If the smiley is green and the Experts log shows 'EA initialised' but no trades for hours, the EA is alive but not generating buy/sell signals. Likely reasons:
• Trading session filter — many EAs restrict trading to specific hours (e.g. London-only 8am-5pm UTC). Outside the window, no signals. Check the EA's Inputs tab for parameters named 'StartHour', 'EndHour', 'TradingSession'.
• Day-of-week filter — some EAs avoid Mondays (low volume) or Fridays (weekend gap risk). Check 'TradeMonday/Friday' inputs.
• Volatility filter — EAs that require minimum ATR or minimum momentum sit out low-volatility periods. Common in summer (June-August) when major-pair volatility drops 30-50%.
• News filter — many EAs avoid trading 30-60 minutes around high-impact news. If you're in a quiet news week the EA may trade fine; in a busy news week it may sit out most sessions.
• Account-condition filter — EAs sometimes refuse to trade if account leverage is too low, equity below a threshold, or broker is non-ECN. Check Inputs for 'MinLeverage', 'MinEquity', 'EcnMode'.
If the EA has a 'verbose' or 'debug' input, enable it temporarily. The log will print the actual filter decisions ('Signal blocked: ATR below threshold' etc).
第 4 步:Check the Journal tab for broker rejections
If the EA tries to send orders but they don't appear in your positions, the broker is rejecting them. The Journal tab (View → Toolbox → Journal) logs every broker interaction including rejected orders.
Common broker-side errors:
• 'Trade context is busy' — MT5 is already processing another order. Usually transient; the EA retries automatically.
• 'Off quotes' — the price you tried to trade at is no longer available. Common during fast moves and news. Increase the EA's Slippage parameter or use market orders instead of limits.
• 'Invalid stops' — the stop loss or take profit is too close to the current price. Broker has a minimum stop distance (usually 5-30 points depending on symbol). Check Symbol Specification → 'Stops Level' and adjust EA inputs accordingly.
• 'Insufficient margin' — your account equity doesn't support the requested position size. Either reduce lot size or close other positions first.
• 'Market is closed' — you tried to trade outside market hours. The EA should have checked this; if it didn't, the EA is buggy.
• 'Trade is disabled' — broker-side restriction on this account/symbol. Contact broker support.
第 5 步:Verify global AutoTrading is enabled
Two levels of AutoTrading must be on for an EA to trade:
1. Global — the AutoTrading button in the main toolbar (small triangle icon). Click it once to toggle. Green means enabled.
2. Per-EA — the 'Allow live trading' checkbox in the EA's Common tab.
If the global toolbar button is red/orange but the per-chart smiley is green, no trades happen — global trumps per-chart. The status of global AutoTrading is also visible in the bottom-right corner of MT5.
Global AutoTrading can auto-disable in these scenarios: • Account change — by default, switching accounts disables global trading as a safety guard. Re-enable manually. • Terminal restart — global state usually persists, but on Windows update reboots it sometimes resets. • Crash recovery — after a crash, MT5 may launch with global trading off. Check after every restart.
A simple production rule: on every MT5 restart, manually verify both the global toolbar button and each EA's smiley before walking away. Takes 30 seconds, catches the most common 'EA stopped trading overnight' scenario.
第 6 步:Check for symbol naming mismatches
An EA hard-coded to trade EURUSD will silently exit OnInit if attached to a chart of a symbol your broker calls 'EURUSD.m' or 'EUR/USD'. The EA reads Symbol() in OnInit, compares to its expected name, and refuses to load if they differ.
Symptoms: the EA's first log message is something like 'Wrong symbol — EA expects EURUSD, chart is EUR/USD' followed by silence. Sometimes the EA is silent entirely if the vendor didn't add the diagnostic log line.
Fix: • Confirm the actual symbol name in MT5's Market Watch. • Check the EA's documentation for the expected symbol name. • If they differ, look for an EA input like 'SymbolOverride' or 'TradeSymbol' that lets you specify. Set it to your broker's actual name. • If no override exists, contact the vendor — most can patch the symbol check in a build update.
Broker-specific symbol naming gotchas: • XAUUSD vs GOLD vs XAU/USD vs XAUUSD.m • EURUSD vs EURUSD.m vs EURUSDi (i = institutional) • BTCUSD vs BTC/USD vs BTCUSD.cw (CryptoFX vs FX/CFD)
Always verify before deploying.
需要避免的常见错误
- ✗ Forgetting global AutoTrading after a restart解决方法: After every MT5 restart, check the orange/green toolbar button before walking away.
- ✗ Logged in with investor password by mistake解决方法: Investor mode is read-only. The EA cannot place orders. Re-log with master password.
- ✗ Assuming silence = EA not signalling解决方法: Enable the EA's Verbose/Debug input. The log will explain WHY the EA isn't trading (e.g. 'outside session', 'low volatility').
- ✗ Ignoring repeated 'Insufficient margin' errors解决方法: Your lot size is too large for current equity. Reduce risk percent or close other positions.
- ✗ Wrong symbol name — EA hard-coded for EURUSD but chart is EURUSD.m解决方法: Use the EA's SymbolOverride input or contact vendor for a patched build.
- ✗ Stop level below broker minimum解决方法: Check Symbol Specification → Stops Level. Set EA's StopLoss to at least that distance.
常见问题
My EA was trading fine yesterday but stopped overnight. What happened?
The diagnostic procedure: open the chart, look at the timestamp of the last journal entry — that's when the EA last received a tick. Hours of silence usually means terminal restart or broker disconnect. Minutes of silence may just mean low-volatility market. The EA's own Verbose log usually says 'self-paused due to limit hit' or similar if that's the cause.
What do the common MQL5 error codes mean?
Errors map to root causes: 130-138 series are trade-context issues (broker rejected the order, retry with adjusted parameters), 4000 series are platform-level issues (connection, permissions), 5000+ series are file/network errors. Most retail EAs handle 130/138 with automatic retry; if you're seeing these in your log without traders complaining, the EA is handling them correctly.
Why does my EA stop trading every Friday afternoon?
Weekend gap risk is real — Sunday-open price can be 100+ pips away from Friday-close price after major news. EAs that hold positions through the weekend can wake up Monday morning at a stop-out loss they couldn't possibly have prevented. The standard mitigation is to close all positions and disable new trades 30-60 minutes before Friday close. Most reputable EAs include this filter; some let you turn it off if you want to take the gap risk.
My EA gets 'Trade context busy' errors during news. How do I fix it?
The single trade context per terminal is an MT5 architectural choice that prevents race conditions. The fix is to either reduce concurrent EA trade requests (stagger EAs) or scale horizontally (one EA per terminal). Most EAs retry 'context busy' automatically; if yours doesn't, the vendor needs to add it. During news the spread also widens so retries usually fill at a worse price — known trade-off.
My EA trades fine in demo but not in live. Why?
Cause (2) is more common than you'd think — vendor anti-piracy systems sometimes check AccountInfoInteger(ACCOUNT_TRADE_MODE) and refuse to trade unless the account is licensed. Check the vendor's licensing portal that you've added your live account to the binding list. If yes, capture the EA's exact log output on both demo and live and email the vendor with both — they can usually diagnose from the log diff in <24 hours.
After a margin call, can I just restart the EA and continue?
Margin calls happen when total open position margin requirement exceeds equity. Causes: (1) lot size too large per trade, (2) too many simultaneous positions (multi-symbol, grid, martingale), (3) leverage reduction by the broker (some brokers cut leverage during news from 1:30 to 1:5, instantly margin-calling positions sized for 1:30). After margin call: review per-trade risk %, set a portfolio-level max-position-count, and consider account-level daily-loss-limit script as a safety net.
Resolved the issue?
Export your account statement to share with broker support or attach to a vendor ticket. Five minutes, two clicks.
Continue to: How to export an MT5 trading report →