OPEN-SOURCE SCRIPT

Market Structure Navigator [JOAT]

2 243
Market Structure Navigator [JOAT]

Introduction

Market structure is one of the most widely discussed concepts in technical analysis, yet most tools that attempt to visualize it reduce swing highs and swing lows to single price points. In practice, price rarely reverses at a precise tick level — it reacts within a zone, which may span several ATR units depending on the instrument and timeframe. This distinction matters: treating a level as a point rather than a zone leads to false breaks being mistaken for genuine structural shifts.

The Market Structure Navigator [JOAT] addresses this by modeling every significant swing high and swing low as an ATR-based zone with measurable thickness. It tracks two layers of structure simultaneously — external (major) pivots that define the larger-degree trend, and internal (minor) pivots that provide context within that trend. Each zone passes through a three-state lifecycle, and structural breaks are automatically classified as either Break of Structure (BOS) or Change of Character (CHoCH), giving you an immediate read on whether a break confirms the existing trend or signals a potential reversal.

This is an overlay indicator — all elements are drawn directly on the price chart.

สแนปชอต
---

Core Concepts

Dual-Layer Structure: External and Internal

The indicator identifies two categories of structural pivots using TradingView's built-in pivot functions:

  • External structure (major): Pivots requiring a configurable number of bars on each side (default 20). These are the significant swing highs and lows that define the broader trend context. They update less frequently and represent the higher-degree market structure.
  • Internal structure (minor): Pivots requiring fewer bars on each side (default 7). These fire more frequently and capture the sub-swings that occur within the larger structural moves.


This dual-layer approach mirrors how institutional analysis treats structure: external levels define the direction of the larger trend; internal levels provide precision context for entries and exits within that trend.

Zone Geometry and ATR Thickness

Rather than marking a pivot as a single horizontal line, each pivot is rendered as a rectangular zone. The zone's top and bottom are calculated as:

Pine Script®


The default ATR multiplier is 0.5, meaning the zone extends half an ATR above and below the pivot price. This thickness is dynamic — it adjusts to the current volatility of the instrument rather than using a fixed pip or point value. Zones extend to the right as new bars form, keeping them visible as price approaches.

Three-State Zone Lifecycle

Every zone passes through three possible states:

  • Active (State 0): The zone has formed and not yet been tested. It extends to the right as bars pass, representing untested support or resistance. This is the most significant state — an active zone has not had its interest absorbed.
  • Swept (State 1): Price has reached the midpoint of the zone (configurable as either a wick touch or a close through the midpoint). A swept zone has been tested and shows that some activity occurred at that level. It may have weakened but is not yet confirmed as broken.
  • Broken (State 2): Price has closed decisively beyond the zone boundary (above the top for a resistance zone, below the bottom for a support zone). A broken zone stops extending. This state marks the structural failure of that level.


This lifecycle gives actionable information that a single horizontal line cannot. An active zone is very different from a swept zone even if they appear at the same price level.

BOS and CHoCH Classification

When price breaks through the last significant external high or low, the indicator determines whether the break is:

  • Break of Structure (BOS): The break occurs in the same direction as the current trend. A bullish BOS is a higher high that extends a confirmed uptrend; a bearish BOS is a lower low extending a downtrend. BOS signals trend continuation.
  • Change of Character (CHoCH): The break occurs against the current trend direction. A CHoCH in a downtrend means price has broken above the last significant swing high — a structural signal that the trend may be reversing. CHoCH signals a potential regime shift, not a confirmed reversal.


Both external and internal structural breaks are tracked separately. An internal CHoCH during an external downtrend, for example, may represent a short-term countertrend move within a larger bearish structure — context that a single-layer tool would miss.

Momentum Normalization

Momentum is calculated as the normalized price change:

Pine Script®


This expresses the size of recent price movement in terms of its own standard deviation, making the momentum reading comparable across different instruments and volatility regimes.

Target Arrows

When an internal structural break occurs, the indicator draws a directional arrow label pointing toward the next significant external level. This provides a visual read on where price may be targeting within the larger structural context.

---

Features

  • Dual-layer structure detection: external major pivots and internal minor pivots tracked independently
  • ATR-dynamic zone thickness — zones adapt to current instrument volatility
  • Three-state zone lifecycle: Active, Swept, Broken — each visually distinct
  • Automatic BOS vs. CHoCH classification for both external and internal breaks
  • Configurable sweep mode: wick-based (high/low touches midpoint) or close-based (close through midpoint)
  • Equal high/low detection with configurable ATR tolerance to flag double tops/bottoms
  • Target arrows on internal breaks pointing toward the next external level
  • Dashboard table showing trend state, momentum, active zone counts, last known structural levels, and last break type
  • Full visual toggle controls for all overlay elements
  • Maximum zone count cap per type to maintain chart performance


---

Dashboard Table

