🔥Black Friday Sale: Get 25% OFF Premium with code BLACKFRIDAY — Sale ends December 1st!🎉
Market Structure Mastery — Higher Highs, Lower Lows, and Break of Structure Explained with Code

Market Structure Mastery — Higher Highs, Lower Lows, and Break of Structure Explained with Code

By HorizonAI Team

If you don’t understand market structure, everything else in Smart Money Concepts (SMC) is just noise.
Order blocks, fair value gaps, and liquidity grabs all sit on top of one core idea:

Is the market making higher highs and higher lows (bullish) or lower highs and lower lows (bearish)?

This guide will help you master structure first, so the rest of SMC makes sense:

  • How to read HH/HL vs LH/LL across any market and timeframe
  • The difference between BOS (Break of Structure) and CHOCH (Change of Character) in ICT‑style SMC
  • How to think about trends, ranges, and transition points
  • How to start visualizing structure in Pine Script on EURUSD
  • How HorizonAI can turn your structure rules into full trading systems

By the end, you’ll have a clean mental model—and a code‑ready way of describing structure—for Forex, indices, crypto, and stocks on 1m to D1.

Market Structure 101 — The Language of Price

Market structure is just a consistent way of naming what price is doing:

  • When price keeps making higher highs and higher lows, we call it bullish structure
  • When price keeps making lower highs and lower lows, we call it bearish structure
  • When neither side is clearly in control, structure is sideways/ranging

Bullish Structure: HH and HL

In a bullish trend:

  • Each new swing high breaks above the previous swing high (Higher High – HH)
  • Each pullback low stays above the prior low (Higher Low – HL)

Visually, it looks like stairs going up.

Bearish Structure: LH and LL

In a bearish trend:

  • Each new swing low breaks below the previous swing low (Lower Low – LL)
  • Each bounce high stays below the prior high (Lower High – LH)

This looks like stairs going down.

Why Swings Matter

Structure is built on swings, not every tick:

  • A swing high is a local peak where price turned down
  • A swing low is a local trough where price turned up

If you treat every tiny up/down as structure, you’ll see BOS/CHOCH everywhere and nowhere at once.

BOS vs CHOCH (ICT‑Style Definitions)

In ICT‑style SMC, you’ll hear two key terms:

  • BOS — Break of Structure
  • CHOCH — Change of Character

They sound similar but mean different things.

Break of Structure (BOS)

A BOS is a trend‑following break:

  • In a bullish trend (HH/HL), when price breaks the previous swing high, that’s a bullish BOS
  • In a bearish trend (LH/LL), when price breaks the previous swing low, that’s a bearish BOS

You’re seeing continuation—the trend proves itself again.

Change of Character (CHOCH)

A CHOCH is the first significant break against the current trend:

  • In a bullish trend, the first time price breaks a prior swing low, that’s a bearish CHOCH
  • In a bearish trend, the first time price breaks a prior swing high, that’s a bullish CHOCH

It’s a warning sign that control may be shifting:

  • Bulls losing control → potential move into distribution or downtrend
  • Bears losing control → potential accumulation or uptrend

Key insight:
CHOCH doesn’t guarantee a full trend reversal, but it’s the earliest structural clue that something has changed.

Structure helps you classify the environment:

  • Clear HH/HL or LH/LL sequences
  • BOS in the direction of the trend
  • Pullbacks that respect prior swing lows/highs

SMC traders then look for:

  • Entries in discount (in an uptrend) or premium (in a downtrend)
  • Confluence with order blocks, FVGs, and liquidity

Ranging

  • Swing highs and lows overlap
  • Price chops around a mean
  • BOS/CHOCH labels become less meaningful

In ranges, SMC traders pay more attention to:

  • Liquidity at range highs/lows
  • Mean reversion to the 50% level

Transitional

  • A prior trend starts breaking down:
    • Multiple CHOCH events
    • BOS in the new direction
  • Higher‑timeframe and lower‑timeframe structure may temporarily disagree

