# Market Structure Indicator (HH HL LH LL) for MT5

> Marks confirmed swing highs and lows, labels them HH, HL, LH or LL and draws break-of-structure (BOS / CHoCH) lines for price action traders.

## At a glance

- What it is: A free Indicator for MetaTrader 5, written in MQL5.
- What it does: Marks confirmed swing highs and lows, labels them HH, HL, LH or LL and draws break-of-structure (BOS / CHoCH) lines for price action traders.
- Shared by: Alex
- Licence: MIT
- Version: 1.0 (1 Dec 2026)
- Settings: 12 inputs
- Lab check: Compiled with MetaEditor build 6333 for MT5 on 1 Dec 2026: 0 errors, 0 warnings.
- Price: Free to download
- Page: https://hub.fxnook.com/market-structure-indicator-hh-hl-lh-ll-for-mt5
- Download (compiled): https://hub.fxnook.com/download/889ffa5b-9de5-4715-a451-a7e6287239e3/compiled
- Download (source): https://hub.fxnook.com/download/889ffa5b-9de5-4715-a451-a7e6287239e3/source

## About

Reading market structure by eye is slow and easy to get wrong when the chart is busy. This indicator finds confirmed swing highs and swing lows, labels each one against the previous swing (higher high, lower high, higher low, lower low) and draws a line when a candle closes beyond the latest swing, so trend and structure breaks are visible at a glance.

## How it works

- A **swing high** is a bar whose high is above the highs of the `Left bars` before it and not exceeded by the `Right bars` after it. A **swing low** is the mirror image using lows.
- A swing is only drawn once all its right-hand bars have **closed**, so a point is confirmed `Right bars` candles after it formed and never moves afterwards.
- Each new swing high is compared with the previous swing high: higher = **HH**, otherwise **LH**. Each new swing low is compared with the previous swing low: higher = **HL**, otherwise **LL**.
- The most recent swing high and swing low are tracked as structure levels. When a **closed** candle closes above the swing high (or below the swing low), a dotted line is drawn from the swing to the breaking candle.
- The line is labelled **BOS** when the break is in the same direction as the previous break, and **CHoCH** (change of character) when it is the first break against the previous direction.

## Inputs

| Input | Default | What it does |
|---|---|---|
| Left bars | 5 | Bars before a swing that must be lower (highs) or higher (lows) |
| Right bars | 5 | Bars after a swing; also the confirmation delay |
| History bars | 3000 | How many bars back to scan (0 = all) |
| Show dots | true | Dot on every confirmed swing point |
| Show labels | true | HH / HL / LH / LL text |
| Show breaks | true | BOS / CHoCH lines |
| Swing high / low colour | Tomato / DodgerBlue | Colours of the dots and labels |
| Bullish / bearish break colour | SeaGreen / Crimson | Colours of the break lines |
| Label font size | 8 | Text size |
| Alert on break | false | One alert when a closed bar breaks structure |

## How to use it

1. In MetaTrader open **File > Open Data Folder**.
2. MT4: copy `FXN_MarketStructure.mq4` into `MQL4/Indicators`. MT5: copy `FXN_MarketStructure.mq5` into `MQL5/Indicators`.
3. Right-click **Indicators** in the Navigator and choose **Refresh** (or restart the terminal). The file compiles on first use; you can also open it in MetaEditor and press Compile.
4. Drag the indicator onto a chart and set the inputs.

Start with `Left bars` = 5 and `Right bars` = 5 on H1 or H4. Smaller values (2-3) show minor structure on lower timeframes; larger values (8-10) keep only major swings. A run of HH and HL marks an up-trend; the first close below the last HL prints a CHoCH and is often where traders start looking for the trend to change.

## Good to know

- **No repaint after confirmation.** The newest swing appears `Right bars` candles late; that delay is the price of confirmation.
- Breaks are judged on the candle close, not on wicks.
- Works on any symbol and timeframe. In tight ranges you will see many small swings; raise the bar counts there.
- It shows structure only. It does not place trades or tell you where to enter.
- The two swing buffers (Swing high, Swing low) can be read by an EA with iCustom; empty bars hold EMPTY_VALUE.

Trading carries risk. Test on a demo account first; past results do not predict future results.

## Settings (inputs)

| Input | Type | Default | Note |
|---|---|---|---|
| InpLeftBars | int | 5 | Bars on the left that must be lower (highs) / higher (lows) |
| InpRightBars | int | 5 | Bars on the right = confirmation delay in bars |
| InpMaxBars | int | 3000 | History bars to scan (0 = all bars) |
| InpShowDots | bool | true | Mark every confirmed swing point with a dot |
| InpShowLabels | bool | true | Show HH / HL / LH / LL labels |
| InpShowBreaks | bool | true | Show break-of-structure lines (BOS / CHoCH) |
| InpHighColor | color | clrTomato | Swing high colour |
| InpLowColor | color | clrDodgerBlue | Swing low colour |
| InpBreakUp | color | clrMediumSeaGreen | Bullish break line colour |
| InpBreakDown | color | clrCrimson | Bearish break line colour |
| InpFontSize | int | 8 | Label font size |
| InpAlertBreak | bool | false | Alert once when a closed bar breaks structure |

Tags: market-structure, swing-high-low, hh-hl, bos, choch, price-action, smart-money, indicator

Shared code is the author's work, not financial advice. Test on a demo account first.
