Skip to main content

Strategy library · Trend following

Moving average crossover: the trend system most traders test first

By Anoop Thomas · Last updated

In short

A moving average crossover strategy buys when a shorter moving average crosses above a longer one, for example the 20-day EMA above the 50-day EMA, and exits or reverses when it crosses back below. It is a trend-following system: it aims to catch long moves and accepts many small losses in sideways markets along the way. Common pairs on NSE daily charts are 20/50 and 50/200.

Almost every trader’s first backtest is a moving average crossover, and it is a fine place to start because the rules leave no room for interpretation. Fast average crosses above slow: buy. Crosses below: sell. The averages lag price, so you will always be late into a trend and late out of it. The bet is that the trends you catch are long enough to pay for the whipsaws you sit through.

It suits patient traders working off daily charts with a basket of stocks. It doesn’t suit anyone who needs to be right on most trades, because a crossover system can be wrong far more often than right and still be worth running if the winners are big enough. Whether yours is, you only learn by testing.

The rules, step by step

A sensible starting template, not a proven system. Change any number, then test it before trusting it.

  1. 1

    Setup

    Daily candles. A fixed universe, for example Nifty 100 stocks, or Nifty itself. Fast average: 20-day EMA. Slow average: 50-day EMA.

  2. 2

    Entry

    Buy at the next day’s open after a daily close where the 20 EMA crosses above the 50 EMA.

  3. 3

    Stop-loss

    Initial stop 2 × ATR(14) below the entry price. It stays where it is until the exit signal; never widen it.

  4. 4

    Exit

    Sell at the next open after the 20 EMA closes below the 50 EMA, or when the stop is hit, whichever comes first.

  5. 5

    Position sizing

    Risk 1% of capital per position: quantity = (capital × 1%) ÷ (2 × ATR). Cap any single stock at 20% of capital and hold at most 8 positions.

  6. 6

    Filters

    Optional: take new longs only when Nifty is above its 200-day average. Test with and without it.

Say it in plain English

Paste this into INDfolio’s AI strategy builder and it becomes a backtestable strategy.

On daily candles for Nifty 100 stocks, buy at the next open when the 20-day EMA crosses above the 50-day EMA. Set the initial stop at 2 times the 14-day ATR below entry. Sell at the next open when the 20-day EMA crosses back below the 50-day EMA or the stop is hit. Risk 1% of capital per trade with at most 8 positions, and only take new longs when Nifty is above its 200-day average.
Backtest this free

Free plan · no card · NSE data included

One hypothetical crossover trade, sized with ATR

A stock at ₹1,000 has just closed with its 20 EMA above its 50 EMA. Its 14-day ATR is ₹25 (hypothetical). Capital is ₹5 lakh and you risk 1% per trade.

Item Value Working
Risk per trade₹5,0001% of ₹5,00,000
Stop distance₹502 × ATR of ₹25
Entry / stop₹1,000 / ₹950Entry minus stop distance
Quantity100 shares5,000 ÷ 50
Position value₹1,00,00020% of capital, right at the cap
Exit on reverse cross at ₹1,100+₹10,000 gross100 × ₹100
Delivery charges, round tripabout ₹250STT 0.1% on each side (₹210), stamp duty, exchange charges, GST, one DP charge

Hypothetical numbers to show sizing arithmetic, not a backtest or a typical outcome. Charges use NSE delivery rates as of September 2026 and a ₹15.34 DP charge (Zerodha’s rate); yours may differ. Try your own inputs in the position size calculator.

Which averages? It matters less than you’d think

People spend weeks choosing between 20/50, 21/55 and 50/200. Neighbouring pairs are built from nearly the same prices, so they should produce similar trade lists, and that is the useful test: if 20/50 looks brilliant and 22/50 looks terrible, neither result means much. An EMA crossover reacts faster than an SMA one. The 50/200 SMA pair, the “golden cross”, trades rarely and holds for long stretches.

Pick a sensible pair, then spend your time on exits and sizing. That is where I’d put the effort.

Sideways markets are the cost of doing business

A crossover system’s worst stretch is a market that goes nowhere in a wide range. The averages cross back and forth, each cross is a small loss plus costs, and months can pass with nothing to show. You can’t filter this away completely. A trend filter (Nifty above its 200-day), a minimum gap between the averages, or a longer slow average all reduce whipsaws, and every one of them also makes you later into real trends.

Intraday crossovers on 5- or 15-minute charts are a different animal: more signals, smaller moves, and costs that weigh far more per trade. If you go that way, test it as its own strategy with intraday charges, not as a scaled-down daily system.

What delivery trades cost

Delivery trades pay 0.1% STT on both the buy and the sell, stamp duty of 0.015% on the buy, exchange charges, and a DP charge each time you sell a stock out of your demat. On the example’s ₹1 lakh in and ₹1.1 lakh out, that comes to about ₹250. Small against a ₹10,000 winner, but a system that whipsaws ten times on the same stock pays it ten times. Check your broker’s figures in the brokerage calculator.

How to test it so the result means something

Use daily data for the whole universe over at least seven or eight years, so the test includes at least one sharp fall and one long, dull sideways stretch. Use the stocks that were in the index at the time if you can; testing today’s Nifty 100 back several years quietly includes only the survivors. Ask any platform, including us, how it handles index membership over time.

Vary the fast and slow lengths across a grid and look at the whole map, not the best cell. Check how much of the total profit came from the top five trades; if removing them wipes out the result, you are depending on a few outliers. Then use walk-forward analysis so the parameters you would trade were chosen without seeing the period they are tested on.

You can describe this rule set in plain English to INDfolio’s AI strategy builder and backtest it on NSE data with costs deducted (we build it, so weigh that accordingly).

Educational content, not investment advice. The rules and numbers on this page are an illustrative template, not a backtest result or a recommendation. Derivatives carry a high risk of loss — SEBI’s own studies of F&O traders found that the large majority of individuals lose money. We build INDfolio AI, so weigh our view accordingly.

FAQ

Frequently asked questions

Which moving average crossover is best for intraday?

There isn’t a best pair. A 9/21 EMA on 5- or 15-minute charts is a common starting point, but costs and slippage weigh much more intraday, so test with realistic charges before choosing.

Should I use EMA or SMA for a crossover strategy?

An EMA reacts faster and gives earlier, more frequent signals; an SMA is slower with fewer trades. Test both on the same data and see whether the difference is larger than the variation between neighbouring settings.

Is the golden cross a reliable buy signal?

The 50/200 golden cross is slow and rare on any one stock, so a single stock’s history gives you very few trades to judge it by. Test it on a basket over a long history before relying on it.

Why does my crossover strategy lose money in sideways markets?

Because the averages keep crossing as price oscillates, producing a small loss plus costs on each swing. A trend filter or a minimum distance between the averages reduces this, at the cost of later entries.

Can I use a moving average crossover to trade Nifty options?

The signal can come from Nifty’s chart while the trade uses options, for example a bull call spread. Test the signal on the index first; options add time decay and strike choice on top.

Describe your strategy. Backtest it in minutes.

Start on the free plan — AI strategy builder and NSE backtesting included, no card required.

Free · No card

Create your account

By continuing you agree to our Terms and Privacy Policy.