OPEN-SOURCE SCRIPT

Market Structure BOS, CHoCH, HH HL LH LL & Trend Health [LunqFX]

9 505
Market structure is the skeleton of every trend: a series of higher highs and higher lows, or lower highs and lower lows, until a break says the trend has changed. This indicator maps that skeleton automatically — labelling every swing as HH, HL, LH or LL, drawing each Break of Structure (BOS) and Change of Character (CHoCH) — and adds one thing no other structure tool has: it tells you the trend is failing BEFORE the structure actually breaks.

❶ THE STRUCTURE MAP

▸ SWING LABELS — every confirmed swing point is labelled HH (higher high), HL (higher low), LH (lower high) or LL (lower low). The sequence of those four labels IS the trend, and having it on the chart removes the guesswork from reading price action.

▸ BOS — Break of Structure. Price closes through the last swing level in the direction of the trend: the trend is continuing. Drawn as a dashed line from the broken level with a BOS label.

▸ CHoCH — Change of Character. Price closes through the last swing level against the trend: the trend has flipped. Drawn as a solid, highlighted line — this is the reversal signal smart-money traders wait for.

▸ STRUCTURE CANDLES — the candles themselves are coloured by the structural trend, not by whether each bar closed up or down. Green means the market structure is bullish, violet means bearish, so the regime is obvious at a single glance. Their brightness fades as Trend Health falls.

❷ TREND HEALTH 0–100 — THE EARLY WARNING

Every other structure tool tells you a trend has ended after CHoCH prints. By then the move is already gone. Trend Health measures the two things that decay before every structure break:

▸ EXPANSION — in a healthy trend each new extreme clears the previous one by at least as much as the last leg did. When new highs barely exceed the old ones, the trend is running out of fuel.

▸ RETRACEMENT — in a healthy trend pullbacks stay shallow. When each pullback eats deeper into the previous leg, control is shifting to the other side.

Both are measured on the live leg, normalised by ATR so the score behaves the same on any symbol and timeframe, and blended into a single 0–100 reading. When it drops below your threshold the dashboard flags WEAKENING — while the trend is still technically intact. That is the warning CHoCH cannot give you, because CHoCH is confirmation, not anticipation.

❸ THE STRUCTURE TAPE

Instead of a table of numbers, the dashboard shows a timeline of the last five structure events, oldest to newest: BOS ▲ · BOS ▲ · CHoCH ▼ · BOS ▼. Reading the sequence tells you instantly whether the market is trending cleanly (a run of BOS in one direction) or chopping (CHoCH flipping back and forth) — context you cannot get from a single label on the chart.

❹ HOW TO TRADE IT

1 — Establish the bias from MARKET STRUCTURE in the panel. Bullish structure = look for longs, bearish = look for shorts. Do not fight it.

2 — Use BOS as continuation. A BOS in the direction of your bias confirms the trend is intact; the broken level often becomes support or resistance on the retest.

3 — Use CHoCH as the reversal trigger. A CHoCH against the prevailing trend is the earliest confirmed signal that structure has flipped. Wait for it before trading a reversal.

4 — Use TREND HEALTH for timing and risk. Health above 65 with a run of BOS on the tape = a clean trend, hold your position and trail. Health falling into WEAKENING = tighten stops, take partials, and stop adding — the structure is decaying and a CHoCH becomes more likely.

5 — Read the tape for market state. Several BOS in a row = trending market, trade continuations. Alternating CHoCH = choppy market, stand aside or trade the range instead.

❺ HOW IT WORKS

Swing points come from confirmed pivots, so a swing only exists once the bars on both sides of it have closed. The most recent swing high and swing low become the active structure levels. When a bar CLOSES beyond one of them (a wick-based mode is available), the break is registered: in the direction of the current trend it is a BOS, against it a CHoCH, and the trend state flips. Trend Health compares the size of the current expansion leg with the previous one in ATR units, and the depth of the latest pullback against the leg it retraced, then blends them 60/40 into the 0–100 score. Immediately after a CHoCH there is no second leg to compare yet, so the panel honestly reports NEW TREND instead of a misleading health reading.

Works on every symbol and timeframe — forex, gold, indices, crypto and stocks — because every threshold is either structural or ATR-normalised, with nothing to configure per market.

SETTINGS — swing length (how major a swing must be), break on close or wick, the health threshold that flags weakening, swing labels and BOS/CHoCH lines on/off, number of events kept, structure candles on/off, and dashboard position.

ALERTS — BOS up, BOS down, CHoCH up, CHoCH down, and Structure Weakening (the early warning).

NON-REPAINTING — swings are built from confirmed pivots and every break is validated on bar close. A label or line that has printed never moves or disappears.

Every component here describes the same object — the market's structure — at a different resolution: the swings build it, BOS and CHoCH break it, Trend Health measures its condition, and the tape is its history. That is why they belong in one tool rather than five.

This indicator is an educational market-analysis tool, not financial advice. Trend Health describes the current structure's condition and does not predict future prices. Always confirm with your own analysis and manage your risk.

Pre-publish checklist

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.