How to read a backtest without fooling yourself
A backtest replays a trading rule on past prices. It is useful, and it is very easy to make one say whatever you hoped.
What a backtest is
A backtest takes a rule, such as “buy when the price closes above its 100-day average”, and applies it day by day to a history of prices, recording what would have been bought and sold and what the account would have been worth.
It answers a narrow question: what would this exact rule have done on this exact history? It does not answer what the rule will do next.
Four ways a backtest misleads
- Trying many versions and keeping the best. Test enough settings and one will look brilliant by chance. This is called overfitting.
- Using information from the future. If a rule decides using today’s closing price and also trades at today’s closing price, it is acting on something it could not yet know.
- Leaving out costs. A rule that trades often can look profitable until each trade is charged.
- Judging on a flattering period. Almost anything that owned stocks looks good over a long rise.
Five questions to ask
- Compared with what? A result means little until it is set beside simply buying and holding.
- Was the judged period kept apart from the period used to choose the settings?
- How many versions were tried, and how did the others do?
- How many trades is the result built on? A handful of trades proves very little.
- How deep was the worst fall, and how long did it last?
Training and test periods
The simplest protection is to split the history. Settings are chosen on the earlier part, the training period. The rule is then run once on the later part, the test period, and that is the number you report. If a rule shines in training and fades in the test, it was fitted to the past and not to anything lasting.
What the tools on this site do
Every study in the Research Lab keeps a test period apart, compares with a benchmark, charges costs, and shows all the settings it tried and not only the winner. Practice data is simulated and labelled, and results from your own files stay in your browser.
Common questions
- What is overfitting?
- Overfitting is tuning a rule so closely to past data that it captures that data’s accidents instead of anything that will repeat. An overfitted rule looks excellent in the period it was tuned on and ordinary or worse afterwards.
- What is drawdown?
- Drawdown is the fall from a previous high to a later low, as a percentage. The maximum drawdown is the deepest such fall in the period. It measures how bad it got along the way, which a final return hides.
- What is the Sharpe ratio?
- It is the average return earned above cash, divided by how much the returns swung. A higher figure means more return for each unit of ups and downs. It says nothing about rare large losses.
Try it
Reading about a rule is not the same as watching it run. The study is free, needs no account, and starts on practice data.
More guides
Educational explanation with illustrative examples. Not financial advice, and not a recommendation to use any strategy.