EMA Crossover Strategy Backtest on NIFTY Options
An EMA crossover strategy on NIFTY buys an ATM call when the 9-EMA crosses above the 21-EMA of spot, and an ATM put on the bearish cross, exiting on the opposite cross or a stop. Because it buys options (long premium), it is fully backtestable today in Algoshastra on real 5-minute historical data. This page explains the mechanics and how to test it yourself.
“Backtest a NIFTY intraday strategy: when the 9 EMA of spot crosses above the 21 EMA, buy 1 lot of the ATM call; when the 9 EMA crosses below the 21 EMA, buy 1 lot of the ATM put. Exit the open option on the opposite EMA crossover or a 30% stop loss on premium, and square off everything at 3:15pm. Use 5-minute bars.”
Backtest it freeWhat the EMA crossover strategy is
An exponential moving average (EMA) crossover is one of the most common trend-following signals in intraday trading. You plot two EMAs of NIFTY spot — a fast one (commonly 9 periods) and a slow one (commonly 21). When the fast EMA crosses above the slow EMA, momentum is turning up; when it crosses below, momentum is turning down.
In the options version covered here, the crossover is the trigger and you express the view by buying an at-the-money (ATM) option: a bullish 9/21 cross means buy the ATM call, a bearish cross means buy the ATM put. You hold until the opposite crossover prints or a stop is hit, and the position is squared off intraday. Because you are always buying (paying premium, never selling to open), your risk on any single trade is capped at the premium paid.
- Fast EMA (e.g. 9) crosses above slow EMA (e.g. 21) on NIFTY spot, buy the ATM call.
- Fast EMA crosses below slow EMA, buy the ATM put.
- Exit on the opposite crossover or a premium-based stop loss.
- Intraday square-off at 3:15pm IST so nothing is carried overnight.
- NIFTY lot size is 75; this is a long-option (debit) strategy, so loss per trade is limited to premium paid.
Why traders use EMA crossovers
The appeal is simplicity and objectivity. A crossover is unambiguous — either the fast EMA is above the slow one or it isn't — so the entry and exit are rule-based rather than discretionary. EMAs also weight recent prices more heavily than a simple moving average, so they react faster to a turn, which matters on a 5-minute intraday chart.
The trade-off is well known: crossover systems tend to do well when NIFTY trends cleanly in one direction and tend to get chopped up (repeated small losses from false crossovers) when the index is range-bound. That is exactly the kind of behaviour a backtest is meant to reveal, rather than something you should assume. This is general information about how the signal works, not a recommendation to trade it.
How to backtest it on NIFTY in Algoshastra
Algoshastra lets you describe the strategy in plain English and have Shastra write and backtest it for you. Because this is a long-option strategy (you are buying calls and puts), it is fully supported by the backtester today — you get a run on real historical 5-minute options bars with brokerage, STT and slippage modelled and an intraday 3:15pm square-off.
Paste the prompt from the box on this page into Shastra. It will translate the EMA crossover logic into a runnable strategy, pick the ATM strike using the position-aware rolling-ATM feed, and produce a backtest you can inspect and then export to run on your own broker. Change the EMA lengths or stop and re-run to compare — the whole loop is free.
Methodology: what the backtest actually models
Understanding the engine helps you read the result honestly. Algoshastra's backtester is a rolling-ATM sandbox: it follows the at-the-money strike as spot moves and prices your option from real historical 5-minute bars. It applies brokerage, STT and a slippage assumption, and it forces an intraday square-off at 3:15pm IST so no position is held overnight.
This is a showcase-grade simulation, not a tick-by-tick replay of every fill you would have gotten live. Liquidity, exact fill price, and fast-market gaps are approximated, so treat the output as a behavioural sketch of the strategy, not a promise of what the same rules would have earned.
How to read the result honestly
Resist the urge to fixate on a single headline number. A more useful reading looks at the distribution and the shape of performance. Was the win rate clustered in trending days and the losses in choppy days? How deep and how long were the drawdowns? Did a handful of trades drive most of the outcome, or was it broad-based?
Run sensitivity checks: swap 9/21 for 5/20 or 10/30, widen or tighten the stop, and see whether the behaviour holds or falls apart. A strategy whose results swing wildly on small parameter changes is fragile. Whatever you see is a property of one historical sample under the sandbox's assumptions — it is not predictive, and past behaviour is not indicative of future results. After backtesting, export the verified strategy to run on your own broker before drawing any conclusions.
- Win rate by regime: trend days versus chop days, not just the overall figure.
- Drawdown shape: depth, duration, and how it recovered.
- Trade dispersion: was the outcome broad-based or driven by a few trades?
- Parameter robustness: does behaviour survive small changes to EMA lengths and stops?
Limitations and honest framing
Algoshastra is a strategy-verification platform. It is not SEBI-registered and offers no live-money trading. Nothing here is investment advice or a recommendation to buy or sell any option, and no return or outcome is promised or implied.
Even a clean-looking backtest carries model risk: it reflects one historical period, the rolling-ATM sandbox assumptions, and approximated fills on 5-minute bars. Use it to understand how the EMA crossover behaves, not as a forecast. If you want to explore other structures, the related strategy pages and the free payoff tools below are good next steps.
- Backtests run in a rolling-ATM sandbox that follows the at-the-money strike as spot moves — it is showcase-grade, not a tick-by-tick replay of real fills.
- Pricing uses real historical 5-minute bars; intrabar movement, exact fills and fast-market gaps are approximated.
- Brokerage, STT and a slippage assumption are modelled, but real-world costs and liquidity can differ from the simulation.
- Algoshastra is a strategy-verification platform, not SEBI-registered, with no live-money trading.
- Results reflect one historical sample and period — past behaviour is not indicative of future results, and outcomes are sensitive to the parameters and dates you choose.
Describe it in plain English — Shastra builds and backtests it on real historical data, then you export it to your own broker. Free to start.