How to backtest a trading strategy without fooling yourself
A backtest is running a strategy's rules on historical data to see what would have happened. It's the only tool that turns a hypothesis into a tested method, and also the easiest way to fool yourself: almost every first backtest comes out profitable, and most of that profit disappears the moment you add costs, realistic execution, and stocks that no longer exist. This page is the protocol we work by, including the mistakes we caught in our own measurements.
The rule above all others: if you change the rules after seeing the result, you're no longer testing, you're fitting. A method fitted to the past explains the past perfectly and the future not at all.
Seven mistakes that turn a backtest into a story
- Look-ahead bias: Using information that wasn't available at the moment of decision. The common example: a signal calculated from a candle that hasn't closed yet, or an average that includes today's close in this morning's decision. We fixed this in our engine by generating signals from closed candles only.
- Phantom fills: Assuming you bought at the trigger price even when price only came close to it. In our own testing, skipping the check that the candle's range actually included the entry price produced hundreds of R of fake profit: losers always get filled (to hit the stop, price must pass through the entry), but the big winners don't always.
- No costs: Commission, bid-ask spread, and slippage. A method with thousands of small trades can flip from profit to loss from this alone. Also run a scenario with doubled costs.
- Survivorship bias: Today's universe is applied to the past. Stocks that crashed and were dropped from the index aren't included, so any method that buys "winners" looks too good. We flag this next to every table, because we haven't solved it.
- Too few trades: Below two hundred trades, the difference between two versions is usually noise. The 28 golden-cross trades in our strategy tournament are an example: a row you shouldn't draw conclusions from.
- Overfitting: Testing twenty configurations and publishing the best one. If configuration 14 works and 13 and 15 don't, that's not an edge, it's luck selected in hindsight.
- One window: Three years of a bull market tell one story. Everything we measured from 2023 to 2026 was measured in a bull market, and that's part of the answer.
The protocol
- Rules written before the data. Entry, exit, size, filters, and what happens on a tie. A rule that isn't written doesn't exist.
- Realistic execution: Signal at the close, entry at the next open; the stop fills at the stop price or the open, whichever is worse; the target counts only if a candle actually reached it; if stop and target are hit in the same candle, count it as a loss. Every uncertainty against the method.
- Split over time: Development on one period, validation on a period you haven't touched, and then a final test period seen only once. If the result is positive only in development, that's overfitting.
- Pre-set acceptance gates: At least two hundred trades, positive expectancy after costs, profit factor above 1.25, and a result that remains positive under doubled costs and in at least two market regimes.
- Paper trading: A hundred trades with documentation of the trigger, actual fill, slippage, and rule violations. If paper trading doesn't match the backtest, the problem is in execution, not the method.
- Real money, small size: Risk 0.1% per trade for the first fifty trades. Only then do you scale up.
What to do with the result
A method that passed the gates isn't a promise, it's a license to trade it small and keep measuring. A method that failed at one gate doesn't get "fixed" by tweaking it until it passes: you state one hypothesis for the change and test it on new data. All the hypotheses added to the engine this year (minimum risk-reward ratio, regime gate, closed-candle signal generation, extreme RSI blocking) went through the same process, and whatever we measured that didn't improve results was left out.
Want to see this on a real chart?
TechAnalyzer Pro analyzes any stock or cryptocurrency and marks the levels, patterns and indicators for you, with a plain-English explanation next to every term. No credit card required.
📈 A stock before its breakout, once a week by email
Each week, one stock with an interesting technical setup, and a simple explanation of what to check on the chart.
Free. One-click unsubscribe. Not investment advice.