Editors' picks
OPEN-SOURCE SCRIPT

Smart NR2-NR20 and Inside Bar (Zeiierman)

19 568
Overview
Smart NR2–NR20 + Inside Bar (Zeiierman) is a compression + breakout scanner that searches for the tightest Narrow Range (NR) condition across NR2…NR20, plus optional Inside Bar detection. When a valid compression forms, it draws a box around the setup, projects the high/low levels forward, and triggers on the first breakout. Optional Trend Filter logic can restrict triggers to trend-aligned breakouts, and optional Exit markers can annotate TP / SL / Time exits after a trigger.
snapshot
🔘 What It Detects
The Smart Narrow Range (NR2…NR20) script continuously checks NR lengths from 2 to 20 and selects the most extreme contraction (tightest relative range vs history) inside the current Look Back window, highlighting the strongest “compression” zones where expansion risk is building. Optionally, it can also treat an Inside Bar as a valid compression trigger.

How It Works

1) Compression Scan (NR Ranking Engine)
For each bar, the script evaluates NR2…NR20:
  • It calculates the N-bar range (highest high − lowest low).
  • It compares that range to prior N-bar ranges over Look Back.
  • It ranks candidates by “tightness” and keeps the strongest one.

Key effect:
  • Higher Look Back = fewer but higher-quality compressions
  • Lower Look Back = more frequent compressions

2) Adaptive Look Back (Static or ADX-Adaptive)
Look Back can be:
  • Static: fixed comparison window
  • ADX Adaptive: Look Back dynamically shifts between LB Min and LB Max depending on trend strength

Conceptually:
  • Higher ADX (strong trend) — shorter Look Back (more responsive)
  • Lower ADX (chop/range) — longer Look Back (more selective)

How to Use

Bullish Setup
  • Wait for a tight range to form
  • Enter on a breakout above the range high
  • Stop below the opposite side of the range
  • Target a multiple of the range size or trail with momentum
  • Optional: wait for a small breakout retest before entering

snapshot
Bearish Setup
  • Wait for a tight range to form
  • Enter on breakout below the range low
  • Stop above the opposite side of the range
  • Target a multiple of the range size or trail with weakness
  • Optional: enter on breakdown retest

snapshot
Settings
  • Enable Inside Bar — toggles Inside Bar detection.
  • Look Back (compare window) — history window used to judge contraction quality.
  • Enable Trend Filter — gates long/short triggers relative to Trend MA.
  • Show Trend MA — plots the Trend MA on chart.
  • Trend MA Mode — Static or NR-Adaptive (length follows Look Back × multiplier).
  • MA Type — EMA or RMA smoothing for the Trend MA.
  • NR — MA Multiplier — scales adaptive MA length from Look Back.
  • Static MA Length — used when Trend MA Mode is Static.
  • Look Back Mode — Static or ADX Adaptive.
  • ADX Length / ADX Low / ADX High — controls adaptive response to trend strength.
  • LB Min / LB Max — bounds for adaptive Look Back range.


-----------------
Disclaimer

The content provided in my scripts, indicators, ideas, algorithms, and systems is for educational and informational purposes only. It does not constitute financial advice, investment recommendations, or a solicitation to buy or sell any financial instruments. I will not accept liability for any loss or damage, including without limitation any loss of profit, which may arise directly or indirectly from the use of or reliance on such information.

All investments involve risk, and the past performance of a security, industry, sector, market, financial product, trading strategy, backtest, or individual's trading does not guarantee future results or returns. Investors are fully responsible for any investment decisions they make. Such decisions should be based solely on an evaluation of their financial circumstances, investment objectives, risk tolerance, and liquidity needs.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.