Backtesting is the process of applying your trading rules to historical price data to see how the strategy would have performed in the past.
It is not a guarantee of future performance. But a strategy that has never been tested against historical data has no evidence-based reason to expect future profit either. Backtesting converts a market opinion into a testable hypothesis.
Why Backtesting Matters for Indian Traders
Most retail traders in India develop their strategies the wrong way: they find a pattern that worked in a recent trade, they trade it repeatedly without testing it systematically, and then they wonder why the results are inconsistent.
The fundamental problem is confirmation bias — the tendency to remember trades where the pattern worked and dismiss trades where it failed. Backtesting forces you to count every instance, winners and losers alike.
The Indian market has unique characteristics that make backtesting specifically important here: weekly F&O expiry effects, strong operator activity in midcaps, FII/DII flow patterns around budget and monetary policy events, and circuit breakers that can trap positions. A strategy backtested on US market data may not behave the same way on NSE.
Where to Get NSE Historical Data
- NSE website (nseindia.com): Historical OHLCV data for Nifty, BankNifty, and individual stocks is available for free under the "Historical Data" section. Download to CSV.
- BSE (bseindia.com): Similar free downloads.
- Broker platforms: Zerodha's Kite, Upstox Pro, and Fyers all provide historical data via their APIs — useful for software-based backtesting.
- Paid data vendors: Amibroker with EOD data subscription, NinjaTrader feeds, or Opserver for high-quality tick data.
For daily-chart strategies, NSE's free downloads are sufficient. For intraday strategies, you need minute-level data which typically requires a broker API or paid vendor.
Manual vs Software Backtesting
Manual backtesting means going through a chart historically — scrolling back in time — and recording every instance where your setup conditions appeared, then noting the outcome. This is slow but produces deep familiarity with how the pattern behaves in different market conditions.
For a chart-based strategy with 2–3 clear conditions, manually backtesting 200 trades over NSE historical charts is the right starting point. Zerodha's TradingView-based Kite charting allows you to scroll back.
Software backtesting (Amibroker, Python with pandas, TradingView Pine Script) is faster and allows parameter optimisation across thousands of historical bars. It is the appropriate approach once you have manually validated that the logic is correct and the conditions are unambiguous.
Begin manually. When the logic is clear enough to express in code without exceptions, move to software.
The Metrics That Matter
After running the backtest, assess these outputs:
Win rate: The percentage of trades that were profitable. Note: win rate alone tells you little without risk-reward context.
Expectancy: (Win rate × Average win) − (Loss rate × Average loss). This is the average amount earned or lost per rupee risked. A positive expectancy is the minimum requirement for a viable system.
Maximum drawdown: The largest peak-to-trough decline in the account balance during the test period. This tells you how much pain the system would ask you to endure before recovering. A system with 40% drawdown is mathematically viable but psychologically unusable for most traders.
Profit factor: Total gross profit divided by total gross loss. Above 1.5 is considered healthy. Below 1.0 means the system lost money overall.
Number of trades: A backtest of 15 trades is statistically meaningless. A minimum of 100 trades across different market conditions (trending, ranging, volatile) is required for the results to carry weight.
The Three Errors That Invalidate a Backtest
Overfitting (curve-fitting): Adjusting your rules repeatedly until they produce the best result on the historical data you have tested. The result will look spectacular in backtest and fail completely on new data, because the rules have been shaped to fit the past, not to capture a real edge.
The symptom: a strategy with 12 specific parameters that produces a 70% win rate on past data. Legitimate strategies tend to have simple, robust conditions that work across parameters, not at one precisely-tuned point.
Lookahead bias: Using information in the backtest that would not have been available at the time the trade was made. Example: if your strategy uses the closing price to decide whether to enter, and you also record the entry at that closing price — you have used tomorrow's close to enter at yesterday's price.
Survivorship bias: Testing your strategy only on companies that are currently listed — ignoring companies that were delisted, went bankrupt, or were suspended during the test period. This makes strategies look better than they are because you are only testing on the survivors.
Walk-Forward Validation
After backtesting on historical data, divide your data into two periods: the in-sample period (used to develop and test the strategy) and the out-of-sample period (data set aside from the start and never used during development).
Run the strategy on the out-of-sample period without any modifications. If performance degrades significantly in out-of-sample testing, the strategy was overfit to the in-sample period and is unlikely to work in live markets.
This split — typically 70% in-sample, 30% out-of-sample — is the minimum validation step before trading real capital.
For educational purposes only. Profitma is not a SEBI-registered investment adviser or research analyst. Nothing in this article constitutes investment advice.