Algo trading lesson: 200-day moving average trend filter backtest on Nifty 50 (data to 12 Nov 2026)

12 Nov 2026 · built from NSE and BSE data by Stocks Glance

We tested the 200-day moving average trend filter on the Nifty 50 from 27 Oct 2016 to 12 Nov 2026: 6.55% a year against 11.38% for simply holding the index, with a worst fall of -19.98% against -38.44%.

The rule

Hold the index while it closes above its 200-day simple moving average; move to cash when it closes below. The signal uses the closing price, and the position changes from the next day, so the test never uses information it could not have had.

Results on Nifty 50 (27 Oct 2016 to 12 Nov 2026)

MeasureStrategyBuy and hold
Annual return (CAGR)6.55%11.38%
Worst fall from a peak (max drawdown)-19.98%-38.44%
₹1 lakh became₹1,88,551.95₹2,93,657.76
Time invested75.80%100%
Number of trades411
Trades that made money21.95%—

Year by year

YearStrategyBuy and hold
2016-8.75%-4.98%
2017+26.59%+28.65%
2018-5.93%+3.15%
2019+3.90%+12.02%
2020+23.09%+14.90%
2021+24.12%+24.12%
2022-9.26%+4.33%
2023+16.21%+20.03%
2024+6.84%+8.80%
2025+0.64%+10.51%
2026-3.60%-3.18%

What this test leaves out

  • Costs: no brokerage, STT, exchange charges, GST, stamp duty or slippage. Rules that trade often lose more to costs than this table shows.
  • Taxes: every exit can create a short-term capital gain.
  • Index, not a fund: you cannot buy the index itself; index funds and ETFs track it with small errors and charge fees.
  • Dividends: the price index excludes dividends, which slightly understates buy and hold.
  • Hindsight: a rule chosen after looking at the past tends to look better than it will in future. This is called overfitting.

How algo trading works in India

Retail investors run rule-based strategies through their broker's platform or API, under rules set by SEBI. A backtest like this one is the first step a quant researcher takes, not proof that a strategy works. Learn the building blocks in trends and moving averages, RSI explained and risk management and stop-loss.

More in algo trading course

All algo trading course lessons and posts →