Market Structure [PRO][keypoems] - 100% rewritten engine

Successor to my earlier script Supply and Demand Areas Responsible and Origins [PRO]. This version rebuilds the engine from scratch and adds HTF support, tap tracking, dealing ranges (“expansion legs”), and DB/DT pattern logic.
What it draws
- Market‑structure zones built from protected high/low and confirmed BOS/MSS. Zones extend forward and remain on chart until 50% mitigation is wicked. Optional 30/50/70 levels.
- Protected High/Low lines and Continuation High/Low levels; BOS and MSS lines are plotted at confirmation.
- SNDR (Supply & Demand Responsible) areas for the counter‑trend swing that caused the BOS. The engine auto‑pivots (tries 3‑pivot then 1‑pivot) and extends each SNDR until 100% mitigation. First‑tap and second‑tap states are tracked and visually marked.
- Zone Tap detection: when price first enters an unmitigated zone, leaves it, and then violates a continuation level, the script confirms the tap and draws a horizontal TAP line from the tap swing for future retests.
- Dealing Ranges (Expansion legs): created on BOS→MSS flips or opposite‑direction MSS. Each range is anchored at the protected level, tracks the current extreme, and marks 50% mitigation. A diagonal arrow plus a 50% line show live progress. An optional right‑hand visual stacks all unmitigated ranges as compact boxes with their 50% line.
- Double Bottom / Double Top patterns: search starts at BOS/MSS events, confirms on neckline break, and draws an ATR‑buffered box and an extending neckline.
- Valid pullback labels and candidate confirmation lines help verify swing sequence formation.
HTF support
Choose a higher timeframe in the Timeframe input to compute market structure on HTF while viewing a lower‑timeframe chart. The script uses request.security and only confirms using closed HTF candles, so zones, BOS/MSS, mitigations and taps match the native HTF chart.
How it works (brief)
- Builds an alternating sequence of valid swings, tracks protected levels, and creates a zone on BOS; zones close or roll when MSS occurs.
- Zone mitigation = wick through the zone’s 50%. SNDR mitigation = full breach (100%).
- Tap logic requires: entry into the zone → exit → violation of a relevant continuation level; only then the TAP line is drawn.
- Dealing ranges start from the protected level at BOS→MSS (or opposite MSS), track the current extreme, and flag mitigation at 50%.
- DB/DT confirms only after a close through the neckline.
Notes
- Origins from the prior script have not been ported to this engine yet.
- Includes a performance switch (scan all zones vs. a recent subset) and an optional on‑chart debug table.
- Visual tool for price‑action study; not a strategy and not financial advice.
- Indicator is APPROVED and generally available via bundle!
- Ported Alerts for: 50% Zone Mitigation, Zone creation, SNDR 1-tap and 2-taps.
Script su invito
Solo gli utenti approvati dall'autore possono accedere a questo script. È necessario richiedere e ottenere l'autorizzazione per utilizzarlo. Tale autorizzazione viene solitamente concessa dopo il pagamento. Per ulteriori dettagli, seguire le istruzioni dell'autore riportate di seguito o contattare direttamente keypoems.
TradingView NON consiglia di pagare o utilizzare uno script a meno che non ci si fidi pienamente del suo autore e non si comprenda il suo funzionamento. Puoi anche trovare alternative gratuite e open-source nei nostri script della comunità.
Istruzioni dell'autore
Attenzione: prima di richiedere l'accesso, leggi la nostra guida per gli script su invito.
Declinazione di responsabilità
Script su invito
Solo gli utenti approvati dall'autore possono accedere a questo script. È necessario richiedere e ottenere l'autorizzazione per utilizzarlo. Tale autorizzazione viene solitamente concessa dopo il pagamento. Per ulteriori dettagli, seguire le istruzioni dell'autore riportate di seguito o contattare direttamente keypoems.
TradingView NON consiglia di pagare o utilizzare uno script a meno che non ci si fidi pienamente del suo autore e non si comprenda il suo funzionamento. Puoi anche trovare alternative gratuite e open-source nei nostri script della comunità.
Istruzioni dell'autore
Attenzione: prima di richiedere l'accesso, leggi la nostra guida per gli script su invito.