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.]
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.