Backtesting on MetaTrader 4 (Step-by-Step)
MetaTrader 4 has a built-in Strategy Tester that lets you run any Expert Advisor (EA) against historical price data automatically. You get a full trade list, equity curve, and performance report — without risking a single cent. MT4 also supports manual backtesting using the F12 candle-by-candle method.
Risk warning: This content is for educational purposes only and not financial advice. Forex trading involves risk, and you can lose money.
MT4 Backtesting
Not sure what backtesting is? Read the backtesting overview first.
- Strategy Tester setup
- Data quality
- Optimization
- Limitations vs MT5
Opening the Strategy Tester
- Go to View → Strategy Tester, or press Ctrl+R. The Strategy Tester panel appears at the bottom of your screen.
Setting up your backtest
- Expert Advisor: select your EA from the dropdown. If you have not installed one yet, place the EA file in your MT4
MQL4/Expertsfolder and restart MT4. Thousands of free EAs are available online if you do not code your own. - Symbol: the currency pair you want to test (e.g., EURUSD).
- Period: the timeframe (e.g., H1, M15, D1).
- Model: the modelling method. “Every tick” is the most accurate — it simulates every price movement within each candle. “Open prices only” is much faster but only reliable for strategies that trade on candle close. “Control points” is a middle ground but rarely used.
- Use date: tick this box and set your start and end dates. Use at least 6 months of data, ideally 1 year or more.
- Spread: set to “Current” or enter a fixed value in points. For realistic results, use a spread close to your broker’s typical spread on this pair.
Expert properties
- Click the Expert properties button to open the settings window.
- Testing tab: set your initial deposit (e.g., $10,000) and leverage (e.g., 1:100).
- Inputs tab: all adjustable parameters of your EA — stop-loss size, take profit, indicator periods, lot size, etc. Adjust these to match what you want to test.
- Click OK, then click Start to run the backtest.
Reading the results
When the backtest finishes, three tabs appear at the bottom:
- Results tab: a list of every trade — entry time, exit time, direction, lot size, profit/loss, and running balance. Scroll through to check if the trades make sense with your strategy rules.
- Graph tab: the equity curve. A steady upward line is good. Sharp drops reveal dangerous drawdown periods. A flat line with a spike at the end is suspicious — the profit may depend on one or two lucky trades.
- Report tab: overall statistics including total trades, profit factor, expected payoff, max drawdown (in money and percentage), win rate, largest winning and losing trade, and average win/loss. See what to track in your backtest for what each metric means.
Data quality
The accuracy of your backtest depends entirely on the quality of your historical data. Bad data produces misleading results.
- After a backtest, check the modelling quality percentage in the Report tab. You want at least 90%. If it is lower, your data has gaps or missing candles.
- To improve data quality: go to Tools → History Center, select your pair, and download the available data. This gives you the basic data from MetaQuotes.
- For the best results, use a tick data tool (e.g., Tick Data Suite or TickStory) to download real tick-by-tick data. This gives you 99% modelling quality and accounts for variable spreads — much more realistic than MT4’s default generated ticks.
- Without good tick data, MT4 generates synthetic ticks from M1 candles. This is acceptable for strategies on higher timeframes (H1, H4, D1) but unreliable for scalping strategies on M1 or M5.
Optimization
Optimization lets you test hundreds or thousands of parameter combinations to find the best settings for your EA.
- In the Strategy Tester, tick the “Optimization” checkbox before clicking Start.
- In Expert properties → Inputs, set a range for each parameter you want to optimize: a start value, step size, and stop value. For example, stop-loss from 20 to 50 in steps of 5.
- MT4 tests every combination and shows the results in the Optimization Results tab, sorted by profit.
- Warning: do not just pick the most profitable combination. This is curve fitting — the “best” parameters often just got lucky on historical data. Look for parameter ranges where multiple nearby values are all profitable. That is a sign of a robust strategy.
- Speed limitation: MT4’s optimizer is single-threaded — it uses only one CPU core. Large optimization runs can take hours. If speed matters, MetaTrader 5 is dramatically faster with multi-threaded optimization.
Visual mode
- Tick “Visual mode” in the Strategy Tester to watch the EA trade on a chart in fast-forward. You see every entry and exit as it happens.
- Useful for understanding how your strategy behaves and spotting obvious problems (e.g., the EA trading during news or at odd times).
- Turn visual mode off when you want final results — it slows down the backtest significantly.
Manual backtesting (F12 method)
If you do not have an EA and want to test a discretionary strategy, you can step through the chart manually.
- Open a chart on your pair and timeframe.
- Turn off Auto Scroll: right-click on the chart and uncheck it. Otherwise the chart keeps jumping to the latest candle.
- Scroll back to your start date using the scroll bar or by pressing Home.
- Press F12 to move forward one candle at a time. You only see what has happened so far — not what comes next.
- When your entry rules are met, record the trade in a spreadsheet (entry price, stop-loss, take profit, date, direction).
- Keep pressing F12 until the trade hits stop or target. Record the result.
- Repeat until the end of your test period.
This method is slow but builds deep familiarity with price action. For a faster manual experience, consider a dedicated tool like Forex Tester Online or FX Replay — see the backtesting overview.
MT4 backtesting limitations
- Single-threaded. Optimization uses one CPU core — slow for large parameter sweeps.
- Generated ticks. MT4 creates synthetic ticks from M1 data by default. Less accurate than real tick data, especially for fast strategies.
- No built-in forward testing. You cannot split data into a backtest and validation period in one run. You have to do this manually or use MT5.
- 9 timeframes only. Cannot test on custom intervals like 2-hour or 8-hour charts.
- No longer actively developed. MT4 receives security patches but no new features. MetaQuotes is focused on MT5.
If these limitations matter to you, MetaTrader 5 solves most of them. If you want the easiest scripting experience, try TradingView.
