Backtesting means applying your written rules to historical data to see what would have happened. Done carefully it is valuable. Done carelessly it is a way to feel confident about something that does not work.
Rules first, results later
Write the complete rules before you look at any results, and do not change them while testing. Every time you tweak a rule after seeing a bad result, you are fitting the rules to the past.
The main traps
- Look-ahead bias. Using information you would not have had at the time, for example judging a swing point that was only confirmed several candles later.
- Overfitting. Tuning many settings until the past looks perfect. The more knobs, the more likely you have described noise.
- Cherry-picking. Testing only the periods or markets where it works.
- Ignoring costs. Spread, commission and slippage can turn a small profit into a loss.
- Too few trades. A good result over twenty trades can easily be luck.
In-sample and out-of-sample
Design the rules on one stretch of data (in-sample). Then run them once, unchanged, on a different stretch you have not looked at (out-of-sample). If the results collapse, the rules were fitted to the first period.
Measure the right things
Record the number of trades, win rate, average win and loss in R, expectancy, and the maximum drawdown. Ask not "did it make money?" but "could I have stayed in it through its worst period?"
Backtest results are optimistic
Even a clean backtest tends to overstate live performance, because live trading has slippage, missed fills, and your own behaviour. Treat the backtest as a filter that removes bad ideas, not a forecast that proves good ones.