MT5 Strategy Tester: How to Backtest an EA in MetaTrader 5
Short answer: open the Strategy Tester with Ctrl+R, pick your Expert Advisor, the symbol, the timeframe and the dates, choose a tick mode, set the deposit, leverage and an execution delay, and click Start. For an EA with tight stops or one that acts inside a bar, test on "Every tick based on real ticks"; "1 minute OHLC" is for fast passes and "Open prices only" only for EAs that act once per new bar. Then read the report in this order: history quality and trade count, equity drawdown and losing streaks, and only then profit factor and expected payoff. A backtest is a first filter, not a verdict: check a forward period and run the EA on a demo account before any live money.
This guide shows each setting, a table of the tick modes, how to read the report, forward and walk-forward tests, why tester and live results differ, and two tester limits we measured ourselves.
Part of the MQL5 and Expert Advisors academy.
How to Backtest an EA in MT5, Step by Step
The MetaTrader 5 Strategy Tester [1] replays history and lets the EA trade it with virtual orders. The settings below are on its Settings tab; the Strategy Testing (opens in a new tab) help page [2] describes each one.
- Open the tester. View โ Strategy Tester, or Ctrl+R. It opens at the bottom of the terminal.
- Pick the Expert Advisor. From the Expert dropdown, or right-click the EA in the Navigator (Ctrl+N) โ Test. It must be compiled (F7 in MetaEditor).
- Pick the symbol and timeframe. The symbol must be in Market Watch (Ctrl+U to add it), with the exact suffix your broker uses (
EURUSDandEURUSD.aare different symbols). - Set the dates. A long enough stretch for the EA to trade many times, in more than one kind of market. The tester loads extra history before the start date for the indicators.
- Choose the tick mode. See the table in the next section.
- Set deposit, leverage and delay. Use your real account's deposit currency and leverage. Set Delays to a fixed delay close to your ping (the tester can measure it) or to a random delay, not "zero latency": no live account fills at zero delay.
- Set Forward if you will optimize (next sections), then click Start. Progress shows at the bottom; the report opens when it ends.


To watch the EA trade bar by bar, tick Visual mode before Start: a chart opens with its trades and a speed control. It needs local agents and does not work during optimization.
Which Tick Mode Should You Use?
The tick mode decides how the tester moves the price inside each bar. MetaTrader 5 can use real or generated ticks (opens in a new tab) [3]; the choice changes results most for EAs with tight stops and targets.
| Mode | What it does | Use it when | What it can miss |
|---|---|---|---|
| Every tick based on real ticks | Replays the ticks your broker recorded, with their spread | Final checks; scalpers; tight stops; trailing stops; anything that acts inside a bar | Only as good as the broker's tick history; the first run is slow while it downloads |
| Every tick | Builds ticks from one-minute bars with the tester's algorithm | Real ticks are missing for your symbol or dates | The real order of highs and lows and the real spread changes inside each minute |
| 1 minute OHLC | Uses only the open, high, low and close of each one-minute bar | Fast passes and first optimizations of EAs that act on closed bars | Moves inside each minute; a stop and a target in the same minute |
| Open prices only | Runs the EA at the open of each bar of the test timeframe | EAs that check their rules once per new bar, and quick rough checks | Everything inside the bar: stops, targets and trailing are guessed |
| Math calculations | Loads no market data; only OnInit, OnTester and OnDeinit run | Pure calculations and optimizing math, not trading | Prices, orders and margin: there are none |
A simple rule: optimize on "1 minute OHLC" to save time, then re-run the chosen inputs on real ticks. If the result changes a lot between the two, the EA depends on what happens inside the bar, and only the real-tick run counts.
How to Read the Strategy Tester Report
When the run ends, the Backtest tab (called Results in the help) shows the statistics and the Graph tab the balance and equity curves. The help page on the testing report (opens in a new tab) [4] defines every field. Read it in this order:
| Read | Field | What it tells you | What to check |
|---|---|---|---|
| 1 | History quality | The share of correct one-minute data in the test | Well below 100 % means gaps or bad bars: the result is unreliable |
| 2 | Total trades | How many trades closed | A few dozen trades prove little; more trades, in different markets, say more |
| 3 | Equity drawdown maximal / relative | The deepest fall of equity, open trades included | Could you live with it, in money and in %? It is the number to size risk on |
| 4 | Balance vs equity drawdown | Balance counts closed trades only | Equity drawdown far above balance drawdown: trades sat deep in loss before closing |
| 5 | Maximum consecutive losses | The longest losing streak and what it cost | Multiply by your risk per trade: that is the streak you must survive |
| 6 | Profit factor | Gross profit รท gross loss | Close to 1 means costs decide the result; check it again after realistic costs |
| 7 | Expected payoff | The average result per trade | Compare it with your spread and commission per trade |
| 8 | Recovery factor, Sharpe ratio | Result against drawdown; result against its own variation | Use them to compare runs of the same EA, not as a target |
On the Graph tab, look for a curve that rises in steps across the whole test, not one that depends on a single period. The Journal tab lists every error the EA met; a clean report with a Journal full of errors is not clean.


