Skip to content
FXNook HubBeta

Alex / Market Structure Indicator (HH HL LH LL) for MT5

MetaTrader 5IndicatorMITCompiled · build 6333
AlexFirst version.build 6333v1.08 hours ago1 version
  • FXN_MarketStructure.mq5First version.10 KB
  • FXN_MarketStructure.ex5Compiled by the Lab with MetaEditor build 633321 KB
README

Overview

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.

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

InputDefaultWhat it does
Left bars5Bars before a swing that must be lower (highs) or higher (lows)
Right bars5Bars after a swing; also the confirmation delay
History bars3000How many bars back to scan (0 = all)
Show dotstrueDot on every confirmed swing point
Show labelstrueHH / HL / LH / LL text
Show breakstrueBOS / CHoCH lines
Swing high / low colourTomato / DodgerBlueColours of the dots and labels
Bullish / bearish break colourSeaGreen / CrimsonColours of the break lines
Label font size8Text size
Alert on breakfalseOne 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.

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

Settings read from the code

InputTypeDefaultNote
InpLeftBarsint5Bars on the left that must be lower (highs) / higher (lows)
InpRightBarsint5Bars on the right = confirmation delay in bars
InpMaxBarsint3000History bars to scan (0 = all bars)
InpShowDotsbooltrueMark every confirmed swing point with a dot
InpShowLabelsbooltrueShow HH / HL / LH / LL labels
InpShowBreaksbooltrueShow break-of-structure lines (BOS / CHoCH)
InpHighColorcolorclrTomatoSwing high colour
InpLowColorcolorclrDodgerBlueSwing low colour
InpBreakUpcolorclrMediumSeaGreenBullish break line colour
InpBreakDowncolorclrCrimsonBearish break line colour
InpFontSizeint8Label font size
InpAlertBreakboolfalseAlert once when a closed bar breaks structure

How to use it

  1. Download the compiled file (or the source and compile it in MetaEditor).
  2. Put it in MetaTrader: File → Open Data Folder → MQL5 → Indicators, then refresh the Navigator.
  3. Test it on a demo account before any real money.
  4. Want changes? Open a copy in your Lab and ask for them in plain words.