DalalAI Blog

How To Backtest a Trading Strategy on Indian Stocks (NSE)

By DalalAI Research · Updated March 2026

A practical guide to strategy backtesting for NSE-listed stocks — what to measure, which biases to eliminate, and how to tell if your strategy actually works.

📖 6 min read · Updated 27 March 2026

Every trader has a strategy idea. Few test it properly before committing real capital. Backtesting is the process of applying a trading rule to historical data to see how it would have performed. Done correctly, it saves you from strategies that look good in hindsight but fail in live markets. Done carelessly, it gives you false confidence in overfitted rules that break on new data.

📌 Backtesting Essentials at a Glance

Must include
Transaction Costs
Brokerage, STT, slippage, and impact cost for NSE trades
Must include
Survivorship Bias Fix
Include delisted companies to avoid inflated returns
Must include
Out-of-Sample Test
Validate on data not used during strategy design
Critical metric
Max Drawdown
Worst peak-to-trough decline tells you the real pain

What backtesting actually means

Backtesting simulates how a trading strategy would have performed using historical price and volume data. You define entry rules, exit rules, and position sizing, then run them against past data. The output is a set of metrics — return, drawdown, win rate, risk-adjusted return — that help you evaluate the strategy before committing capital.

The key insight: backtesting does not predict future performance. It validates whether a strategy had a systematic edge in the past. The gap between past simulation and future live results is where most traders lose money.

Why backtesting on Indian data is different

Indian markets have specific characteristics that make backtesting harder than in developed markets. Circuit limits halt trading when stocks hit upper or lower circuits — your backtest might assume you could sell at a certain price, but in reality no buyer was available at circuit. Delivery percentage matters because T+1 settlement affects position management. Liquidity varies widely across the 500+ actively traded NSE stocks, so strategies that work on large-caps may not execute properly on mid-caps.

Additionally, India has specific costs: Securities Transaction Tax (STT), GST on brokerage, stamp duty, and exchange charges. These vary by trade type (delivery vs. intraday). A backtest that ignores these costs will show inflated returns.

The biases that kill backtests

Survivorship bias is the most common. If your backtest universe only includes currently listed stocks, you miss all the companies that were delisted, merged, or went bankrupt. This inflates returns because you're testing only on survivors.

Look-ahead bias happens when your strategy uses data that wasn't available at the time of the simulated decision. Quarterly results might be in your dataset dated to the quarter end, but they were actually published weeks later.

Overfitting occurs when you tune too many parameters to match historical data. A strategy with 12 tuned parameters that "works perfectly" on 3 years of data will almost certainly fail on new data. Simpler rules generalize better.

Key metrics to evaluate a backtest

MetricWhat it measuresWhat to look for
CAGRCompound annual growth rateCompare to Nifty 50 benchmark
Max DrawdownWorst peak-to-trough decline< 25% for most retail strategies
Sharpe RatioRisk-adjusted return> 1.0 is decent; > 1.5 is good
Win Rate% of trades that were profitableContext-dependent; 40% can work with high reward:risk
Profit FactorGross profit ÷ gross loss> 1.5 is healthy
Trade CountTotal number of tradesNeeds enough trades for statistical significance (30+)

Building a backtesting workflow

A sound backtesting workflow has three phases. First, hypothesis formation — you define why your strategy should work based on market structure, not just pattern matching. Second, in-sample testing — you run the strategy on a portion of your data (typically 60-70%) to calibrate parameters. Third, out-of-sample validation — you test on the remaining data that was not used during design. Only if performance holds in out-of-sample data should you consider live trading.

Many traders skip the third step and go straight from optimization to live capital. This is where most money is lost. The out-of-sample test is the most important step in the entire process.

From backtest to live: the validation gap

Even a robust backtest will perform differently in live markets. Slippage, partial fills, and changing market conditions create a gap between simulated and real returns. The best approach is incremental deployment: start with small position sizes, track live performance against the backtest for several months, and scale up only if the live results match the simulation within expected variance.

❓ FAQ

Can I backtest trading strategies on Indian stocks for free?

DalalAI provides backtesting tools that let you validate strategies against NSE historical data. The free tier covers basic backtests with standard metrics and bias correction.

How many years of data do I need for a reliable backtest?

A minimum of 5 years covering different market conditions (bull, bear, sideways) is recommended. For strategies with fewer trades, longer periods provide more statistical confidence.

What is the most common backtesting mistake?

Overfitting — tuning too many parameters on historical data until the results look perfect. These over-optimized strategies almost always fail in live markets. Keep rules simple and validate on data not used during design.

Try DalalAI Free — Backtest Your Strategies →

📚 Related Reading

Algo Trading in India — Complete Guide to Automated Trading on NSE/BSE — algo trading
Best Paper Trading App for India (2026) — Practice Without Risk — paper trading
Machine Learning for Stock Market in India — Practical Guide for Quant Traders — ML for trading
📬

Get Free Daily Stock Picks

AI-curated top picks, market regime, and accuracy report — every market morning.

Found this useful? Share it 𝕏 Post LinkedIn WhatsApp 🔗 Copy Link

← All Posts | Stock Screener | AI Copilot