Backtesting means running your trading rules over past prices to see how they would have performed. Done properly, it tells you whether a strategy deserves a month on a demo account. Done badly, it produces a beautiful curve that vanishes the moment real money is involved. The difference is usually one of five mistakes in the test itself. Here are the five, then a proper test in the MT5 strategy tester and in a spreadsheet.
What a backtest can and cannot tell you
A backtest shows how often the rules fired, how big the wins and losses were, how long the losing streaks ran and how deep the drawdown went. It cannot promise that the future will look like the past, and it cannot fix vague rules; “buy when it looks strong” cannot be tested.
A backtest is a filter for bad ideas, not a proof of good ones. Its job is to reject strategies, and most should be rejected.
Mistake 1: Look-ahead bias
Look-ahead bias is using information that was not available at the moment of the decision. It is the most common way a test fakes profit, and the hardest to notice.
- Deciding at the open of a candle using that candle’s close.
- Using the day’s high or low as an entry filter before the day has ended.
- Indicators that “repaint”, redrawing past values once new candles arrive, so the history looks cleaner than it was live.
The fix: at every decision point ask “what did I know at this second?” In MT5 use the “every tick” modes, not open prices only, and avoid any indicator whose past values change.
Mistake 2: Ignoring spread, commission and swap
Every trade pays the spread, often a commission, and a swap for each night it stays open. A scalping strategy that earns 3 pips a trade can show a profit with zero costs and a loss with a 1-pip spread. The spread and commission guide explains how each is charged.
The fix: test with your broker’s typical spread, not its best advertised one, widened for news hours and the late New York session, plus commission per lot and the swap on any trade held past rollover.
Mistake 3: Over-fitting
Over-fitting is tuning the rules until they match the past perfectly. If a moving-average period of 37 beats 36 and 38 by a wide margin, that is noise, not an edge.
The fix: keep settings few, prefer round values, and check that nearby values give similar results. Split the history: design on the first part, test once on the second part you have never looked at. If the second half falls apart, the strategy was fitted, not found.
Mistake 4: Survivorship and selection bias
You test twenty ideas, keep the one that worked and forget the nineteen. Or you test gold only in the period you already know it rallied, or EUR/USD only in the quarter that fits the rules.
The fix: log every test you run, including the failures, and test on more than one pair across trending, sideways and crisis periods. A strategy that only survives the market it was built in has not been tested.
Mistake 5: Sample size
Thirty trades can show a 70 percent win rate by luck alone, and tell you nothing reliable about expectancy or drawdown.
The fix: aim for several hundred trades across years and conditions. If the strategy trades too rarely for that, keep your confidence low and your position size small.
Step by step: the MT5 strategy tester
- Write the rules precisely. Entry, stop, target, size, time filter and exit, so exact that a stranger could follow them. For an EA this is the code; for a manual strategy, write it as if it were.
- Load real history. In MT5’s symbol list, make sure the pair’s bars and ticks have downloaded and that history reaches back as far as you intend to test; gaps show up as flat stretches.
- Set the costs. In the tester’s settings, set the spread to your broker’s typical value or higher. Confirm commission and swap in the symbol specification; if missing, deduct them from the report by hand.
- Pick the modelling mode. “Every tick based on real ticks” is the slowest and the most honest. “Open prices only” is fast and only acceptable for strategies that act strictly on candle closes.
- Test on data you did not design on. Run the first test on the out-of-sample period, not on the chart you tuned the rules against.
- Read the whole report. Net profit is the least useful number. Look at trade count, profit factor, maximum drawdown, longest losing streak and average trade after costs.
- Forward test. Run it on demo for at least a month and compare the live equity curve with the tested one; a large gap means a hidden mistake.
Step by step: a spreadsheet for manual strategies
- Open the chart at a past date and hide everything to the right (MT5’s “shift end of chart” setting, or a replay tool).
- Create columns: date, pair, direction, entry, stop, target, exit price, result in R (profit divided by the risk), spread deducted, and a note on why the trade was taken.
- Move forward one candle at a time. Log every signal the rules produce, including the ugly ones. Skipping the ones you “would not have taken” is selection bias.
- Deduct the spread from every trade and the swap from every overnight one.
- After a few hundred rows, compute: win rate, average win in R, average loss in R, expectancy, longest losing streak and maximum drawdown in R.
A worked example of expectancy
Suppose a spreadsheet test of 200 trades shows a 45 percent win rate, an average win of 1.6R and an average loss of 1R. All numbers here are an example.
- Expectancy before costs = 0.45 × 1.6 − 0.55 × 1 = 0.72 − 0.55 = 0.17R per trade.
- Now suppose the stop is 20 pips and spread plus commission cost 2 pips a trade, which is 0.10R.
- Expectancy after costs = 0.17 − 0.10 = 0.07R per trade.
The edge survives, but costs took more than half of it. A slightly wider spread, or a few trades lost to look-ahead bias, and it is gone. That is what a backtest is meant to reveal before real money does.
Checklist before you trust a backtest
- Rules written so precisely that no judgement is needed.
- Every decision uses only information available at that moment.
- Spread, commission and swap included at realistic, not ideal, levels.
- Few settings, and neighbouring settings give similar results.
- Tested on a period and a pair that were not used to design it.
- Several hundred trades across trending, sideways and crisis markets.
- Drawdown and losing streak read before net profit.
- A month of demo results compared with the test.
A strategy that passes all eight is worth a small live account with the risk rules applied from the first trade. One that fails any of them goes back to the drawing board, and that is the backtest doing its job.
Questions, answered plainly.
How many trades does a backtest need to mean anything?
There is no magic number, but a few dozen trades is not evidence. Aim for several hundred signals spread across different market conditions, including at least one period where the strategy lost money.
Can I backtest a manual strategy without coding?
Yes. Scroll the chart forward candle by candle with the future hidden and log every signal in a spreadsheet. It is slow, but it is the honest way to test discretionary rules.
Does the MT5 strategy tester include spread and swap?
It applies the spread you set and the symbol's swap and commission settings from your broker. Check them in the tester settings and the symbol specification; if they are missing, deduct them yourself.
A strategy made money in the backtest. Can I trade it live now?
Not yet. Run it on a demo account for at least a month and compare the live results with the backtest. If they diverge a lot, one of the mistakes in this post is probably hiding in the test.