OPEN-SOURCE SCRIPT
Updated SD Zone Pro - Grouped Pivot Volume & Supply-Demand Zones

SD Zone Pro - Grouped Pivot Volume & Supply-Demand Zones
Overview
SD Zone Pro is an advanced Supply and Demand (SD) zone detection tool engineered to highlight key institutional interest areas on your charts.
Unlike traditional supply/demand indicators that rely solely on single-bar imbalances or simple market structure breaks, SD Zone Pro uses a smart pivot-clustering algorithm. It tracks consecutive swing highs and lows, aggregates their corresponding trading volumes, and dynamically groups closely-spaced pivots into high-conviction consolidated zones.
Whether you are a scalper looking for quick reaction levels or a swing trader identifying major macro support/resistance areas, SD Zone Pro provides a clear, clutter-free representation of order flow dynamics.
Key Features
Smart Pivot Clustering: Automatically groups a user-defined number of consecutive high or low pivots to form robust Supply/Demand zones.
Volume Aggregation & Formatting: Calculates the cumulative volume traded across all merged pivots within a zone (formatted cleanly as K, M, or B).
Dynamic Zone Merging (ATR-Based): Evaluates spatial proximity using ATR (Average True Range) to automatically merge overlapping or closely situated boxes, preventing chart clutter.
Proximity Detection: Continuously expands active zones if new pivots occur within a customizable bar distance threshold.
Multi-Timeframe / Multi-Horizon Flexibility: Adjustable inputs designed for short-term, medium-term, and long-term trading horizons.
Display Control: Fully customizable rendering modes (Demand Only, Supply Only, or Both) and max box retention controls to optimize pine script performance.
How It Works
Pivot Identification: The indicator continuously detects structural Highs and Lows based on Pivot High Length and Pivot Low Length settings.
Grouping & Volume Accumulation: Once High Pivots to Group or Low Pivots to Group count is reached, it identifies the key extreme price level (lowest low for demand, highest high for supply) and sums up the total volume generated during those pivot bars.
Zone Drawing: A visual box is drawn from the key extreme price level with a dynamic offset (ATR * 0.5) to mark the zone boundary.
Proximity & Overlap Merge:
Proximity Check: If a new cluster forms within Proximity Distance (Bars), it updates and merges into the active cluster.
Tolerance Merge: If a finalized zone overlaps or sits within Box Merge Tolerance (ATR Multiplier) distance of an existing closed zone, the two zones merge into a single consolidated box and sum their volume labels.
Inputs & Settings Guide
1. Pivot Detection
Pivot Low Length / Pivot High Length: Determines the number of left/right bars required to confirm a pivot.
Short Term: 1 - 3
Medium Term: 5 - 10
Long Term: 14 - 21
2. Clustering Parameters
Low Pivots to Group / High Pivots to Group: Sets how many consecutive pivots form a single cluster.
Short Term: 2 - 3
Medium Term: 5
Long Term: 8 - 10
Proximity Distance (Bars): Maximum bar distance to combine new incoming pivots into the current active cluster.
Short Term: 5 - 10 bars
Medium Term: 15 - 25 bars
Long Term: 30+ bars
3. Box & Merge Settings
Box Merge Tolerance (ATR Multiplier): ATR multiplier used to detect overlapping zones. Higher values merge wider zones together.
Short Term: 0.5 - 1.0 (Narrower, precise zones)
Medium Term: 1.5 - 2.0
Long Term: 2.5+ (Broad macro zones)
Maximum Box Count (0 = Unlimited): Limits the number of historical zones retained on the chart to maintain clean visual performance (Set to 0 for unlimited).
4. Display Controls
Display Mode: Choose between Demand Only, Supply Only, or Both.
Show Demand / Supply Labels & Draw Boxes: Toggle volume labels or visual boxes independently to suit your chart template.
Practical Trading Strategies
1. Demand & Supply Retests (Bounce Play)
Look for price returning to an active Demand Zone (Red Box) or Supply Zone (Green Box) with significant aggregated volume. High volume in a consolidated zone indicates strong institutional order absorption, offering high R:R (Risk-to-Reward) entry points.
2. High-Volume Zone Breakouts (Flip Zones)
When price aggressively closes through a high-volume Supply or Demand zone, that zone often flips role (e.g., broken Supply becomes future Demand).
3. Confluence with Market Structure
Use Pivot High Length and Pivot Low Length set to 5 or higher on 1H / 4H timeframes to mark macro liquidity pools, then align lower timeframe entries when price reaches these pre-marked SD zones.
Disclaimer: This indicator is designed for analytical and educational purposes only. It does not constitute financial advice or trade signals. Always use proper risk management and validate setups with additional market context
Overview
SD Zone Pro is an advanced Supply and Demand (SD) zone detection tool engineered to highlight key institutional interest areas on your charts.
Unlike traditional supply/demand indicators that rely solely on single-bar imbalances or simple market structure breaks, SD Zone Pro uses a smart pivot-clustering algorithm. It tracks consecutive swing highs and lows, aggregates their corresponding trading volumes, and dynamically groups closely-spaced pivots into high-conviction consolidated zones.
Whether you are a scalper looking for quick reaction levels or a swing trader identifying major macro support/resistance areas, SD Zone Pro provides a clear, clutter-free representation of order flow dynamics.
Key Features
Smart Pivot Clustering: Automatically groups a user-defined number of consecutive high or low pivots to form robust Supply/Demand zones.
Volume Aggregation & Formatting: Calculates the cumulative volume traded across all merged pivots within a zone (formatted cleanly as K, M, or B).
Dynamic Zone Merging (ATR-Based): Evaluates spatial proximity using ATR (Average True Range) to automatically merge overlapping or closely situated boxes, preventing chart clutter.
Proximity Detection: Continuously expands active zones if new pivots occur within a customizable bar distance threshold.
Multi-Timeframe / Multi-Horizon Flexibility: Adjustable inputs designed for short-term, medium-term, and long-term trading horizons.
Display Control: Fully customizable rendering modes (Demand Only, Supply Only, or Both) and max box retention controls to optimize pine script performance.
How It Works
Pivot Identification: The indicator continuously detects structural Highs and Lows based on Pivot High Length and Pivot Low Length settings.
Grouping & Volume Accumulation: Once High Pivots to Group or Low Pivots to Group count is reached, it identifies the key extreme price level (lowest low for demand, highest high for supply) and sums up the total volume generated during those pivot bars.
Zone Drawing: A visual box is drawn from the key extreme price level with a dynamic offset (ATR * 0.5) to mark the zone boundary.
Proximity & Overlap Merge:
Proximity Check: If a new cluster forms within Proximity Distance (Bars), it updates and merges into the active cluster.
Tolerance Merge: If a finalized zone overlaps or sits within Box Merge Tolerance (ATR Multiplier) distance of an existing closed zone, the two zones merge into a single consolidated box and sum their volume labels.
Inputs & Settings Guide
1. Pivot Detection
Pivot Low Length / Pivot High Length: Determines the number of left/right bars required to confirm a pivot.
Short Term: 1 - 3
Medium Term: 5 - 10
Long Term: 14 - 21
2. Clustering Parameters
Low Pivots to Group / High Pivots to Group: Sets how many consecutive pivots form a single cluster.
Short Term: 2 - 3
Medium Term: 5
Long Term: 8 - 10
Proximity Distance (Bars): Maximum bar distance to combine new incoming pivots into the current active cluster.
Short Term: 5 - 10 bars
Medium Term: 15 - 25 bars
Long Term: 30+ bars
3. Box & Merge Settings
Box Merge Tolerance (ATR Multiplier): ATR multiplier used to detect overlapping zones. Higher values merge wider zones together.
Short Term: 0.5 - 1.0 (Narrower, precise zones)
Medium Term: 1.5 - 2.0
Long Term: 2.5+ (Broad macro zones)
Maximum Box Count (0 = Unlimited): Limits the number of historical zones retained on the chart to maintain clean visual performance (Set to 0 for unlimited).
4. Display Controls
Display Mode: Choose between Demand Only, Supply Only, or Both.
Show Demand / Supply Labels & Draw Boxes: Toggle volume labels or visual boxes independently to suit your chart template.
Practical Trading Strategies
1. Demand & Supply Retests (Bounce Play)
Look for price returning to an active Demand Zone (Red Box) or Supply Zone (Green Box) with significant aggregated volume. High volume in a consolidated zone indicates strong institutional order absorption, offering high R:R (Risk-to-Reward) entry points.
2. High-Volume Zone Breakouts (Flip Zones)
When price aggressively closes through a high-volume Supply or Demand zone, that zone often flips role (e.g., broken Supply becomes future Demand).
3. Confluence with Market Structure
Use Pivot High Length and Pivot Low Length set to 5 or higher on 1H / 4H timeframes to mark macro liquidity pools, then align lower timeframe entries when price reaches these pre-marked SD zones.
Disclaimer: This indicator is designed for analytical and educational purposes only. It does not constitute financial advice or trade signals. Always use proper risk management and validate setups with additional market context
Release Notes
SD Zone Pro – New FeatureMerged Zone Color
When a Demand (buy) zone and a Supply (sell) zone overlap and merge, you can now optionally highlight this with a distinct color (orange by default). This lets you instantly spot "this area has seen both buying and selling pressure — a key zone."
If the setting is enabled: the merged zone turns orange (or your chosen color).
If disabled: it stays the normal red/green as before.
Release Notes
Update: Multi-Timeframe (MTF) SupportSD Zone Pro now includes an optional Multi-Timeframe (MTF) mode for pivot and volume detection.
What's new:
By default, the indicator detects pivots and volume using the chart's own timeframe. With MTF mode enabled, you can instead pull pivot and volume data from any timeframe you choose, while the Supply/Demand zones still draw on your current chart.
How to use it:
Open the "Multi-Timeframe (MTF)" settings group.
Turn on "Enable MTF?".
Set "MTF Timeframe" to the timeframe you want to base pivots on (e.g. 240 for 4H, D for Daily). Leave it blank to use the chart's timeframe.
Recommendation:
Using a higher timeframe than your chart (for example, a 4H or Daily timeframe on a 15-minute chart) generally gives more reliable, higher-quality Supply/Demand zones with less noise. Lower timeframes can be selected too, but may produce less consistent pivot placement.
If MTF mode is left off, the indicator behaves exactly as before — no changes to existing behavior.
Release Notes
SD Zone Pro — Price Range Filter AddedAdded new Price Range Filter settings group. When enabled (Enable Price Range Filter?), Supply/Demand zones falling outside the specified price range are visually hidden (they are not deleted, only made transparent).
Supports two source modes:
Manual: Enter a fixed Min/Max price range.
Time-Based: Automatically calculates the highest high and lowest low within a selected time window (e.g., last 4 hours, last 7 days) and uses it as the price boundary, dynamic as price moves.
Operates independently of the Maximum Box Count setting — whether the box limit is set to 0 (unlimited) or any value, the filter functions according to its own logic.
Existing zone creation, merging, and extending logic remain unchanged; the filter acts strictly as a visibility layer.
Benefits of the Price Range Filter
Reduces Visual Noise: Prevents old Supply/Demand zones far away from the current market price from cluttering the screen; only zones within your active trading range remain visible.
Enhances Focus: Makes it easier to distinguish zones near the current price level, especially on long-term charts (e.g., multi-year stock charts) with accumulated historical boxes.
Independent Control Layer: Maximum Box Count determines "how many total boxes to retain," whereas this filter determines "which price range boxes should be displayed." Both can be used together to solve different visual challenges.
Dynamic Trailing (Time-Based Mode): On volatile instruments (like cryptocurrencies), instead of manually updating static Min/Max prices, selecting "price range within the last X hours/days" allows the filter to automatically trail current price action without manual intervention.
Full Backward Compatibility: Disabled by default (Enable Price Range Filter? = false), ensuring your previous chart configurations and visual setups remain intact after the update until explicitly enabled.
⚠️ Warning: Compatibility Issue with Short Time Window + High Chart Timeframe in Time-Based Mode
When Price Range Source = Time-Based is selected, your input time window (Time Range Value + Time Unit) is converted into bar counts based on the chart's timeframe (lookbackBars). If the chosen time window is shorter than the chart's single bar duration, the calculated bar count is clamped to a minimum of 1 bar (math.max(1, ...)). In this case:
The filter range collapses to the High and Low of just a single bar.
Since this creates an extremely narrow price band, almost no Supply/Demand boxes fit within it, causing zones to disappear from the chart (zones are not deleted, only hidden by transparency).
Example
Chart Timeframe: 1 Day (1D)
Time Unit = "Hour", Time Range Value = 4 → Selected window is 4 hours.
On a 1D chart, 1 bar = 24 hours, so a 4-hour window is shorter than 1 bar → system rounds it up to 1 bar.
Result: Filter range collapses strictly to the last day's High/Low → almost all zones fall outside this tight range, rendering the chart seemingly empty.
Rule of Thumb
The chosen time window (Value × Unit) must be significantly larger than the chart's timeframe.
Practical Guidelines:
1-Minute Chart: Short time windows (e.g., 30 Minutes, 2 Hours) are suitable.
1-Hour Chart: Multi-day windows (e.g., 3 Days, 1 Week) work best.
Daily Chart (1D): Use at least multi-week or monthly windows (e.g., 2 Weeks, 1 Month); short hourly values (like 4 Hours) are ineffective and cause zones to disappear.
Weekly/Monthly Chart: Broader multi-month or yearly windows (e.g., 6 Months, 1 Year) should be preferred.
In short: As the chart timeframe increases, the Time-Based window must also be increased; otherwise, the filter range shrinks to a single bar and hides your zones.
Open-source script
In true PulseWire spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
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 PulseWire. Read more in the Terms of Use.
Open-source script
In true PulseWire spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
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 PulseWire. Read more in the Terms of Use.
