Backtest vs forward test: how to test an EA in MetaTrader 5 without fooling yourself
A backtest can show years of results in minutes. That speed is useful and dangerous at the same time, because a test that looks perfect on history can tell you very little about next month.
Two kinds of test
A backtest runs an Expert Advisor on historical prices, as if it had been trading in the past. A forward test runs it in real time on a demo or live account, from today onwards. Both have a place. Problems start when a backtest is treated as a promise.
Running a backtest in MetaTrader 5
- Open the Strategy Tester with Ctrl+R or from the View menu.
- Choose the Expert Advisor, the symbol, the timeframe and the date range.
- Choose the modelling mode (see below).
- Set the deposit, leverage and, if available, the delays.
- Set the EA's inputs on the Inputs tab, then click Start.
- Read the results on the Backtest and Graph tabs: net profit, drawdown, profit factor, number of trades and the equity curve.
Choose the right modelling mode
- Every tick based on real ticks: uses the real tick history from your broker, including real spreads. This is the most realistic mode and the one to use for any final test.
- Every tick: generates ticks artificially from minute data. Faster, but less exact.
- 1 minute OHLC and Open prices only: very fast, useful only for strategies that do not depend on what happens inside a bar.
For news and session strategies, where seconds matter, only real ticks give a meaningful result, and even then with limits.
Add execution delay
MetaTrader 5 lets you add a delay to order execution. The default "zero latency, ideal execution" fills every order instantly. Choosing a random or fixed delay gives a more honest picture of what a real connection to your broker looks like.
Why backtests are often too optimistic
- Perfect fills. Even with real ticks, a tester cannot fully reproduce slippage, requotes and the competition for liquidity around a major release. See spread and slippage during news.
- Missing or different data. Tick history differs between brokers, and older periods may have gaps.
- Changing conditions. Spreads, contract sizes and trading hours change over time.
- Overfitting. This is the biggest risk, explained below.
Overfitting: the perfect past
Overfitting means tuning the settings until they fit the past almost perfectly. With enough inputs and optimisation runs, almost any EA can be made to look excellent on historical data. The settings then describe the noise of that specific period rather than a real edge, and they often fail on new data.
Ways to reduce it:
- Keep the number of inputs you optimise small.
- Prefer settings in a stable area, where nearby values also perform reasonably, over a single sharp peak.
- Use out-of-sample data: optimise on one period and test on a later period the EA has never seen. MetaTrader 5 has a Forward option in the tester settings that splits the period for you.
- Be suspicious of results that look too smooth, especially with a very high win rate and deep floating losses, which can point to martingale or grid behaviour.
The forward test
A forward test answers the question a backtest cannot: how does the EA behave today, on my broker, with real execution?
- Start on a demo account to check that everything works: inputs, WebRequest, dashboard and logs.
- Move to a small live account as soon as possible, because demo execution is often better than live.
- Run it long enough to cover many trades and different market conditions: for a news EA, several months of releases; for a session EA, many trading days.
- Compare the live results with the backtest for the same period. A moderate gap is normal. A very large gap points to execution, data or overfitting problems.
- Publish or follow the account as an MQL5 signal, so the record is independent and verifiable. Our guide on reading an MQL5 signal explains what to check.
How much to trust each test
Think of the backtest as a filter: it can tell you that an idea is clearly bad, and it can show how the strategy behaves in different historical periods. The forward test is the evidence: slower, smaller, but real. A strategy deserves real money only after both point in the same direction.
Key takeaways
- A backtest runs an EA on history; a forward test runs it in real time on a demo or live account.
- In MetaTrader 5, use "Every tick based on real ticks" and add execution delay for realistic tests.
- Backtests miss real slippage and execution, and can be overfitted to the past.
- Reduce overfitting with few optimised inputs, stable settings and out-of-sample periods.
- Trust a strategy only when a long live forward test confirms the backtest.
Trading carries a high level of risk and may not be suitable for everyone. This article is for education only and is not financial advice. Past results do not guarantee future results.