PulseHub
OPEN-SOURCE SCRIPT
Updated

Demand & Supply Zones Pro RBR / DBR / DBD / RBD [KTFL]

1 088
Demand & Supply Zones Pro — RBR / DBR + Volume Strength + TP/SL

Professional Demand & Supply indicator that automatically detects institutional accumulation and distribution zones using Rally-Base-Rally (RBR), Drop-Base-Rally (DBR), Rally-Base-Drop (RBD), and Drop-Base-Drop (DBD) price structures.

Unlike traditional Supply & Demand indicators that rely only on price action, this script also evaluates Volume Strength, generates a complete Entry / Stop Loss / Take Profit trading plan, and records trading statistics directly on the chart. The script is written entirely from scratch and is not derived from any existing PulseWire indicator.

Features
✔ Automatic Demand & Supply Detection

The script automatically identifies the four classic institutional structures:

Rally → Base → Rally (RBR)
Drop → Base → Rally (DBR)
Rally → Base → Drop (RBD)
Drop → Base → Drop (DBD)

Each zone is confirmed only after a valid Leg-In, Base and Leg-Out sequence has completed, reducing false signals.

✔ Volume Strength Analysis

Every zone is graded using relative volume compared to the market average.

Features include:

Average Volume Comparison
Zone Grade (A / B / C)
Optional Grade A Filter
Volume Ratio Display
Volume-based Zone Coloring

This allows traders to quickly distinguish stronger institutional zones from weaker ones.

✔ Complete Trade Plan

When price revisits a valid zone, the indicator automatically calculates:

Entry Price
Stop Loss
Take Profit
Risk : Reward

Supported Entry Modes:

Zone Edge
Confirmation Close
Trigger Body

Supported Stop Loss Modes:

Zone Distal
ATR

Supported Risk Rewards:

1R
1.5R
2R
2.5R
3R
4R
5R
6R

Projected TP and SL levels can also be displayed before price revisits the zone.

✔ Smart Zone Management

The indicator automatically manages every zone by:

Extending active zones
Fading or deleting used zones
Detecting broken zones
Keeping only the latest zones
Preventing unnecessary clutter

Users can choose whether used zones remain visible or are removed automatically.

✔ EMA Trend Filter

An optional higher-timeframe EMA filter helps trade only in the direction of the dominant trend.

Available modes:

Price above/below EMA
EMA Slope
Both conditions

Users may also choose whether the filter blocks entries only or prevents counter-trend zones from being created entirely.

✔ Trading Statistics Dashboard

The built-in dashboard provides real-time statistics including:

Current Trend
Active Demand / Supply Zones
Average Volume Strength
Current Trade Status
Last Signal
Entry / SL / TP
Win Rate
Consecutive Losses
Total R Multiple
Daily Performance
Win Rate by Pattern (RBR, DBR, RBD, DBD)

This makes it easy to evaluate which market structures perform best over time.

✔ Trade History

Completed trades can optionally remain on the chart, allowing traders to review previous entries, exits and R-multiples.

Historical trades may include:

Entry
Stop Loss
Take Profit
Win / Loss Labels
Complete Trade Boxes

This is useful for reviewing strategy performance and studying historical setups.

✔ Alerts

Built-in alerts include:

New Demand Zone
New Supply Zone
Demand Retest
Supply Retest
Long Entry
Short Entry

These alerts can be connected to PulseWire notifications or automated workflows.

No Repainting

The detection engine evaluates only confirmed candles after the full structure has formed. Signals are generated using completed price action rather than future information, helping to avoid repainting behavior.

Disclaimer

This indicator is designed as a trading decision-support tool and should not be considered financial advice. Always apply proper risk management before entering any trade.
Release Notes
Demand & Supply Zones Pro — RBR / DBR (DS Pro)

An institutional-style supply & demand zone tool for Pine v6. It detects zones from the classic Leg-in → Base → Leg-out structure, grades each zone by volume strength, and projects a full Entry / Stop Loss / Take Profit plan with an on-chart performance tracker. Written entirely from scratch.


WHAT IT DOES

DS Pro looks for the four price structures that mark where imbalance was created and orders are likely resting:

- RBR (Rally-Base-Rally) = Demand — leg-in up, leg-out up
- DBR (Drop-Base-Rally) = Demand — leg-in down, leg-out up
- RBD (Rally-Base-Drop) = Supply — leg-in up, leg-out down
- DBD (Drop-Base-Drop) = Supply — leg-in down, leg-out down

