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
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
Entry
Buy at the next day’s open after a daily close where the 20 EMA crosses above the 50 EMA.
- 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
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
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
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,000 | 1% of ₹5,00,000 |
| Stop distance | ₹50 | 2 × ATR of ₹25 |
| Entry / stop | ₹1,000 / ₹950 | Entry minus stop distance |
| Quantity | 100 shares | 5,000 ÷ 50 |
| Position value | ₹1,00,000 | 20% of capital, right at the cap |
| Exit on reverse cross at ₹1,100 | +₹10,000 gross | 100 × ₹100 |
| Delivery charges, round trip | about ₹250 | STT 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.
More from the strategy library
All strategies →Trend following
Supertrend
Go long when price closes above the Supertrend line, exit or flip when it closes below. The line doubles as a trailing stop.
Options income
Short Straddle
Sell the ATM call and put, collect both premiums, lose if Nifty moves too far. Includes the 9:20 am straddle rules.
Options income
Short Strangle
Sell an out-of-the-money call and put. Wider breakevens than a straddle, a smaller credit, and the same unlimited loss on a big move.
Options income
Iron Condor
A short strangle with protective wings: a smaller credit, a defined maximum loss and far lower margin. Four legs means four sets of costs.
Options directional
Bull Call Spread
Buy a call and sell a higher-strike call. Cheaper than a naked call, with profit and loss both capped. Needs a directional view.
Options income
Covered Call
Hold a full lot of an F&O stock and sell an out-of-the-money call against it each month. Premium in, upside capped, downside unchanged.