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.
Tập lệnh chỉ hiển thị cho người được mời
Chỉ những người dùng được tác giả chấp thuận mới có thể truy cập tập lệnh này. Bạn sẽ cần yêu cầu và được cấp quyền sử dụng. Thông thường quyền này được cấp sau khi thanh toán. Để biết thêm chi tiết, làm theo hướng dẫn của tác giả bên dưới hoặc liên hệ trực tiếp với keypoems.
TradingView KHÔNG khuyến nghị bạn trả phí hoặc sử dụng một tập lệnh trừ khi bạn hoàn toàn tin tưởng vào tác giả và hiểu cách hoạt động của tập lệnh. Bạn cũng có thể tìm các lựa chọn miễn phí, mã nguồn mở trong các script cộng đồng của chúng tôi.
Hướng dẫn của tác giả
Thông báo miễn trừ trách nhiệm
Tập lệnh chỉ hiển thị cho người được mời
Chỉ những người dùng được tác giả chấp thuận mới có thể truy cập tập lệnh này. Bạn sẽ cần yêu cầu và được cấp quyền sử dụng. Thông thường quyền này được cấp sau khi thanh toán. Để biết thêm chi tiết, làm theo hướng dẫn của tác giả bên dưới hoặc liên hệ trực tiếp với keypoems.
TradingView KHÔNG khuyến nghị bạn trả phí hoặc sử dụng một tập lệnh trừ khi bạn hoàn toàn tin tưởng vào tác giả và hiểu cách hoạt động của tập lệnh. Bạn cũng có thể tìm các lựa chọn miễn phí, mã nguồn mở trong các script cộng đồng của chúng tôi.