OPEN-SOURCE SCRIPT
Mis à jour

RBD Confluence Zones

609
Confluence Zones highlights areas on the chart where multiple key support/resistance levels stack within a tight range — places where multiple timeframes "agree." These zones tend to act as stronger S/R than any single level alone.

How it works
Each bar the indicator calculates a set of important price levels and groups any that fall within a user-defined proximity threshold (ATR-based by default). Groups of 2 or more levels are drawn as colored zones:

- Cyan = 2 levels (light confluence)
- Magenta = 3 levels (medium confluence)
- Yellow = 4+ levels (strong confluence, rare)

Levels included (each toggleable)
- Weekly Pivot Points: P, R1, R2, S1, S2 (+ optional R3/S3)
- Monthly Pivot Points: P, R1, R2, S1, S2 (+ optional R3/S3)
- Previous Week High / Low
- Previous Month High / Low
- Previous Day High / Low
- Previous Weekly Market Profile VAH / VAL (TPO method, 20 bins, 70% VA)

Key inputs
- Proximity Mode: ATR / Percent of Price / Ticks
- ATR Multiplier (default 0.5): how close levels must be to cluster
- Min Levels per Zone (default 2)
- Value Area % for the Weekly Market Profile (default 70%)
- Border width, label size, colors, lookback all customizable

Reading the chart
- Plain dotted lines: individual levels that did not cluster
- Colored boxes: confluence zones, labeled with what is inside (e.g. "PMH + WVAL + MR1 x3")
- The "xN" count tells you how many levels formed the zone — higher = higher-probability reaction area

Tips
- Default ATR threshold (0.5) works well across most assets/timeframes
- Increase the multiplier for wider clusters, decrease for tighter
- Match the label content to your bias: heavier-timeframe levels (monthly, prev H/L) carry more weight than weekly pivots alone

Credits
The Weekly Market Profile (VAH/VAL) TPO logic is derived from the RBD Market Profile indicator — 20-bin TPO, expanding from POC to cover the chosen Value Area percentage. Standard pivot formulas are Classic Floor.
Notes de version
This update makes the indicator behave the same on every chart timeframe
and fixes a clustering bug that could fuse distant levels into one wide zone.

Changes:

1. ATR is now computed on a configurable higher timeframe (Daily by default)
- Previous behavior: ATR taken from the chart's timeframe, so the
clustering threshold shrank when you moved to a lower timeframe.
A 4-level zone on Daily would silently break into individual lines on 1H.
- New behavior: same symbol = same zones at the same prices across 1H, 4H,
Daily, etc. New input: "ATR Timeframe" (default "D").

2. Cluster width is now capped at the threshold (no more chaining)
- Previous behavior: levels were joined to a zone if they were within
threshold of the *previous* level in the chain, so 5+ levels could
daisy-chain into a zone several times wider than the threshold.
- New behavior: a level only joins a zone if it is within threshold of
the zone's *lowest* member. Every zone's total width <= threshold.
"ATR Multiplier" tooltip updated to reflect this.

3. Individual level lines now extend across the entire chart
- Previously the dotted level lines were bounded by the lookback, so on
low timeframes they only covered a tiny slice of the visible chart.
- Now they use extend.both — proper horizontal price levels.

4. Zone lookback is now in calendar days, not bars
- Renamed "Zone Lookback Bars" -> "Zone Lookback (days)", default 14.
Visual zone width is now consistent across timeframes.

5. Individual level lines OFF by default
- The dotted lines are now a debug aid rather than a default visual.
Renamed to "Show Individual Level Lines (debug)" with tooltip
explaining when to turn it on (tuning the ATR Multiplier)
Notes de version
1. Higher-Timeframe Pivots & Levels (optional)

Added four new level groups to the confluence set, all defaulting OFF so existing setups are unchanged:

- Quarterly Pivots — QP, QR1/QR2, QS1/QS2 (and QR3/QS3 if R3 enabled)
- Yearly Pivots — YP, YR1/YR2, YS1/YS2
- Previous Quarter High/Low (PQH/PQL)
- Previous Year High/Low (PYH/PYL)

