How to backtest a trading strategy (without fooling yourself)
What backtesting is, manual versus automated backtests, how many trades you need and the common biases that make a strategy look better than it is.
Backtesting means testing a strategy on historical data to see how it would have performed. Done well, it saves you months of real losses: you find out in days whether an idea makes sense. Done badly, it gives you false confidence that the market will correct with real money.
What it is and what it's for
A backtest answers questions like: does this strategy make money in the long run? What's its win rate and risk/reward? What drawdown did it have? How many losses in a row should I expect?
It's also useful for something less obvious: practicing execution. Repeating a setup a hundred times on the chart trains your eye to recognize it in real time.
Manual and automated backtesting
- Automated: you write the rules in code and a program applies them to years of data in seconds. It's fast and objective, but it only works for rules that can be 100% defined.
- Manual (replay): you replay the market candle by candle, without seeing the future, and make decisions as you would live. It's slower, but it's how you test discretionary strategies, and it trains your execution. On Zeteo Trades you can do it for free in the Backtesting section, with 1-minute candles from real futures.
Step by step for a manual backtest
- Write down the rules before you start. Entry conditions, stop placement, target or exit method, allowed hours and how many trades per day. If a rule can't be written down, it isn't a rule yet.
- Pick the period and the instrument. Include different market conditions: trending days, ranging days and news days.
- Hide the future. Use a replay mode that only shows past candles. Looking at the full chart and "finding" entries is the most common mistake.
- Log every trade as if it were real: entry, stop, exit, result in R and a screenshot. Use the same fields as in your trading journal.
- Don't change the rules halfway. If you think of an improvement, write it down and test it in a new backtest.
- Analyze the results: win rate, actual risk/reward, expectancy, profit factor and maximum drawdown.
How many trades you need
With 20 or 30 trades the result depends too much on chance. As a reference:
- Fewer than 30: only useful for ruling out clearly bad ideas.
- 30 to 100: trends start to show.
- More than 100: a reasonable estimate of win rate and expectancy.
If your strategy produces few trades per month, you'll need more historical data to reach a useful sample.
The biases that ruin a backtest
Look-ahead bias. Using information you didn't have at the time: seeing how the candle closed before deciding, or knowing "the market crashed that day". Replay mode largely prevents it.
Overfitting. Tweaking parameters until the historical result looks perfect: "17-period average instead of 20, 13-point stop, Tuesdays and Thursdays only". The strategy ends up describing the past instead of predicting the future. The more parameters you tune, the more you should distrust the result.
Ignoring costs. Commissions and slippage can turn a strategy with many small trades from a winner into a loser. Always include them.
Idealized execution. On a historical chart it looks easy to enter right at the low. Live there's hesitation, delays and orders that don't fill. If your strategy only works with perfect fills, it's fragile.
Cherry-picked samples. Testing only the months that "worked". Choose the period before you start and don't change it.
Validate before risking money
A good practice is to split the data in two: develop and tune the strategy on the first part (in-sample) and test it, without touching anything, on the second (out-of-sample). If the results look alike, that's a good sign. If they collapse in the second part, you probably overfit.
After the backtest, the next step is a forward test: trading the strategy in real time on a demo account or with very small risk, and comparing the results with the backtest in your journal.
What to do with the results
- Negative expectancy: drop or redesign the strategy. Don't "fix" it with more filters until it turns positive.
- Positive expectancy and acceptable drawdown: move on to a forward test with reduced risk.
- Positive expectancy but a drawdown you couldn't stomach: lower your risk per trade or look for a less volatile setup.
Summary
A good backtest starts with written rules, hides the future, logs every trade honestly, includes costs and collects enough trades. It's the cheapest way to find out whether an idea deserves your money, as long as you don't fool yourself while doing it.