Optimization, Forward Testing and Walk-Forward
Optimization. Tick an input's box on the Inputs tab, set Start, Step and Stop, pick a criterion and an optimization type (slow complete or fast genetic), and Start. The Optimization tab lists every pass. The best pass on past data is often the one that fits its noise best.
Forward. The Forward (opens in a new tab) setting [5] splits the date range: No, 1/2, 1/3, 1/4 or Custom (you set the forward start date). The EA is optimized on the first part and the chosen inputs are checked on the most recent part; those results appear on a separate Forward tab, with a line at the forward start on the chart. Inputs that hold up only in the first part were fitted to it.
Walk-forward. MetaTrader 5 has no built-in walk-forward analysis, but you can do it by hand with the Forward setting:
| Window | Optimize on | Then check on |
|---|---|---|
| 1 | Months 1-12 | Months 13-15 |
| 2 | Months 4-15 | Months 16-18 |
| 3 | Months 7-18 | Months 19-21 |
Each window is one tester run with a custom forward date. Keep an EA only if most forward windows hold up with similar inputs; if each window needs very different inputs, the rules are fitting noise. Warning signs at any stage: a strong backtest with a weak forward part, most trades packed into one period, and extreme inputs (a period of 3, a stop of 2 points).
Strategy Tester vs Live: Why Results Differ
The tester replays history under assumptions about ticks, spread and fills. A live account adds spread widening, slippage, delays and the broker's rules. If an EA looks good in the tester and fails on a real account, the gap is usually in the settings or the execution, not bad luck: fix those before you change the strategy.
| Factor | Strategy Tester | Live / demo account |
|---|---|---|
| Spread | From the history, or the value you set | Widens at news, at the daily rollover and in thin hours |
| Fills | At the tested prices, unless you set a delay | Slippage, requotes, partial fills |
| Delay | What you set under Delays | Internet, VPS and broker execution |
| Stop level | Applied to the prices the tester models | Enforced: 10016 invalid stops |
| Symbol | The one you picked | Suffixes and contract specs differ per broker |
| You | Absent | Switching the EA off, changing inputs mid-run |
- Spread and slippage. Scalping and gold EAs are the most sensitive: see Scalping EA for MT5 and Gold EA (XAUUSD). Test with a realistic spread and add a spread filter to the EA.
- Lot and margin. Read volume limits and tick value from the broker, never assume them: EA risk management.
- Prop accounts. The standard tester does not model daily-loss or news rules: prop firm EA rules.
An EA made without code has the same gap: it comes from market modelling and execution, not from how the MQL5 was written.
Two Tester Limits We Measured
We run the MQL5 code that AlfaTactix generates in the MetaTrader 5 tester to check it against our own backtest. Two tester behaviours from those runs matter for anyone testing an EA:
1. Higher-timeframe history starts on 1 January of the year before the test. The tester gave our Expert Advisor higher-timeframe history only from 1 January of the year before the test start. An EA on H4 that read a daily EMA 200 asked for 1,000 daily bars and got 303. The help page says the tester loads extra history before the start; it does not load as much as a long higher-timeframe indicator may want. What to do: if the EA reads a slow indicator on a higher timeframe, start the test later in the year, or judge only the trades after the indicator has had its bars.
2. A custom symbol is charged no commission and no slippage. On a custom symbol (one you create in MetaTrader 5 and fill with imported prices), the tester charges no commission, no slippage and no limit-order fill offset. A report on a custom symbol leaves those costs out, so subtract them yourself before you judge it.
Limits of what we measured: because of point 2, our trade comparisons with MetaTrader 5 do not prove commission and slippage there. Our runs used one symbol, one broker's feed and the "1 minute OHLC" mode; real-tick mode and live or forward trading were not run.
Or Backtest on the Site, Without MT5
If you build the strategy in the AlfaTactix Strategy Builder, you can test the same rules before you open MetaTrader 5. The backtest runs on the site: you don't need MetaTrader 5 or TradingView to backtest. Backtests run on data you upload, on any timeframe down to one minute; how many days one run covers depends on your plan (Pricing). The backtest is open to every signed-in user, on every plan, Free included.
Then download the generated EA and confirm it in the Strategy Tester with the steps above. How the engine compares with the MetaTrader 5 tester, and its limits: Backtest engine. Start here: No-code backtest.
A backtest is not a forecast; past results do not predict future results.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| EA not in the dropdown | Not compiled, or not in MQL5/Experts | Compile in MetaEditor (F7) and refresh the Navigator |
| No trades | Symbol not in Market Watch, filters never pass, lot below the minimum | Read the Journal; check volume limits and filters on the test dates |
| "Not enough money" | Lot too large for the deposit and leverage | Size from risk and check margin: EA risk management |
| Invalid stops in the Journal | Stops inside the stop level | Read SYMBOL_TRADE_STOPS_LEVEL: Error 10016 |
| Results change a lot between modes | The EA depends on moves inside the bar | Trust the real-tick run |
| Very slow run | Real ticks over a long period, or a huge optimization | Optimize on 1 minute OHLC, use the genetic algorithm, then re-check on real ticks |
Checklist Before Going Live
| Step | Action |
|---|---|
| 1 | Re-run the chosen inputs on Every tick based on real ticks |
| 2 | Use a realistic spread and a non-zero delay |
| 3 | Check a Forward period, or walk-forward windows |
| 4 | Read the report in order: quality, trades, equity drawdown, streaks, then the rest |
| 5 | Run the EA on demo across several sessions and compare its fills with the tester |
| 6 | Journal clean: no repeated 10016 / 10019 errors (common errors) |
| 7 | A VPS if the EA must run around the clock: VPS for an EA |
| 8 | Start live with the minimum lot and the risk caps you tested |
Design and test on desktop; the MT5 mobile app is for watching demo or live trades, not for tick-mode tests.
Next Steps
After the checklist, move the EA to demo first. Size every trade from your risk with EA Risk Management. To build the rules without code and test them on the site first, see Build an EA without coding.

