OPEN-SOURCE SCRIPT
Supply and Demand Zones [Clean v6]

Supply and Demand Zones [Clean v6]
Overview
The Supply and Demand Zones [Clean v6] indicator is an automated market structure tool designed to identify high-probability Points of Interest (POI) on any asset or timeframe. Built using Pine Script v6, this script focuses on clarity and performance, providing traders with a clutter-free view of where institutional buying and selling pressure has previously occurred.
Unlike crowded indicators that overwhelm the chart, this script dynamically manages zones—drawing new ones as structure forms and automatically removing invalid zones as price breaks through them.
Key Features
Automated Zone Detection: Automatically identifies Supply (Resistance) and Demand (Support) zones based on Swing Highs and Swing Lows.
Dynamic Zone Management: Active zones extend to the right until price interacts with them.
Break of Structure (BOS) Logic: When price violates a zone (closes beyond the invalidation level), the zone is automatically removed and marked as "Broken" to keep the chart clean.
Zig Zag Structure: Includes an optional Zig Zag overlay to visualize market flow, Higher Highs, and Lower Lows.
ATR-Based Sizing: Zone width is calculated using the Average True Range (ATR), ensuring zones adapt to the asset's current volatility.
Pine Script v6: Optimized using the latest array and method functions for speed and stability.
How It Works
Zone Creation: The script looks for Pivot Highs and Lows based on your defined Swing Length.
Supply Zones (Red): Created at Swing Highs.
Demand Zones (Blue): Created at Swing Lows.
Zone Width: The height of the box is determined by the ATR multiplied by your Zone Width setting. This ensures the zone covers the "wick" area or the volatility range of the pivot.
Invalidation: If the price closes past the outer edge of a zone (the top of a Supply zone or bottom of a Demand zone), the script detects a break, removes the filled box, and leaves a subtle trace of the broken structure.
How to Use
Trend Following: Use the Zig Zag lines to identify the trend direction. Look for Long entries in Demand zones during an uptrend, and Short entries in Supply zones during a downtrend.
Reversals: Watch for price to react at older, unfilled zones (POIs) that align with major support/resistance levels.
Stop Loss Placement: The outer edge of the zone acts as a natural invalidation point. If price closes beyond it, the setup is typically invalidated.
Settings Guide
Swing Length: Determines the sensitivity of the pivot detection. Lower numbers find more local zones (scalping); higher numbers find major structural zones (swing trading).
Max Zones to Keep: Limits the number of historic zones displayed to prevent chart clutter.
Zone Width (ATR): Adjusts how thick the zones are. Increase this value if you want to capture wider wicks.
Visual Settings: Fully customizable colors for Supply, Demand, Borders, and Zig Zag lines.
Disclaimer
This tool is for informational and educational purposes only. It visualizes past price action and does not guarantee future performance. Always manage your risk appropriately.
Overview
The Supply and Demand Zones [Clean v6] indicator is an automated market structure tool designed to identify high-probability Points of Interest (POI) on any asset or timeframe. Built using Pine Script v6, this script focuses on clarity and performance, providing traders with a clutter-free view of where institutional buying and selling pressure has previously occurred.
Unlike crowded indicators that overwhelm the chart, this script dynamically manages zones—drawing new ones as structure forms and automatically removing invalid zones as price breaks through them.
Key Features
Automated Zone Detection: Automatically identifies Supply (Resistance) and Demand (Support) zones based on Swing Highs and Swing Lows.
Dynamic Zone Management: Active zones extend to the right until price interacts with them.
Break of Structure (BOS) Logic: When price violates a zone (closes beyond the invalidation level), the zone is automatically removed and marked as "Broken" to keep the chart clean.
Zig Zag Structure: Includes an optional Zig Zag overlay to visualize market flow, Higher Highs, and Lower Lows.
ATR-Based Sizing: Zone width is calculated using the Average True Range (ATR), ensuring zones adapt to the asset's current volatility.
Pine Script v6: Optimized using the latest array and method functions for speed and stability.
How It Works
Zone Creation: The script looks for Pivot Highs and Lows based on your defined Swing Length.
Supply Zones (Red): Created at Swing Highs.
Demand Zones (Blue): Created at Swing Lows.
Zone Width: The height of the box is determined by the ATR multiplied by your Zone Width setting. This ensures the zone covers the "wick" area or the volatility range of the pivot.
Invalidation: If the price closes past the outer edge of a zone (the top of a Supply zone or bottom of a Demand zone), the script detects a break, removes the filled box, and leaves a subtle trace of the broken structure.
How to Use
Trend Following: Use the Zig Zag lines to identify the trend direction. Look for Long entries in Demand zones during an uptrend, and Short entries in Supply zones during a downtrend.
Reversals: Watch for price to react at older, unfilled zones (POIs) that align with major support/resistance levels.
Stop Loss Placement: The outer edge of the zone acts as a natural invalidation point. If price closes beyond it, the setup is typically invalidated.
Settings Guide
Swing Length: Determines the sensitivity of the pivot detection. Lower numbers find more local zones (scalping); higher numbers find major structural zones (swing trading).
Max Zones to Keep: Limits the number of historic zones displayed to prevent chart clutter.
Zone Width (ATR): Adjusts how thick the zones are. Increase this value if you want to capture wider wicks.
Visual Settings: Fully customizable colors for Supply, Demand, Borders, and Zig Zag lines.
Disclaimer
This tool is for informational and educational purposes only. It visualizes past price action and does not guarantee future performance. Always manage your risk appropriately.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
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.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
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.