How to Backtest an Expert Advisor in MT5, Step by Step
Short answer: open the Strategy Tester in MetaTrader 5 (Ctrl+R), choose your EA, symbol, timeframe and date range, set the modelling mode (use "Every tick based on real ticks" for final tests), enter a realistic deposit, leverage and execution delay, then press Start. Judge the result on profit factor, maximum equity drawdown, number of trades and history quality — not on net profit alone.
Step 1: Open the Strategy Tester
In MT5, press Ctrl+R or choose View → Strategy Tester. On the Overview tab, choose Single test. The Settings tab is where every decision below lives.
Step 2: Choose the EA, symbol and timeframe
Pick your Expert Advisor from the list, then the exact symbol your broker uses —
XAUUSD, XAUUSDm and GOLD are different histories. The timeframe is the
chart period the EA thinks it is attached to; if your EA checks conditions on a
new H1 bar, test on H1.
Step 3: Set the date range
Use as much history as the strategy's logic deserves, and keep part of it back. Build and tune on, say, 2019–2023; judge on 2024–2026. A result on data you never looked at is worth more than any number of runs on data you tuned against.
Step 4: Pick the modelling mode
| Mode | What it simulates | Use it for |
|---|---|---|
| Every tick based on real ticks | The broker's recorded ticks, where available | Final validation |
| Every tick | Ticks generated from 1-minute bars | Strategies that act inside a bar |
| 1 minute OHLC | Four prices per 1-minute bar | Fast checks of bar-close strategies |
| Open prices only | One price per bar | Very fast screening of strategies that act only at bar open |
| Math calculations | No prices | Optimising pure calculations |
If your EA uses stops, trailing stops or intrabar logic, anything coarser than every tick will misstate the result. We cover the difference in detail in a later post on real versus generated ticks.
Step 5: Deposit, leverage and delays
- Deposit and currency: what you will actually trade with.
- Leverage: your account's real leverage — it changes margin, and therefore which trades can be opened at all.
- Delays: "Zero latency, ideal execution" is a fantasy. A random delay is a fairer test for anything short-term.
Step 6: Set the inputs
On the Inputs tab, set the values you want to test. These are the EA's
input variables — in a TradeSmithy graph, every global parameter node becomes
one, and any indicator period can be wired to one.
Step 7: Run it and read the report
Press Start. The Backtest tab then shows the report. The numbers that matter, in order:
| Metric | What it tells you | Warning sign |
|---|---|---|
| Total trades | Whether the sample means anything | Under ~100 trades |
| Profit factor | Gross profit ÷ gross loss | Below ~1.2 after costs |
| Equity drawdown maximal | The worst peak-to-trough fall, including open trades | Larger than you could sit through |
| Expected payoff | Average result per trade | Smaller than the spread |
| Recovery factor | Net profit ÷ max drawdown | Below ~2 |
| History quality | How much of the test used real data | Well below 100% |
The Graph tab shows balance and equity. A balance line that rises smoothly while equity dips far below it is the fingerprint of a grid or martingale EA holding losers open.
Common backtesting mistakes
- Testing with zero or unrealistically low spread.
- Tuning parameters and judging on the same dates.
- Too few trades to mean anything.
- Ignoring commission on raw-spread accounts.
- Treating a backtest as a forecast. It is evidence about the past; see our honest take on making money with a bot.
Backtest without tying up your own computer
TradeSmithy runs backtests on its own servers. On a Pro project you choose the symbol, timeframe, dates, deposit, leverage, spread (or the symbol's recorded spread) and modelling mode — every tick, 1-minute OHLC or open prices — and queue the run. It keeps going if you close the tab, and returns an equity curve, the full trade list and the tester log, which you can export to Excel.
Start free to build the EA and test it in your own MetaTrader, or go Pro for $19 per 30 days for 50 server backtests a month alongside the AI assistant. New to builders? Start with the EA builder comparison.
Frequently asked questions
How long should I backtest an EA for?
Long enough to include different market conditions and at least a few hundred trades, with a separate period held back for validation.
Which MT5 modelling mode is most accurate?
Every tick based on real ticks, where your broker has recorded tick history for the period.
Why is my MT5 backtest so slow?
Real-tick modelling on long periods processes enormous amounts of data. Screen with 1-minute OHLC, then validate the survivors on real ticks.
Can I trust a backtest?
Trust it as far as its assumptions: costs, data quality, and whether the rules were tuned on the same period. Always forward test on demo.
Keep reading
Why Is My EA Not Trading? A 12-Point MT5 and MT4 Checklist
The EA is attached, the market is moving, and nothing happens. Twelve causes in the order worth checking, with the MT5 and MT4 error codes that name each one.
4 min readWhat Is an Expert Advisor (EA) in Forex Trading?
An Expert Advisor is a program that runs inside MetaTrader and trades by rules. How EAs work, what they can and can't do, and how to get or build one.
4 min readCan You Make Money With a Trading Bot? An Honest Answer
Some bots make money, most bought ones don't, and no backtest guarantees either. What decides the outcome, and the realistic ways people earn from EAs.
5 min read