This is where many SMC setups live:

  • Liquidity grabs at old trend extremes
  • First OBs and FVGs in the new direction

Simple Swing Detection in Pine Script (EURUSD)

Before you label BOS/CHOCH, you need swings.
Pine Script has built‑ins to help with that.

//@version=5
indicator("Market Structure Swings (EURUSD)", overlay = true)

leftBars  = input.int(2, "Left Bars")
rightBars = input.int(2, "Right Bars")

swHigh = ta.pivothigh(high, leftBars, rightBars)
swLow  = ta.pivotlow(low, leftBars, rightBars)

plotshape(not na(swHigh), title = "Swing High", style = shape.triangledown,
     location = location.abovebar, color = color.red, size = size.tiny)
plotshape(not na(swLow), title = "Swing Low", style = shape.triangleup,
     location = location.belowbar, color = color.green, size = size.tiny)

This doesn’t label HH/HL yet, but it gives you consistent swing points to work with.

Labeling HH, HL, LH, LL (Conceptual Logic)

Once you have swings, you can loop through them logically:

  1. Keep track of the last confirmed swing high and low
  2. When a new swing low forms:
    • If it’s above the previous swing low → HL
    • If it’s below the previous swing low → LL
  3. When a new swing high forms:
    • If it’s above the previous swing high → HH
    • If it’s below the previous swing high → LH

In Pine Script, this kind of stateful logic uses var variables and updates them when swing points appear.

You don’t need to implement the full system manually right now—HorizonAI can generate a more complete structure‑labeling script for you—but it’s important you understand the idea.

Visual BOS/CHOCH Example (Simplified)

Here’s a very simplified way to think about BOS/CHOCH in code terms:

  • Keep arrays of recent swing highs and lows
  • Define:
    • Bullish BOS: current close breaks above the last significant swing high
    • Bearish BOS: current close breaks below the last significant swing low
    • Bearish CHOCH: after a bullish sequence, price breaks a key swing low
    • Bullish CHOCH: after a bearish sequence, price breaks a key swing high

In Pine, that might look like:

//@version=5
indicator("Structure BOS/CHOCH (Conceptual)", overlay = true)

// Use simple pivots as swings
swHigh = ta.pivothigh(high, 2, 2)
swLow  = ta.pivotlow(low, 2, 2)

var float lastHigh = na
var float lastLow  = na
var string trend   = "none"  // "bull", "bear", "none"

if not na(swHigh)
    lastHigh := swHigh
if not na(swLow)
    lastLow := swLow

// Very simplified logic — for teaching only
bullBOS  = not na(lastHigh) and close > lastHigh
bearBOS  = not na(lastLow)  and close < lastLow

// Update trend on BOS
if bullBOS
    trend := "bull"
if bearBOS
    trend := "bear"

// CHOCH: break opposite level vs current trend
bullCHOCH = trend == "bear" and bullBOS
bearCHOCH = trend == "bull" and bearBOS

plotshape(bullBOS,   title = "BOS Up",   style = shape.labelup,   text = "BOS↑",   color = color.new(color.green, 0), size = size.tiny)
plotshape(bearBOS,   title = "BOS Down", style = shape.labeldown, text = "BOS↓",   color = color.new(color.red, 0),   size = size.tiny)
plotshape(bullCHOCH, title = "CHOCH Up", style = shape.labelup,   text = "CHOCH↑", color = color.new(color.blue, 0),  size = size.tiny)
plotshape(bearCHOCH, title = "CHOCH Down", style = shape.labeldown, text = "CHOCH↓", color = color.new(color.orange, 0), size = size.tiny)

This is not a production‑grade SMC tool, but it shows how your conceptual definitions of BOS/CHOCH can be turned into rules a backtest understands.

HorizonAI can generate more precise, higher‑timeframe‑aware versions of this for you.

