Market Structure
A foundational market structure indicator that automatically identifies and plots swing highs and lows. Detects break of structure (BOS) and change of character (CHoCH) in real-time. Perfect for traders who want clean, actionable structure reads without the noise.

What's Included
How Market Structure works
Market structure is the sequence of swing highs and swing lows that price prints as it moves. In an uptrend price forms higher highs and higher lows; in a downtrend it forms lower highs and lower lows. Reading this sequence tells you the prevailing direction and where control is shifting between buyers and sellers.
A Break of Structure (BOS) happens when price closes beyond the most recent swing point in the direction of the existing trend, confirming that the trend is continuing. A Change of Character (CHoCH) is the first break against the trend, often the earliest hint that momentum is turning. An automated structure indicator finds the relevant swings and labels these two events so you do not have to mark them by eye.
Traders use structure as the skeleton that everything else hangs on. Instead of reacting to individual candles, you frame the chart around whether higher highs and higher lows are still intact, and you treat a confirmed break or character change as the moment to re-evaluate your bias.
When to use it
- Establishing directional bias before looking for an entry, so your trades align with the prevailing structure
- Confirming trend continuation when a BOS prints in the direction you are already trading
- Spotting early reversal risk when a CHoCH breaks the most recent counter-trend swing
- Anchoring stops and targets to real structural swing points rather than arbitrary levels
When it's not the right tool
- In tight, choppy ranges where swings overlap and BOS/CHoCH labels flip back and forth without follow-through
- As a standalone entry trigger; structure defines context but says nothing about timing or momentum on its own
- On very low timeframes during news, where noise creates structure breaks that reverse almost immediately
Source Code Preview
Get the full PineScript v6 source code—use it as a foundation and build on top of it with HorizonAI.
Frequently asked questions
What is the difference between BOS and CHoCH?
A Break of Structure confirms the trend is continuing, because price breaks a swing point in the same direction as the current trend. A Change of Character is the first break in the opposite direction, which can be an early warning that the trend is losing control. BOS is continuation; CHoCH is the potential turn.
What timeframe works best for reading market structure?
Structure is fractal and appears on every timeframe, so it works on all of them. Many traders set bias on a higher timeframe such as the 4-hour or daily, then drop down to a lower timeframe for entries that agree with that bias. Aligning structure across two timeframes generally filters out weaker signals.
Does automatic structure labeling repaint?
Any swing-detection tool only confirms a high or low after enough candles have formed around it, so the most recent, unconfirmed swing can update as new bars print. Once a swing is confirmed and a break has closed through it, that label is fixed. Treat the latest unconfirmed swing as provisional.
Can I combine market structure with other tools?
Yes, structure is designed to be the foundation layer. It pairs naturally with order blocks, liquidity levels and momentum tools, since those give you entry timing once structure has set your directional context. With HorizonAI you can also adjust how sensitively swings are detected to suit your style.
Get access to all 23+ scripts
Full source code, alert templates, and the perfect base to build on with HorizonAI. Join 10,000+ traders.