Why: On weekly/monthly charts, weekly-based levels like PWH/PWL get pierced inside a single bar and behave like noise. Higher-timeframe levels carry real swing-trade-grade gravity.
Enable Q/Y levels when working monthly; keep them off for intraday. All previous levels (PWH/PWL, WR1/WS1, WVAH/WVAL, etc.) remain available — these are additions, not replacements.

2. Historical Confluence Zones (new toggle group)

You can now lock prior periods' confluence zones onto the chart to study how price respected them.

- Show Historical Confluence Zones — master on/off (default OFF)
- Number of Past Periods to Show — 1 to 12 (default 3)
- History Period Length — Auto / Weekly / Monthly / Quarterly
- Auto: ≤Daily chart → Weekly snapshots, Weekly+ chart → Monthly snapshots
- Historical Zone Transparency % — keeps history visually distinct from current zones
- Show Historical Zone Labels — toggle
- Historical Min Levels per Zone — independent threshold; raise to declutter

How it works: At the start of each period, the indicator captures the levels active at that moment (HTF pivots, prev highs/lows, weekly MP VAH/VAL, ATR). When that period ends, those
captured levels are used to draw a frozen confluence zone box spanning that period — dashed border, dimmed fill, never recomputed. The oldest box drops off when you exceed your "past
periods" count.

Why: Pattern recognition. Seeing how price reacted at last quarter's x4 zone tells you what to expect at the current one. Old confluence zones also retain latent S/R weight for months
after they form.

3. Visual & Performance Tweaks

- Bumped drawing limits to support history (max_boxes_count=100, max_labels_count=200)
- Refactored level-building and clustering into reusable functions so current and historical zones share identical logic

---
Recommended setup for monthly charts (e.g., XAUUSD, ES1!, indices):
Enable Quarterly Pivots, Yearly Pivots, PQH/PQL, PYH/PYL, plus Historical Confluence Zones (3 periods). Your yellow x4+ zones will lean on heavier swing levels, and you'll have visual
context for how the prior 3 months' zones played out.

Recommended setup for intraday/daily: Keep defaults (W/M only) and optionally enable Historical Zones with Weekly period length.
Notes de version
Renamed RBD to MJQ
New input group "Style v2" (appended last, existing inputs untouched):

1. "Zone placement" — Rail / Span, default Rail. Zones no longer stretch back across the lookback window covering
price action; they start a few bars right of the live candle and extend into the right margin as a level ladder.
"Span" = legacy behavior.
2. "Color by side of price" — bool, default on. Clusters above price draw in the supply color (pink #e91e63), below
price in the demand color (cyan #00bcd4), straddling price gray — same palette as the SMC zone engine. Level count
(x2/x3/x4+) is now shown by fill intensity and border width instead of aqua/fuchsia/yellow hues. Off = legacy colors.
3. "Rail offset" — int, default 8. How many bars right of the live candle the rail begins.
4. "Anchor zones near price to candles" — float ×ATR, default 1.0. A zone whose nearest edge is within this distance
of the live close is in play: it extends back 12 bars over the candles with a solid border so you can watch price
trade into it. Distant zones stay parked in the rail. 0 = pure rail.

Changed defaults:
- ATR Multiplier: 0.5 → 0.15 — paired with ATR Timeframe "D", this reproduces the old 60-min-ATR × 1.0 cluster width
but works on every chart timeframe.
- Label Size: normal → small.

Heads-up for your own settings: don't set ATR Timeframe below your chart timeframe (e.g. "60" while viewing Daily) — a
lower-TF request.security is a runtime error and the study dies with "Can't parse pine". Leave it on "D".

Both source files are in the repo (rbd_smc_pro.pine, confluence_zones.pine) with deploy helpers .claude/inject_smc.mjs
and .claude/inject_confluence.mjs. Note the repo also has uncommitted changes from before this session if you want to
commit everything together.

Clause de non-responsabilité

Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.