OPEN-SOURCE SCRIPT

SD Zone Pro - Grouped Pivot Volume & Supply-Demand Zones

125
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

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน