PROTECTED SOURCE SCRIPT

GOLD – OB Clean + Internal/External Market Structure [Dragos]

36
GOLD – OB Clean + Internal/External Market Structure [Dragos]

All-in-one tool for XAUUSD that combines:

Clean Order Blocks (Supply/Demand) derived from the last opposite candle after a BOS (break of structure)

Internal & External Market Structure (CHoCH/BOS) with lines and labels

Visual zone management: right extension, mitigation (first touch), invalidation (close beyond), and 50% midline

How it works

Structure & BOS

Finds pivots (HH/LL) via Pivot len.

Triggers BOS when price crosses the last confirmed swing.

Order Blocks

On BOS, scans the last N bars for the opposite candle (bear for BOS up / bull for BOS down) and draws the OB:

Green = Demand, Red = Supply

Optional: use wicks (high/low) or just the body (open/close).

Mitigation: on first touch the zone fades or hides (per settings).

Invalidation: if price closes beyond the zone, it turns gray or gets removed (per settings).

Midline: 50% line for refined management (partial entries, R/R, etc.).

Internal / External Structure

Two structure layers: Internal (micro, shorter swing) and External (macro, longer swing).

Displays CHoCH/BOS with labels; External lines can be dashed for clarity.

Choose to show Internal, External, or Both.

Key Settings

Structure

Pivot len (swing HH/LL) — pivot sensitivity.

Order Blocks

Lookback N bars for the opposite candle

Use wicks — if on, zone uses high/low; otherwise just the body.

Zone Management

Extend zones to the right

Hide zone after mitigation (touch)

Fade zone after mitigation

Remove zone when invalidated

Show 50% line

Max zones stored

Colors: fill/border for Demand/Supply, 50% line color, Mitigated/Invalidated colors.

General

Only on XAU/GOLD (optional) — restricts execution to symbols containing “XAU”/“GOLD”.

Market Structure (tab)

Internal Swing Length / External Swing Length

Show Internal/External Market Structure (Both / Internal / External)

Colors for bullish/bearish MS

Usage Guide

Recommended timeframes: M5/M15 for entries, H1 for context.

Workflow:

Determine External (macro) direction.

Look for BOS and OB in the same direction on Internal.

Wait for mitigation (touch) inside the OB; the 50% line can be used for conservative entries.

Good confluences: sessions (killzones), volume spikes, extreme RSI, MAs (add as separate indicators if needed).

Visual Conventions

Demand: green; Supply: red.

Mitigated: faded yellow (or hidden if chosen).

Invalidated: gray (or removed).

50% line: gray.

Notes & Limits

Pine v6. Object caps follow TradingView limits (max_* = 500). On long histories, increase “Max zones stored” carefully.

BOS is computed when price crosses the last confirmed swing; some traders prefer “close-only” confirmation (can be customized if desired).

This tool does not auto-generate BUY/SELL signals; it’s a context & zones assistant.

Risk disclaimer: Trading involves risk. This tool is for educational analysis and does not guarantee profit. Use strict risk management (fixed SL, R:R ≥ 1:2, risk < 1% per trade).

Clause de non-responsabilité

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