Hello, automation — how Expert Advisors really work
What a bot does, what a backtest is, and the single most-important reason a clean backtest still loses money live.
Last reviewed:
Automation in 90 seconds
An EA is code that places trades by rules. A backtest replays history against the rules. A clean backtest is the *floor* of live performance, never the ceiling — usually the gap is large.
- EA = Expert Advisor = MT5 program in MQL5 that runs on a chart, reads price, places orders by rules. Same OrderSend, same SL/TP semantics from Lesson 4.
- Strategy Tester = built-in MT5 tool that replays historical ticks against an EA. Produces equity curve, profit factor, max drawdown, win rate, total trades.
- Backtests systematically overstate live performance. Four big reasons: realistic spread (usually wider than tester models), slippage (especially during news), commission (often omitted by default), execution latency (microseconds matter at scale).
- Walk-forward analysis = backtest on years 1-3, test on year 4, repeat sliding. Survives overfitting that single-window backtests don't catch.
- Honest evaluation = backtest + walk-forward + small-live shadow trade. Skip any step and you're running a hope, not an algorithm.
The honest evaluation framework matters even more in the era of EA-friendly prop firms:
The largest prop firm at the time was alleged to be running an internal-only trading book; reshaped how the prop scene is regulated.
SourceBacktest vs live — watch the gap widen
Same EA on the same data. The clean backtest shows one equity curve; the 'live' curve is what happens when you add real-world frictions back in. Toggle each friction and see the gap grow.
These are illustrative magnitudes, not real backtest output. Actual divergence varies by strategy and broker. The point is: there is always a gap, and a good evaluation discipline measures it before deploying capital.
How EAs and backtests actually work
What an EA actually is
Strip away the marketing. An Expert Advisor is just a small program — typically 200-2000 lines of MQL5 (or compiled to a .ex5 binary) — that MT5 runs on a chart. It reads incoming ticks via event callbacks (OnTick), checks its own rules, and calls OrderSend() when conditions match. The SL/TP attached are the same SL/TP from Lesson 4. The only difference from a manual trader is that the EA does it without coffee, sleep, or impatience.
EAs come in three flavours: trend-followers (moving-average crossovers, breakout strategies); mean-reversion (grid trading, range fade, RSI-based); hybrid / portfolio (combine signals from multiple sub-strategies). The L8 strategy families translate directly. An EA isn't a magic edge — it's a codified version of a manual strategy, executed without emotion.
What an EA isn't: a way to bypass needing a strategy. The 'I bought a bot from Telegram and it will print money' fantasy is what made this market a marketing-driven mess. The EA only outputs what the rules in it produce; bad rules = bad output.
Backtesting — replaying the past, honestly
Backtest = replay historical tick data through an EA's rules, watch the equity curve. MT5's Strategy Tester does this in seconds for years of data on majors.
The tester reports: total net profit, profit factor (gross profit / gross loss; > 1.3 healthy, > 2 great), maximum drawdown (peak-to-trough %, < 20 % survivable), Sharpe ratio (risk-adjusted return), win rate, total trades. A reasonable retail trend-following EA on EURUSD H1 might show: 3-year backtest, +35 % net, profit factor 1.4, max DD 15 %, win rate 40 %, 850 trades. That's a credible-looking result. Now we have to ask the harder question: does it survive contact with reality?
Three checks that turn a backtest into a meaningful signal: (1) realistic spread / commission — set the tester to use 'every tick' mode with real broker spread settings, not 'control points' or default spread; (2) walk-forward — backtest 2019-2022, test 2023 forward; if results crater, the strategy was overfit; (3) out-of-sample test — backtest excludes the last 6 months; check those 6 months live or in tester separately. Any EA that passes all three is genuinely worth shadow-trading on demo.
Why a clean backtest overstates live — the four frictions
Four mechanisms erode live performance vs an idealised backtest:
Spread variation: MT5's default Strategy Tester uses a constant spread (often the current value). Real spreads widen during news, weekends, and Asian-session-only hours. An EA that places 30 trades a week pays roughly 20-50 % more in spread costs live than in default tester.
Slippage: MT5 Strategy Tester assumes you fill at exactly the price requested. Live, your buy fills a tick or two worse than the displayed ask on average — and during news, sometimes 5-30 pips worse. SL slippage is the same in reverse. For high-frequency or low-edge strategies, slippage is the biggest single live-vs-backtest gap.
Commission: Many EA backtests omit commission entirely. If your broker charges $7 per round-trip per 1.00 lot (typical ECN), every trade costs ~$0.07 on a 0.01 lot — small per trade, meaningful at 1000 trades/year.
Execution latency: Tester executes instantly when conditions match. Live, your order travels client → broker → upstream → fill confirmation in 50-300 ms. For slow strategies (hourly entries) it doesn't matter; for fast ones (sub-minute) it can flip the sign of expectancy.
Walk-forward — the test that catches overfitting
Most backtest blowups aren't about frictions. They're about overfitting — tuning a strategy to look great on historical data it has already seen, only to find it fails on data it hasn't.
The remedy is walk-forward analysis. You divide your data into 'in-sample' (training) and 'out-of-sample' (test) windows. Train the strategy on years 1-3, freeze it, test on year 4. Slide the window: train 2-4, test 5. Repeat. If the out-of-sample windows look meaningfully worse than the in-sample ones, your strategy was overfit; the historical performance won't translate forward. If the out-of-sample windows look similar to in-sample, the strategy has genuine structural edge.
MT5's Strategy Tester supports walk-forward via the 'forward period' setting in optimisation. Set forward % to 30-50 %; run optimisation. The tester reports both in-sample and out-of-sample stats. The gap between them is your overfitting tax.
Key terms
Why EA evaluation matters more than ever — the 2023 prop-firm reset
The 2023 prop-firm reset reshaped the world EAs operate in — and made honest evaluation more important than ever.
The largest prop firm at the time was alleged to be running an internal-only trading book; reshaped how the prop scene is regulated.
Before August 2023, the prop-firm ecosystem was awash in 'pass the evaluation with this EA' marketing. The MyForexFunds enforcement (~135,000 customers, $310 M in evaluation fees, alleged simulated-book practices) reshaped the segment. Surviving firms (FTMO, FundedNext, FundingPips, The Funded Trader) tightened risk models and disclosure. The EA-evaluation marketing pivoted from 'this bot passes any prop challenge' to more honest framings around per-firm risk rules. For a serious retail trader, the practical lesson is unchanged: any EA you consider — whether for a personal account or for prop evaluations — gets evaluated with the three-check protocol (realistic backtest + walk-forward + small-live shadow) before any meaningful capital touches it. The shortcut culture that 2023 broke wasn't actually a shortcut — it was a marketing layer that bypassed the work, and the work caught up.
SourcePractice — run the Strategy Tester yourself
10-minute practice — run the Strategy Tester yourself
MT5 ships with several free sample EAs. We'll backtest one in three real configurations and see how the numbers change.
- 1
Open MT5 → View → Strategy Tester (Ctrl+R). It opens a tester pane at the bottom.
- 2
Expert pulldown → choose a sample EA (e.g. 'MACD Sample' which ships with MT5). Symbol: EURUSD. Period: H1. Date range: last 12 months.
- 3
Modelling: select 'Every tick based on real ticks' if available (most accurate). Otherwise 'Every tick'. Click Start. Wait ~30 seconds.
- 4
Look at the Results tab: profit factor, max drawdown, win rate, total trades. Note the equity curve graph in the Graph tab. This is the 'clean backtest' baseline.
- 5
Now: Settings → Spread → set to a realistic value (try 15 points for EURUSD = 1.5 pips). Re-run. Compare. The numbers should be visibly worse — that's friction at work, and that's only spread. Add commission in your head (~$7/round-trip per 1.00 lot scaled to your lot size).
Mastery check
Six questions on EAs, backtesting, and honest evaluation. Pass at 5 of 6.
Hello, automation — quick check
Test your understanding with 6 questions. Pass with 5/6 correct.
Reflect
Reflection
Type your honest answers — saved on this device only. Use them next week to spot patterns in your trading thinking.
Pro deep dive — under the tester
If you came in already familiar with backtesting, here's the structural detail you need to evaluate other people's EAs (or build your own honestly).
Tick modelling — what 'every tick' actually means
MT5's Strategy Tester offers three modelling modes: 'Open prices only' (extremely fast, useful only for daily/weekly strategies), 'Every tick' (interpolated from M1 OHLC), and 'Every tick based on real ticks' (uses actual tick history from your broker). The third is the gold standard but requires downloading tick history. Many EAs that 'pass' the cheaper modes fail the real-tick mode because intra-bar price action interacts with SL/TP differently. Always test in real-tick mode before considering live deployment.
Modelling slippage explicitly
MT5's default tester doesn't model slippage at all — your fills are at requested price. For a realistic test, you need either MT5's newer 'random slippage' option (limited control), a custom EA that simulates slippage by adjusting fill prices in OnTick, or external backtest tools (e.g. Python with MetaTrader5 module + realistic execution simulation). Pro retail traders typically build a small custom slippage model that adds 0.5-2 pips of execution friction on every trade in the tester. The PF drops; the resulting number is closer to reality.
Out-of-sample windows and the multiplicity problem
A single walk-forward window catches obvious overfitting. Multiple-strategy testing requires more discipline because of the multiplicity problem: if you backtest 100 parameter combinations, 5-10 will look great on any historical window by chance alone. The defence is to use a Bonferroni-style correction on your significance thresholds — if you tested 100 combinations, require profit factor > 1.6 instead of 1.3 to consider any one of them significant. Most retail EA sellers don't apply this correction (they show you the best of 100 parameter combinations as if it were the result of an unbiased single test). When evaluating an EA, ask: 'how many parameter combinations were tested before this one was selected as the published result?' If the answer is unknown or large, the published statistics are inflated.
Live shadow trading — the third check
Even with realistic-friction backtest + walk-forward, EAs can still fail live for broker-specific reasons: different commission structure, different spread profile during your timezone, different order-rejection rates, different swap calculations. The third check is shadow trading on a demo account at your actual broker for at least 30 days (preferably 90) and comparing the live-tester run to the backtest expectation. If the gap is more than 30 % (e.g. backtest +20 %, shadow +13 %), investigate before live deploying.
Bibliography
Show answer
An Expert Advisor (EA) is an MQL5 program that runs inside MT5, watches the market, and places orders automatically by rules someone wrote. It uses the same OrderSend, SLs, and TPs as a manual trader — just executed by code, not by hand. Before any EA touches live capital, three checks are non-negotiable: (1) a realistic-friction backtest using 'every tick from real ticks' with your broker's actual spread plus commission and a slippage model; (2) walk-forward analysis splitting data into training and test windows, with out-of-sample stats close to in-sample (the defence against overfitting); (3) shadow trading on a demo account at your live broker for at least 30 days, tracking the live-vs-backtest gap. Any EA that passes all three is worth deploying with the smallest possible position size while monitoring continues. Any EA that fails any step gets moved on from — there will be others.
Educational material only — not investment advice. Trading carries risk of capital loss. Always practice on demo and use a stop-loss. ← Back to Forex Basics