Backtesting a trading strategy: nine mistakes that make good results lie
A beautiful backtest is easy to build and easy to fool yourself with. The nine most common mistakes, from look-ahead bias to ignoring costs, and how to test a strategy honestly.
A backtest tests a trading strategy on historical data to see how it would have performed. It is essential, and it is also the easiest place to fool yourself. Most strategies that look brilliant in a backtest fail live because of a few repeatable mistakes: look-ahead bias, overfitting, survivorship bias and ignoring costs and slippage.
Nothing in this article is investment advice, and no backtest guarantees future returns. The goal is narrower: to help you tell the difference between a strategy that might work and one that only works on the past.
What is a backtest actually measuring?
A backtest replays history and applies your rules as if you had traded them. It measures how the rules would have behaved on that specific data, under the assumptions you made about prices, costs and execution. Every unrealistic assumption makes the result look better than reality. The skill is in removing those assumptions one by one.
Which mistakes make backtests lie?
1. Look-ahead bias
Using information that was not available at the time of the trade, such as using a day’s closing price to decide a trade placed at that day’s open. It is the most common bug and produces impossibly good results.
2. Overfitting
Tuning parameters until the strategy fits past data perfectly. A strategy with many tuned settings often captures noise, not a real pattern, and collapses on new data.
3. Survivorship bias
Testing only on stocks that exist today ignores the companies that were delisted or collapsed. Results look better because the losers are missing from the data.
4. Ignoring costs and slippage
Brokerage, taxes, exchange charges and the gap between the price you see and the price you get add up fast, especially for frequent trading. Many profitable-looking intraday strategies become loss-making once realistic costs are included.
5. Unrealistic fills
Assuming every order fills at the exact price, in any size. Illiquid stocks and fast markets do not work that way.
6. Too little data, or one market regime
A strategy tested only in a rising market has not been tested. Include different conditions: trending, sideways and sharply falling periods.
7. Data snooping
Trying hundreds of ideas on the same data and keeping the best one. By chance alone, something will look good.
8. Ignoring drawdowns
Judging only total return hides the pain. A strategy that falls 40 percent before recovering may be impossible to stick with in real life.
9. No out-of-sample test
If every bit of data was used to design the strategy, you have nothing left to check it on.
How do you backtest honestly?
What metrics should you look at?
What about rules for algo trading in India?
Algorithmic trading by retail investors in India is regulated, and rules for how retail algos must be offered through brokers have been evolving. Check the current position on the SEBI website and with your broker before running any automated strategy with real money.
Treat any backtest that looks too good as a bug until proven otherwise. In practice, it almost always is.
What does an honest backtest workflow look like?
Which tools do you need?
Python with pandas and NumPy handles data and calculations, a plotting library shows equity curves and drawdowns, and a backtesting library or your own simple event loop runs the rules. Good data matters more than clever code: adjusted prices for splits and dividends, correct timestamps and, ideally, delisted instruments. Keep every experiment in a notebook or log, including the ideas that failed, so you can see how many things you tried before finding a winner. That record is your best defence against data snooping.
How do you judge whether an edge is real?
Ask whether there is a sensible reason the pattern should exist, such as behaviour, structure or risk, rather than only a statistical result. Check that small changes to parameters do not destroy performance; fragile strategies are usually overfitted. Look at results year by year, not just the total. A modest, stable edge that survives costs is far more valuable than a spectacular curve built on a handful of trades.
What skills do you need to do this properly?
Python and pandas for handling data, enough statistics to recognise noise, and a working understanding of market microstructure: how orders, spreads and liquidity work. Our guide on how much maths machine learning needs covers the statistics side.
Classes run live online, so the FinTech and Algorithmic Trading program is open to learners anywhere in India: metros such as Chennai, Hyderabad, Bengaluru and Pune, growing cities such as Coimbatore, Kochi, Indore and Nagpur, and smaller towns such as Ranchi, Patna, Bhubaneswar and Raipur. Classroom batches run in Kolkata, Asansol and Durgapur, and companies can book on-site batches.
Our FinTech and Algorithmic Trading program teaches Python, data, strategy research and honest backtesting over six months. ₹49,999 with No-Cost EMI of ₹10,000 × 6. No profit promises, ever.
SEE THE COURSEFrequently asked questions
Related reading
We teach this, live
Every article here comes from something we teach. Sit in on a free masterclass and judge the mentors yourself.