Backtesting on MetaTrader 5 (Step-by-Step)
MetaTrader 5 has the most powerful free backtesting engine available to retail traders. Multi-threaded optimization, real tick data from your broker, and built-in forward testing make it a major upgrade over MT4’s Strategy Tester.
Risk warning: This content is for educational purposes only and not financial advice. Forex trading involves risk, and you can lose money.
MT5 Backtesting
Not sure what backtesting is? Read the backtesting overview first.
- Strategy Tester setup
- MT5 vs MT4 differences
- Optimization
- Forward testing
Opening the Strategy Tester in MetaTrader 5
- Go to View → Strategy Tester, or press Ctrl+R. The Strategy Tester panel appears at the bottom of your screen.
Setting up your backtest
The basic workflow is the same as MT4:
- Expert Advisor: select your EA from the dropdown. MT5 EAs are written in MQL5 (not compatible with MT4’s MQL4 EAs).
- Symbol: the currency pair to test.
- Timeframe: MT5 offers 21 timeframes — including M2, M3, M4, M6, M10, M12, M20, H2, H3, H6, H8, and H12 — versus MT4’s 9.
- Date range: set start and end dates. At least 6 months, ideally 1 year+.
- Modelling: choose “Every tick based on real ticks” for the most accurate results. MT5 downloads actual tick data from your broker’s server — no need for third-party tick data tools like on MT4.
- Deposit and leverage: set in the Strategy Tester settings.
- Inputs: click the Inputs tab to adjust your EA’s parameters (stop-loss, take profit, indicator settings, etc.).
- Click Start.
What makes MT5 better than MT4 for backtesting
- Real tick data. MT5 downloads actual tick-by-tick data from your broker. No more synthetic ticks generated from M1 candles — results are significantly more realistic, especially for scalping and fast strategies.
- Multi-threaded optimization. MT5 uses all your CPU cores to test parameter combinations in parallel. An optimization run that takes hours on MT4 can finish in minutes on MT5.
- 21 timeframes. Test on intervals MT4 does not support, like H2, H8, or M10.
- Built-in forward testing. You can split your data into a backtest period and a forward test period in a single run. MT5 optimizes on the first period and validates on the second — a quick way to check for overfitting.
- MQL5 is more powerful. Object-oriented programming, more built-in functions, and better support for complex strategies than MQL4.
Reading the results
Same structure as MT4, but with more detail:
- Results tab: every trade listed with entry, exit, profit/loss, and running balance.
- Graph tab: equity curve showing the balance over time. Look for a steady upward line. Sharp drops reveal drawdown risk.
- Backtest tab: detailed statistics — total trades, profit factor, Sharpe ratio, expected payoff, max drawdown, win rate, and recovery factor. See what to track for what each metric means.
Optimization
- Select “Full optimization” or “Fast genetic based algorithm” in the Strategy Tester mode dropdown.
- In the Inputs tab, set a range for each parameter: start value, step, and stop value.
- Full optimization tests every single combination — thorough but slow even with multi-threading for large parameter spaces.
- Genetic algorithm uses intelligent sampling to find good parameter areas much faster. Usually the better choice for initial exploration.
- Results appear in the Optimization Results tab. Look for clusters of profitable settings — not just the single best result. Isolated winners are likely curve fitted.
Built-in forward testing
- In the Strategy Tester, enable “Forward” and set a forward testing period (e.g., the last 3 months of your date range).
- MT5 optimizes your EA on the backtest period, then automatically runs the best parameters on the forward period to see if they hold up.
- This is a quick sanity check — if the forward results are dramatically worse than the backtest, your parameters are likely overfitted.
- For a deeper understanding of forward testing, read the forward testing guide.
Metatrader 5’s backtest visual mode
- Tick “Visualization” to watch the EA trade on a chart in fast-forward. You see entries, exits, and indicator values in real time.
- MT5’s visual mode is smoother and faster than MT4’s. Useful for understanding strategy behavior and spotting issues.
- Turn it off for final result runs — it slows down the process.
Manual backtesting (F12 method)
Same as MT4: turn off Auto Scroll, scroll back to your start date, and press F12 to step forward one candle at a time. Record each trade in a spreadsheet. For a faster manual experience, consider a dedicated tool — see the backtesting overview.