Using Structure to Frame Trades (Without Going Full SMC Yet)

You don’t need every SMC buzzword to start using structure:

Simple Structure‑First Approach

  1. Identify higher‑timeframe bias (e.g. 4H):
    • Bullish: HH/HL, recent bullish BOS
    • Bearish: LH/LL, recent bearish BOS
  2. Drop to intraday (15m or 1H):
    • Look for pullbacks against the higher‑timeframe trend
  3. Use structure for context:
    • In a bullish 4H trend, prefer longs after 15m bearish CHOCH → bullish BOS
    • In a bearish 4H trend, prefer shorts after 15m bullish CHOCH → bearish BOS

Later, you can tighten entries with:

  • Order blocks within discount/premium zones
  • Fair value gap fills in the direction of structure
  • Session‑specific liquidity events

But structure remains the skeleton everything else hangs on.

Common Market Structure Mistakes

❌ Mistake #1: Redefining Structure Every Candle

If you change your interpretation every bar:

  • Yesterday was bullish
  • Today is bearish
  • Tomorrow is “confusing”

…you’ll never build a consistent rule set.

Fix it by:

  • Using fixed swing rules (e.g., ta.pivothigh/low)
  • Anchoring bias on higher timeframes (4H/D1) and updating only on clear BOS/CHOCH

❌ Mistake #2: Mixing Micro and Macro Structure

On 1m EURUSD you might see ten CHOCHs inside a single 4H candle.

Don’t confuse:

  • Higher‑timeframe structure (true bias)
  • Lower‑timeframe noise (execution detail)

Use:

  • Higher timeframes for direction and bias
  • Lower timeframes for entry refinement

❌ Mistake #3: No Plan for Ranges

When price is sideways:

  • HH/HL vs LH/LL labels lose power
  • You see fake BOS/CHOCH constantly

Have explicit rules like:

  • “If price has stayed within X% of the mean for Y hours, treat as range.”
  • “In ranges, focus on liquidity at range highs/lows or skip trading entirely.”

HorizonAI can help you build range filters into your Pine scripts automatically.

Turn Your Market Structure Rules into Code with HorizonAI

Once you’re comfortable describing structure in words, you can let AI handle the heavy lifting:

  • You define the logic:
    • “4H bullish if last two swings are HH/HL and we have a recent BOS up.”
    • “On 15m, take longs only after a CHOCH + BOS in the direction of 4H.”
  • HorizonAI generates Pine Script v6 that:
    • Detects swings (HH, HL, LH, LL)
    • Labels BOS and CHOCH consistently
    • Applies multi‑timeframe bias filters
    • Adds risk management and realistic costs

You can also access prebuilt market‑structure and SMC scripts inside HorizonAI so you don’t start from scratch.

Example prompts:

"Create a Pine Script v6 indicator for EURUSD that labels HH, HL, LH, LL on 15m and highlights BOS and CHOCH events with different colors."

"Build a strategy that trades only in the direction of 4H structure, entering on 15m CHOCH + BOS, risking 1% per trade with 2:1 RR."

"Generate a multi‑timeframe market structure dashboard that shows me whether D1, 4H, and 1H are bullish, bearish, or ranging."

Turn your structure into a strategy with HorizonAI →

Final Thoughts

Before you worry about perfect order block definitions or exotic FVG rules, master structure:

  1. Read HH/HL vs LH/LL clearly on any chart
  2. Understand BOS as trend confirmation and CHOCH as early warning
  3. Separate higher‑timeframe bias from lower‑timeframe execution
  4. Treat ranges, trends, and transitions differently
  5. Turn your structure rules into code, so you can backtest instead of guessing

Once you can describe market structure in precise language, HorizonAI can help you convert it into Pine Script, test it on EURUSD (and beyond), and then layer on the rest of SMC when you’re ready.

Questions about BOS, CHOCH, or how to codify structure? Join our Discord community to learn and share ideas with other traders.