A table displayed at the top-right of the chart provides a live summary of structural conditions:

  • Ext Trend: Current external trend direction (Bullish / Bearish)
  • Int Trend: Current internal trend direction
  • Momentum: Normalised momentum value
  • Ext Zones Active: Number of currently active external zones
  • Int Zones Active: Number of currently active internal zones
  • Last Ext High / Low: Price level of the most recent significant external pivot high and low
  • Last Break: The most recent break type (eBOS, eCHoCH, iBOS, iCHoCH)


---

Color System

  • External high zones: red
  • External low zones: white
  • Internal high zones: teal
  • Internal low zones: blue
  • BOS labels: green
  • CHoCH labels: red


This color separation allows you to immediately distinguish between the two structural layers without reading labels.

---

สแนปชอต

Input Parameters

  • External Pivot Length (default 20) — bars required on each side for a major pivot to confirm
  • Internal Pivot Length (default 7) — bars required on each side for a minor pivot to confirm
  • ATR Length (default 14) — ATR period used for zone thickness calculation
  • Zone ATR Multiplier (default 0.5) — controls how wide each zone is relative to ATR
  • Equal H/L Tolerance (default 0.3 ATR) — how close two pivots must be to be considered equal highs or lows
  • Sweep Mode (Wick / Close) — whether zone sweeps are triggered by wick touch or candle close through the midpoint
  • Max Zones Per Type (default 40) — caps the number of active zones drawn per category to preserve chart performance
  • BOS Lookback (default 30) — bars looked back when checking for structural breaks
  • Visual Toggles — individual controls for zones, BOS/CHoCH labels, target arrows, and the dashboard table


---

How to Use

  • Apply to any chart. The indicator will begin plotting zones as enough bars form to confirm pivots at the chosen lengths.
  • Allow sufficient historical bars to load so that the external pivots have time to confirm — with extLen set to 20, a pivot requires 20 bars after the swing point before it is officially plotted.
  • Read the external layer first. The external trend (eBOS/eCHoCH sequence) tells you the larger-degree direction. Trade in alignment with this unless you have strong reason to fade it.
  • Use the internal layer for timing. Internal CHoCH events within an external uptrend can signal pullback entries; internal BOS events in the direction of the external trend can confirm continuation.
  • Active zones are the most significant. A first-touch of an active zone is generally more meaningful than a return to a swept or broken zone.
  • When price approaches a zone, check the sweep mode setting and monitor whether price is reaching the midpoint (sweep) or closing through the boundary (break).
  • The target arrow on an internal break shows the next external level — this is a reference, not a guaranteed target.


---

Limitations

  • Pivot detection is inherently lagging. A pivot at bar N is only confirmed after N + extLen (or intLen) additional bars have formed. This means zones appear after the fact — the exact pivot price was in the past by the time the zone is drawn.
  • With longer pivot lengths, the indicator requires more historical bars to display meaningful structure. On short lookback windows or when first applied to a chart, the initial display may show few or no zones until sufficient pivot confirmation has accumulated.
  • ATR-based zone thickness means zone width changes with volatility. During high-volatility periods, zones become wider and may overlap. During compressed volatility, zones are narrower. Adjust the ATR multiplier if zones are too wide or too narrow for your preferred trading style.
  • The BOS/CHoCH classification is based on the direction of the previous break relative to the current one. In choppy, range-bound markets, rapid BOS/CHoCH alternation is possible and does not necessarily indicate a trend — it may simply reflect noise.
  • Zone lifecycle states reflect price behavior relative to the zone midpoint and boundary. They do not predict whether a swept zone will hold or whether a broken zone will become a new support/resistance level.
  • Maximum zone count limits (default 40 per type) are necessary to maintain chart performance. On instruments or timeframes with many pivot formations, older zones will be removed as new ones are added.
  • No indicator can classify market structure with certainty in real time. CHoCH signals a potential reversal; it does not confirm one. Always apply additional judgment.


---

Originality Statement

The distinguishing design decisions in this indicator are: zone-based pivot modeling, the three-state lifecycle, and the integrated dual-layer structure system.

Most structure tools mark a swing high or low as a horizontal line at a single price. This indicator models each pivot as a zone with ATR-derived thickness, acknowledging that price reactions do not occur at a tick but within a range that varies with the instrument's current volatility. A 0.5 ATR zone around a pivot is a more honest representation of where liquidity and interest are likely to cluster.

The three-state lifecycle (Active → Swept → Broken) adds information that static horizontal lines cannot convey. An active zone that has never been tested is categorically different from one that has seen a wick test — and both are different from a zone that has been fully broken. Treating these three states identically discards relevant context.

The dual-layer architecture (external major + internal minor) is not simply running the same algorithm twice at different sensitivities. The external layer provides the trend framework; the internal layer provides the tactical sub-structure within it. The BOS/CHoCH classification connects these two layers — an internal CHoCH is interpreted in the context of the external trend direction, not in isolation.

---

Disclaimer

This indicator is provided for educational and informational purposes only. It does not constitute financial advice, investment advice, or a recommendation to buy or sell any security. All trading involves risk, including the possible loss of principal. Past indicator performance does not guarantee future results. Always conduct your own research and consult a qualified financial professional before making any trading decisions.

-Made with passion by officialjackofalltrades

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

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