The 5 10 20 strategy is a short-only trend system for Nifty. You go short when both the 5-day and 10-day exponential moving averages (EMA) cross below the 20-day EMA, and cover when both cross back above it. We first posted it in January 2009, after Nifty’s steep fall in 2008, and this update explains the rules, adds AmiBroker code and covers where the system works and where it fails.
Key takeaways
- Entry: short at the day’s close once both the 5 and 10 EMA are below the 20 EMA.
- Exit: cover at the day’s high once both the 5 and 10 EMA are back above the 20 EMA. Using the high is a deliberately conservative fill.
- Requiring two fast averages to agree filters some false signals, at the cost of later entries.
- Short-only trend systems shine in falling markets like 2008 and bleed through choppy or rising markets.
- Backtest on your own data with costs before trading it, and trade it through Nifty futures or options, since a short sale in the cash market must be squared off the same day.
The 5 10 20 strategy rules
Here are the rules exactly as we posted them in 2009:
The Nifty chart below showed the 5-10-20 EMA movement over 2008. In that bear year the results looked very good, because the averages stayed stacked below the 20 EMA for long stretches.

How the 5 10 20 strategy works
An exponential moving average gives more weight to recent prices than a simple average, so it reacts faster. The 5 EMA tracks the last week of trading, the 10 EMA about two weeks, and the 20 EMA about a month.
- When both short averages fall below the 20 EMA, the last one to two weeks of prices are weaker than the last month. That is the start of a short-term downtrend.
- Waiting for both the 5 and 10 EMA, rather than the 5 EMA alone, cuts the number of whipsaws on one-day dips.
- The exit needs both averages back above the 20 EMA, which lets a down move run until the trend has clearly turned.
If you want to see how these averages behave, read our notes on visualizing the 20-day EMA and on Nifty falling below its 5 EMA.
AmiBroker AFL code for the 5 10 20 strategy
// 5 10 20 EMA short only strategy - marketcalls.in
SetTradeDelays(0, 0, 0, 0);
SetPositionSize(1, spsShares);
e5 = EMA(Close, 5);
e10 = EMA(Close, 10);
e20 = EMA(Close, 20);
bothBelow = e5 < e20 AND e10 < e20;
bothAbove = e5 > e20 AND e10 > e20;
Short = bothBelow AND NOT Ref(bothBelow, -1);
Cover = bothAbove AND NOT Ref(bothAbove, -1);
Buy = Sell = 0;
Short = ExRem(Short, Cover);
Cover = ExRem(Cover, Short);
ShortPrice = Close;
CoverPrice = High;
Plot(Close, "Close", colorDefault, styleCandle);
Plot(e5, "EMA 5", colorRed);
Plot(e10, "EMA 10", colorOrange);
Plot(e20, "EMA 20", colorBlue, styleThick);
PlotShapes(Short * shapeDownArrow, colorRed, 0, High, -12);
PlotShapes(Cover * shapeUpArrow, colorGreen, 0, Low, -12);
Code explained line by line
SetTradeDelays(0, 0, 0, 0)trades on the signal bar itself, which matches “short at today’s close”.SetPositionSize(1, spsShares)trades one unit so the backtest shows points captured. Change this to your lot size.e5,e10ande20are the three exponential moving averages of the close.bothBelowandbothAbovecheck whether both fast averages are on the same side of the 20 EMA.Shortfires on the first bar wherebothBelowbecomes true.Coverfires on the first bar wherebothAbovebecomes true.Buy = Sell = 0makes the system short only.ExRemremoves repeated signals so each short has one matching cover (see the AmiBroker ExRem reference).ShortPrice = CloseandCoverPrice = Highapply the original fills: enter at the close, exit at the high.- The
PlotandPlotShapeslines draw the candles, the three EMAs and red and green arrows at signals.
How to run it in AmiBroker
- Open the Formula Editor, paste the code and save it as 5-10-20 Short.afl.
- Apply it to a Nifty or Nifty futures daily chart to see the arrows.
- Open the Analysis window, pick the formula, set the range and click Backtest.
- In Settings, add brokerage and slippage and set the futures lot size before you trust the result.
For traders: where this system fails
- In a sideways market, the averages tangle and the system shorts into every small dip, then covers at the high.
- In a strong bull market it sits out or takes small losses, so it should be paired with a long system or a trend filter.
- Covering at the day’s high is a worst-case fill. If your backtest uses the close, results will look better than real trading.
- Treat it as one part of a rule set, as we describe in the trading strategies Marketcalls follows.
Frequently Asked Questions
What is the 5 10 20 strategy?
It is a short-only moving average system. You short when both the 5 and 10-day EMA move below the 20-day EMA and cover when both move back above it.
Can I use these rules for buying?
You can mirror the rules for longs, buying when both fast EMAs move above the 20 EMA. Test the long side separately, because markets rise and fall in different ways.
Which timeframe works best?
The original rules use daily bars on Nifty. The same logic runs on hourly charts, but signals become more frequent and costs matter more.
Why cover at the day’s high?
It assumes the worst exit price of the day, which keeps backtest results honest. In live trading you can cover at the close or the next open instead.
Learn by watching: free videos every week
Market Profile, order flow, Python, AI and OpenAlgo tutorials on YouTube.


Rajandran Sir,
I feel this strategy worked well in down trending market and can be used in opposite way in up trending market.
Need your comment on this.
Sachin Pethe
Yeah Sachin, in the uptrending market the reverse procedure suits for Long trades
Sir,
I feel this is a lagging indicator and misses half of the move. More effective after a sideways move and not after a big fall or big upmove , do u agree.?
Please advise
YEH EMA is a lagging indictor.But still i feel we can make safer strategies using EMA.