OPEN-SOURCE SCRIPT

Structural Divergence [Proozac]

215
Structural Divergence [Proozac] — Pine Script v6 — Overlay Indicator

What It Does
Structural Divergence merges two of the most reliable concepts in technical analysis into a single confluence-based signal: Market Structure (HH/HL/LH/LL, BOS/CHoCH) and RSI/MACD divergence detected precisely at structural swing points — not anywhere on the chart, but exactly where it matters.
Most divergence indicators flag every RSI/price disagreement, drowning traders in low-quality signals. Structural Divergence only calculates divergence at confirmed swing highs and lows, then cross-references it against real structural breaks. A signal only fires when both align.
## How It Works

Swing Detection: identifies significant highs and lows using a configurable pivot length, then labels each one HH, HL, LH, or LL relative to the prior swing of the same type.
BOS / CHoCH: automatically draws Break of Structure and Change of Character lines whenever price closes beyond the last confirmed swing level, tracking trend direction in real time.
Divergence Engine: at every swing high/low, RSI (and optionally MACD histogram, for stricter confirmation) is compared against the prior swing of the same type to detect classic bearish/bullish divergence.
Confluence Signal: when a divergence and a BOS/CHoCH occur within a configurable bar window in the same direction, a triangle signal fires with a built-in alert — filtering out the noise of standalone divergence or structure signals used alone.

Why It's Different
Instead of stacking indicators and hoping for visual confluence, this script computes it algorithmically. The result is fewer, higher-conviction signals: you're not just seeing "RSI diverged" or "structure broke" — you're seeing both happen together, which historically marks higher-probability reversal and continuation zones.
## Settings

Swing Detection Length (pivot sensitivity)
RSI Length
Optional MACD confirmation (stricter mode)
Confluence window (max bars between divergence and structural break)
Full color customization for bullish/bearish elements

Alerts
Two ready-to-use alert conditions: Confluence Buy Signal and Confluence Sell Signal — plug straight into TradingView's alert system or your own webhook automation.

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

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