Brig AI Labs Logo

NR7 Breakout Strategy for Nifty: Pine Script with Entry Rules and Backtesting

πŸ”Š

⚠️ Some language voices may not work on all phones or browsers.

What is the NR7 Strategy?

NR7 stands for the Narrowest Range in the Last 7 Candles. It identifies periods of low volatility, which often precede large price movements. The breakout from an NR7 bar can signal trend initiation or expansion, making it ideal for breakout traders and algo strategies.

How the Strategy Works

  • Scan the last 7 candles and identify the one with the narrowest high-low range
  • If the current candle is the NR7 bar, mark its high and low
  • Enter long when price breaks the high of the NR7 bar
  • Enter short when price breaks the low of the NR7 bar
  • Optional: Add filters like volume, time-of-day, or trend confirmation

Backtest-Ready Pine Script

//@version=5
strategy("NR7 Breakout Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)

length = 7
isNR7 = false
nr7BarIndex = na

range = high - low
minRange = ta.lowest(range, length)
isNR7 := range == minRange

// Store NR7 high/low from previous bar
nr7High = isNR7 ? high : na
nr7Low = isNR7 ? low : na
nr7High := nz(nr7High[1], high[1])
nr7Low := nz(nr7Low[1], low[1])

longEntry = ta.crossover(close, nr7High[1])
shortEntry = ta.crossunder(close, nr7Low[1])

strategy.entry("NR7 Long", strategy.long, when = longEntry)
strategy.entry("NR7 Short", strategy.short, when = shortEntry)

// Simple Exit
strategy.close("NR7 Long", when = ta.crossunder(close, nr7Low[1]))
strategy.close("NR7 Short", when = ta.crossover(close, nr7High[1]))

plotshape(isNR7, title="NR7 Bar", location=location.belowbar, color=color.orange, style=shape.circle, size=size.tiny)

Customization Tips

  • πŸ’‘ Add a time filter to exclude first 15 mins of trading (especially on indices)
  • πŸ“ˆ Use with volume filters or RSI divergence for smarter entries
  • πŸ” Combine with ATR for dynamic SL/TP setups
  • πŸ•΅οΈβ€β™‚οΈ Plot levels for visualization and alerts

Why It Works

Markets cycle between low and high volatility. NR7 helps algos catch the transition from contraction to expansion. It’s simple, logical, and easily backtestable.

Conclusion

The NR7 breakout system is a versatile entry model with an edge rooted in volatility psychology. Use it with confluence filters for better precision, and backtest rigorously before deployment.


This article is part of Brig Tech Labs' initiative to empower traders with actionable, transparent, and automation-ready strategy frameworks.

Author: Brig Quant Research Team

← Back to all posts