What is Backtesting?
Backtesting is testing a trading rule on past market data to see how it would have performed: how many trades, wins and losses, drawdowns and costs. It shows how a rule behaved in the past; it cannot tell you how it will behave in future.
Also called: backtest, backtesting in trading, strategy backtesting, backtest trading strategy
A simple backtest: 10/30-day moving-average crossover on NIFTY futures
Buying NIFTY futures when the 10-day average crossed above the 30-day and selling when it crossed back, from 19 Dec 2025, gave 5 closed trades: none of them won, with an average loss of −2.11% - an expectancy of −2.11% per trade. The rule returned −1.78% against −0.15% for buy-and-hold.
| Measure | Value |
|---|---|
| Closed trades | 5 |
| Win rate | 0% |
| Average win | 0.00% |
| Average loss | −2.11% |
| Expectancy per trade | −2.11% |
| Total return (rule) | −1.78% |
| Buy and hold | −0.15% |
| Max drawdown (rule) | −11.27% |
Long or flat, on daily closes, before costs and slippage, about one year of data - far too few trades to judge a rule. It shows the arithmetic, not an edge.
Backtest your own strategy →How it works
A backtest needs three things: exact rules, clean historical data and a way to simulate trades. The rules must say precisely when to enter, when to exit and how much to trade, with no room for judgement. The software then walks through the data one bar at a time, applies the rules using only information available at that moment, records each trade and builds an equity curve, the running value of the account.
The output is a set of statistics: number of trades, win rate, average win and loss, expectancy per trade, total return, maximum drawdown and often a Sharpe ratio. For F&O the data must also handle real contract details, such as rolling futures from one expiry to the next and using option premiums that actually traded.
Worked example. suppose a rule tested on two years of NIFTY futures data makes 40 trades. 16 win with an average gain of ₹6,000 and 24 lose with an average loss of ₹2,500. Gross result = 16 × 6,000 − 24 × 2,500 = 96,000 − 60,000 = ₹36,000. If costs and slippage come to ₹400 per round trip, that is 40 × 400 = ₹16,000, leaving ₹20,000. Costs took away 16,000 ÷ 36,000, about 44% of the gross result.
Reading today's live example
The live example above runs a deliberately simple rule on NIFTY futures daily closes over about a year: a crossover of the 10-day and 30-day moving averages. It shows the number of trades, win rate, average win and loss, expectancy, total return against simply holding NIFTY futures, maximum drawdown and the equity curve. It is illustrative and before costs. Look at the shape of the curve, not only the final number: flat or falling stretches show when the rule struggled.
Traps that make backtests look better than reality
Overfitting is the biggest trap: tuning parameters until the past looks great, so the rule fits old noise rather than a lasting pattern. Look-ahead bias means using data that was not available at the time, such as trading at today's close on a signal that needs today's close to calculate. Survivorship bias comes from testing only on stocks in today's F&O list, ignoring those that were dropped.
Costs matter more than most people expect. Brokerage, exchange charges, GST, stamp duty and STT all reduce results; from 1 April 2026, STT on futures is 0.05% of the sell-side value and on options 0.15% of the premium on the sell side. Slippage, the gap between the expected and actual fill price, adds more. A few dozen trades is also a small sample. Testing on a period the rule was not built on, called out-of-sample testing, is a basic check.
How traders use it
Traders use backtests to reject weak ideas cheaply, to see how deep and long a rule's drawdowns were, and to compare versions of a rule on the same data. Even a careful backtest only shows past behaviour. Markets change, so many traders test across different years and conditions and treat results as a range of possibilities, not a forecast.
Frequently asked questions
What is backtesting in trading in simple words?
Backtesting means checking how a trading rule would have done if it had been followed in the past. You write exact entry and exit rules, run them on historical prices and study the trades, profit or loss and drawdowns. Past results do not predict future results.
What is overfitting in backtesting?
Overfitting is adjusting a rule until it looks excellent on past data, so it captures random noise instead of a real pattern. Such rules often do much worse on new data. Using few parameters and testing on an unseen period helps reveal it.
Is backtesting reliable?
It is useful but limited. A backtest is only as good as its data, its cost assumptions and its freedom from biases such as look-ahead and survivorship. Even a clean backtest shows past behaviour, and future markets may be different.
How many trades are enough for a backtest?
There is no fixed number, but a handful of trades says very little, because a few lucky wins can dominate. More trades across different market phases, such as rising, falling and sideways years, give a more stable picture of how the rule behaves.
Can I backtest options strategies on NIFTY?
Yes, if you have historical option prices for each strike and expiry. Options backtests need care with premiums that actually traded, bid-ask spreads, expiry handling and margin. Quantsapp's backtesting tool lets you test NIFTY strategies on historical data.
Related terms
Go deeper
For education only; not investment advice. Live figures from NSE via Quantsapp. Derivatives trading carries substantial risk. Disclaimer