A leg is a strong, full-bodied bar (body ≥ a chosen % of its range, and range ≥ ATR × multiple). A base is one or more small, quiet bars where price pauses. When a valid leg-in, base, and leg-out line up — and the leg-out actually breaks the base edge — a zone is drawn from the base's high/low (or body, your choice).

By default only the two Demand patterns (RBR, DBR) are on. Enable RBD / DBD to hunt short setups.


VOLUME STRENGTH GRADING

Every zone is scored against the recent average volume and labelled A / B / C:

- Grade A — volume ≥ 2.0x average (strong participation, default)
- Grade B — volume ≥ 1.2x average
- Grade C — everything below

You choose what counts toward the score: the base only, base + leg-out (accumulation plus the breakout thrust — the default), or the whole structure. Higher-volume zones can be shaded darker, and you can discard weak zones or trade grade A only.


TRADE PLAN (ENTRY / SL / TP)

For each zone DS Pro projects a complete plan:

- Entry — Zone Edge (limit-style, default), Confirmation Close, or Trigger Body.
- Stop Loss — Zone Distal (just beyond the far edge + an ATR buffer, so wicks are less likely to knock you out) or a fixed ATR distance.
- Take Profit — a fixed R-multiple of the risk (1R to 6R, default 3R).

Projected SL/TP levels are shown on pending zones so you can plan before price arrives.


REALISTIC RETEST LOGIC (NON-REPAINTING)

Detection runs only on confirmed bars (evaluated one bar back), so zones do not repaint. Entries follow a limit-order-like sequence: price must first close beyond the entry edge (the zone becomes armed), then return to touch it to count as an entry. This filters bars that spike through a zone without ever leaving it first.


ON-CHART HISTORY & TRACKER

Closed trades are frozen on the chart — TP/SL boxes, Entry/SL/TP lines, and a +3R / -1R result label — so you can review exactly where past setups entered and exited. History depth is capped and configurable, and old trades can be faded into the background to keep the focus on the current one.

Note: the built-in stats are a simplified on-chart simulation (one trade tracked at a time; if SL and TP are both hit in the same bar it is scored as SL, a conservative assumption). It is meant for visual review and quick edge-checking, not as a broker-accurate strategy backtest.


TREND FILTER (EMA)

An optional EMA filter (default length 200, with an optional higher-timeframe setting) keeps you on the right side of the market: Demand/Long only in an uptrend, Supply/Short only in a downtrend. Measure the trend by Price vs EMA, EMA slope, or Both (strictest). Filter either at entry (zones still drawn for reference — recommended, since the trend when price returns matters most) or by not creating counter-trend zones at all (cleaner chart).


DASHBOARD

A compact table shows the live picture at a glance:

- Current EMA trend state and what it allows
- Pending Demand / Supply zones and their average volume
- Trade status, last signal, entered-zone grade, and live Entry / SL / TP
- Trades, Wins / Losses, Win rate, current & max loss streak
- Total R and today's R
- Win rate broken down by pattern (RBR / DBR / RBD / DBD)

Position, size, colours, and width are all adjustable.


ALERTS

Six ready-to-use alert conditions: New Demand Zone, New Supply Zone, Demand Retest, Supply Retest, Long Entry, and Short Entry — each tagged with the ticker and timeframe.


SUGGESTED WORKFLOW

1. Pick your bias — leave Demand-only on for longs, or enable RBD/DBD for shorts.
2. Keep the trend filter on and aligned with your higher-timeframe view.
3. Favour Grade A zones with volume well above average.
4. Wait for the zone to arm and then retest — treat the projected Entry as a limit order, with SL/TP already defined.
5. Use the dashboard's per-pattern win rate to learn which structures work best on your instrument and timeframe.


SETTINGS GROUPS

1. Structure Detection — ATR length, leg/base body and range thresholds, max base bars, break confirmation.
2. Pattern Selection — toggle RBR / DBR / RBD / DBD.
3. Volume Strength — averaging window, scope, A/B/C thresholds, filters.
4. Trade Plan — enable, entry mode, SL mode, TP target, retest rule, history options.
5. Zones & Display — edges, extension, retention, colours, labels.
6. Trend Filter (EMA) — enable, length, timeframe, measure, stage.
7. Dashboard — show/position/size/colours.


Educational tool. Supply & demand zones show areas of potential interest, not guaranteed reversals — no indicator predicts the future. Always use proper risk management and confirm with your own analysis. Not financial advice.

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.