A backtest applies the rules of a strategy to historical data to see how it would have performed. It looks simple, and that is exactly why it is easy to get wrong: most of the spectacular backtests you see online fail because of errors their author cannot see. This guide explains what a backtest can and cannot tell you, which biases invalidate it and how to run one honestly.
What a backtest is and is not
A backtest simulates past trades using rules defined in advance: when to enter, where to put the stop, when to exit and with what size. Its real value is to discard bad ideas quickly and to estimate the order of magnitude of key figures (win rate, typical loss, losing streaks). It does not prove the strategy will win in the future; it only says that, with that data and those assumptions, this is what would have happened.
Think of a backtest as a stress test, not a forecast. A bad result is very reliable information (if it does not even work in the past, there is no reason to risk money). A good result is only a hypothesis that still has to survive more tests.
Data: garbage in, garbage out
The quality of your data limits the quality of your conclusion. Check for gaps and duplicates, time zone and daylight saving changes, and splits or dividends on shares. With one-minute candles you cannot tell whether the stop or the target was hit first inside the same candle; tick data can tell you, but it is heavier and not always available.
In CFDs and forex, historical prices depend on the provider: real spreads were wider during news and in thin hours than the average spread many programs apply by default. In futures, a badly built continuous series (without adjusting for the jumps between expiries) can create false gains or losses at every roll. Always compare a sample of trades against a real chart.
Look-ahead bias
This happens when the simulation uses information that did not exist at that moment. The classic example is deciding an entry using the high or close of the candle you enter on, knowing how it ended. It also appears with indicators that repaint, fundamental data published after the date shown in the table, or a moving average computed with future values because of an indexing error.
The warning sign is a near-perfect curve that collapses in real time. To avoid it, make sure each decision uses only closed candles, execute the order at the open of the next candle, and manually review a few trades checking exactly what you knew at that moment.
Survivorship bias
If you test a stock strategy only on companies that exist today, you ignore those that went bankrupt, were dropped from an index or were merged. The survivors, by definition, did better, so results come out inflated. The same applies to discarded cryptocurrencies, closed funds, or indices rebuilt using today’s members.
The fix is to use data that includes delisted companies (with the historical composition for each date) or to limit yourself to instruments that existed and traded normally throughout the whole period. In forex and index futures the problem is smaller, but there is a variant: choosing the instrument or period that worked best is another form of selecting after the fact.
Costs and slippage: the forgotten drag
A backtest without costs overstates performance, and the more you trade, the more it overstates. You need to include spread, commission, swap for overnight positions and slippage, which is the difference between the expected price and the price you actually get, especially on stops and around news. A practical rule is to assume more slippage on stop orders than on limit orders.
Tight-stop strategies are the most sensitive: if you pay 1.5 pips in total costs and your stop is 15 pips, the cost is 0.1 R on every trade; with a 50 pip stop it is only 0.03 R. An edge of 0.10 R per trade disappears in the first case. Always rerun the backtest with costs 50% higher than you expect and see whether it is still profitable.
Small samples: chance also draws pretty curves
With few trades, chance dominates. A strategy with an edge of +0.17 R per trade, a 45% win rate, an average win of 1.6 R and a loss of 1 R has a standard deviation of about 1.29 R per trade. With 30 trades, the standard error of the mean is 1.29 ÷ √30 ≈ 0.24 R: the 95% confidence interval is ±0.46 R, which comfortably includes zero and very negative values. With 200 trades, the error falls to 0.09 R and the interval runs from −0.01 to +0.35 R.
In other words, even 200 trades barely suffice to tell a small edge from luck. As a reference, for the lower end of the interval to clear zero with that edge you would need about 220 trades, and to have an 80% chance of detecting it, about 455. If your strategy trades twice a week, do not expect solid conclusions from a single year.