OPEN-SOURCE SCRIPT
Supply & Demand Zone Detector

Automatically detects and marks Supply & Demand zones using price-action structure, rather than fixed pivot lookbacks.
How it works: the script flags a "breakout" candle when its range exceeds a multiple of ATR and its body makes up most of that range (a strong, low-wick move). It then scans backward for the tight consolidation ("base") immediately preceding that candle — candles whose range stays below a smaller ATR multiple. The high/low envelope of that base becomes the zone: a bullish breakout marks Demand, a bearish breakout marks Supply.
Each zone tracks its own state: it draws solid while fresh, and the first time price trades back into it, the zone is marked tested (dashed, faded) and an alert fires. If price later closes cleanly through the far side, the zone is invalidated and removed — so the chart only shows zones that are still structurally valid.
Inputs: ATR length, breakout/base ATR multipliers, max base candles to scan, optional max zone width (in points), max zones kept on chart.
Limitations: this version detects and manages zones only — it does not generate buy/sell entries. [Zone-touch alerts are provided for you to build your own entry rules around.]
How it works: the script flags a "breakout" candle when its range exceeds a multiple of ATR and its body makes up most of that range (a strong, low-wick move). It then scans backward for the tight consolidation ("base") immediately preceding that candle — candles whose range stays below a smaller ATR multiple. The high/low envelope of that base becomes the zone: a bullish breakout marks Demand, a bearish breakout marks Supply.
Each zone tracks its own state: it draws solid while fresh, and the first time price trades back into it, the zone is marked tested (dashed, faded) and an alert fires. If price later closes cleanly through the far side, the zone is invalidated and removed — so the chart only shows zones that are still structurally valid.
Inputs: ATR length, breakout/base ATR multipliers, max base candles to scan, optional max zone width (in points), max zones kept on chart.
Limitations: this version detects and manages zones only — it does not generate buy/sell entries. [Zone-touch alerts are provided for you to build your own entry rules around.]
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que cualquier republicación del código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que cualquier republicación del código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.