What Is Backtesting and What Does It Tell You?
Once you've set up trading rules, you'll probably wonder, "What would have happened if I'd followed these back then?" A backtest is a simulation that answers that question. It applies rules you decided in advance to past price data and calculates what the result would have been if you'd bought and sold exactly by those rules. It isn't a record of real trades. It's a simulation that assumes "what if you'd followed this rule at the time." That's why it's used to check how your rules behaved in a range of past market conditions. It isn't a tool that tells you what will happen next.
What a backtest does
You need three things to run a backtest.
- Rules: when to buy (the buy condition), when to lock in a profit (the take-profit condition), and when to cut a loss (the stop-loss condition)
- Data: the past prices of a stock. Daily candles, which show one price per day, are the usual choice.
- Period and method: which period to look at, and whether to put in your money all at once at the start or in smaller amounts at regular intervals
The calculation starts on the first day of the period and moves forward one day at a time. It builds up a record of buying on days when the buy condition is met and selling on days when the sell condition is met. Emotions don't get involved and only the rules are followed, so the character of the rules themselves shows through.
What you read in the results
The results screen shows values like these.
- Return: how much your assets grew or shrank over the whole period
- Maximum drawdown (MDD): the biggest drop from the highest point. It shows the decline you'd have had to sit through while following the rules.
- Win rate and number of trades: the share of trades that ended in a profit, and how many trades there were. When there are only a few trades, the win rate can swing a lot by chance.
- Difference from buy-and-hold: a comparison with simply holding through the same period without any trading
If you look only at return, you'll miss a lot. Even with the same return, a rule that dropped sharply along the way and one that moved gently are different in character. The whole period can end in a loss, and sometimes the trading result is worse than just holding. Those results are still useful, because they give you a reason to adjust or drop a rule.
What a backtest doesn't tell you
When you look at backtest results, keep the limits in mind too. U.S. Commodity Futures Trading Commission (CFTC) rules require commodity pool operators and commodity trading advisors who show simulated or hypothetical performance to include a disclaimer to this effect (they can also use wording set by the futures association instead). Such performance has inherent limitations, doesn't represent actual trading, and is designed with the benefit of hindsight. A backtest you run yourself has the same limits.
- Hindsight: if you keep tweaking conditions while looking at the results, you end up with rules that fit only the past (overfitting).
- Daily closing prices: price moves within the day aren't reflected, so the price you'd actually get filled at can be different.
- Survivorship bias: if the data keeps only stocks that are trading now and leaves out stocks that were delisted in the past, the results can look better than they really were.
- Costs: fees, taxes, and slippage (the difference between the price you ordered at and the price you actually got) can change the results.
Past performance does not guarantee future returns. Backtest results are a simulation run on past data and may differ from actual trading. This article is for education and information only and is not investment advice.
What you can do in the app
If you run into unfamiliar terms on the results screen, you can look them up in the glossary in the Principle app. It explains terms like backtest, MDD, and buy-and-hold.
View on the App Store · View on Google Play
Sources
Principle - Backtest your stock trading rules without code · What you can do with Principle