PROTECTED SOURCE SCRIPT
Aggiornato

Market Structure Pivots with BOS & CHoCH [zazenio]

119
What is Market Structure?

Market structure is simply the pattern of highs and lows that price creates as it moves. When you look at any chart, you'll notice price doesn't move in a straight line — it swings up, pulls back, swings up again (in an uptrend), or the opposite in a downtrend.

These swing points — the peaks and valleys — are what traders call pivots. Identifying them correctly is the foundation of understanding where a market has been and where it might go next.

What This Indicator Does

Swing Pivots automatically marks these peaks and valleys on your chart so you don't have to draw them manually. It works on any market — stocks, crypto, forex, futures, indices — and on any timeframe.

Beyond just marking pivots, this indicator also draws BOS (Break of Structure) and CHoCH (Change of Character) lines — two essential concepts that help you understand when a trend is continuing or potentially reversing.

How Pivots Are Detected

This indicator confirms pivots based on price structure, not a fixed bar count.

Here's how it works:

A swing high is confirmed when price breaks below the previous swing low. At that moment, we know the high was real — price tried to go higher, failed, and reversed. The market "proved" that level was a genuine turning point.

A swing low is confirmed when price breaks above the previous swing high. The same logic applies — price tried to go lower, failed, and reversed direction.

This creates a natural alternation: high, low, high, low. Each pivot is validated by the market's actual behavior, not by waiting for an arbitrary number of bars to pass.

Understanding BOS and CHoCH

Once you can identify pivots, the next step is understanding what happens when price breaks through them. This is where BOS and CHoCH come in.

BOS (Break of Structure)
A Break of Structure occurs when price continues in the direction of the current trend by breaking a previous pivot level.
  • In an uptrend: Price breaks above a previous swing high → This signals strength. Buyers are pushing price to new highs, and the trend is likely to continue.
  • In a downtrend: Price breaks below a previous swing low → This signals weakness. Sellers are pushing price to new lows, and the trend is likely to continue.

Think of BOS as the market saying "the trend is still intact." Each BOS confirms that the dominant side (buyers or sellers) remains in control.

CHoCH (Change of Character)
A Change of Character occurs when price breaks a pivot level in the opposite direction of the current trend. This is an early warning signal that the trend may be reversing.
  • In an uptrend: Price breaks below a previous swing low → This is unexpected. In a healthy uptrend, lows should hold. When they don't, it suggests buyers are losing control and sellers may be taking over.
  • In a downtrend: Price breaks above a previous swing high → This is unexpected. In a healthy downtrend, highs should hold. When they don't, it suggests sellers are losing control and buyers may be stepping in.

Think of CHoCH as the market's behavior "changing character" — it's no longer acting the way it should if the trend were healthy.

Why BOS and CHoCH Matter

These concepts give you a framework for reading what the market is actually doing:
  • BOS tells you the trend is continuing — stay with it or look for entries in that direction
  • CHoCH warns you the trend may be ending — time to be cautious, take profits, or look for trades in the new direction

By visualizing these breaks directly on your chart, you don't have to guess. You can see at a glance whether the market is trending smoothly (consecutive BOS) or showing signs of reversal (CHoCH).

Why This Approach Works

Most pivot indicators use a "lookback" method — they wait for a certain number of bars (say, 5 or 10) on each side of a candle before confirming it as a pivot. This creates a fixed delay. By the time the pivot appears on your chart, price has already moved on.

This indicator doesn't wait. It confirms pivots the moment price structure proves them. The result is pivots that align with how traders actually read charts — based on breaks of structure, not arbitrary countdowns.

Settings

Configuration
  • Swing Width: Controls how sensitive the detection is. Higher numbers show only major swings; lower numbers capture smaller moves within the structure.


Pivot Settings
  • High/Low Color: Customize the colors of swing high and swing low markers
  • Style: Choose between Triangle or Circle markers
  • Size: Adjust the size of pivot markers (Auto, Tiny, Small, Normal)


Structure Lines
  • Show CHoCH: Toggle Change of Character lines on/off
  • CHoCH Color: Customize the color of CHoCH lines
  • CHoCH Label: Show/hide the "CHoCH" text label
  • Show BOS: Toggle Break of Structure lines on/off
  • BOS Color: Customize the color of BOS lines
  • BOS Label: Show/hide the "BOS" text label


Use Cases
  • See the "skeleton" of price action at a glance
  • Identify potential support and resistance levels
  • Understand if the market is trending or ranging
  • Spot trend continuations with BOS lines
  • Catch early reversal signals with CHoCH lines
  • Build a foundation for more advanced trading strategies


━━━━━━━━━━━━━━━━━━━━━━

Version History

v1.1
  • Added BOS (Break of Structure) lines to visualize trend continuation
  • Added CHoCH (Change of Character) lines to identify potential trend reversals
  • Added toggle options for BOS and CHoCH visibility
  • Added customizable colors for structure lines
  • Added optional labels for BOS and CHoCH


v1.0
  • Initial release
  • Automatic swing high and swing low detection
  • Structure-based pivot confirmation (not fixed lookback)
  • Customizable pivot markers (style, size, colors)
  • Adjustable swing width sensitivity


━━━━━━━━━━━━━━━━━━━━━━

Disclaimer:
This script is provided for educational and informational purposes only. It is not financial advice and does not constitute a recommendation to buy or sell any financial instrument. Always do your own research and trade at your own risk.
Note di rilascio
v1.2

Wick vs Body Break Detection
Not all structure breaks are created equal. A candle that merely wicks through a level tells a different story than one that closes beyond it — and now this indicator shows you the difference at a glance.

When price breaks a pivot level, the indicator evaluates how it broke:

  • Body break (solid line): Price closed beyond the level. This represents conviction. Traders committed to the move, and the candle finished on the other side. Body breaks tend to signal follow-through — the market has made its decision.
  • Wick break (dashed line): Price pierced the level but closed back inside. This represents rejection or hesitation. The market tested the level, but buyers or sellers stepped in to defend it. Wick breaks often lead to retests or outright reversals.


Why does this matter? Consider a CHoCH that appears after an extended uptrend. If it's a wick break (dashed), the reversal signal is tentative — price tested the swing low but couldn't hold below it. You might wait for confirmation before acting. But if it's a body break (solid), sellers demonstrated real control by closing below the level. The reversal carries more weight.

The same logic applies to BOS. A solid BOS shows the trend continuing with momentum. A dashed BOS suggests the breakout is questionable — price poked through but couldn't commit, which often precedes a pullback to retest the level.

You can customize the line style and width for both scenarios independently, for both CHoCH and BOS lines.

Smarter Pivot Selection
Previously, when price broke structure and the indicator needed to identify the opposing pivot (for example, finding the swing low after a high break), it simply selected the lowest price in the range. This occasionally placed pivots on candles that weren't true swing points — just the absolute extreme.

Now the indicator searches for validated pivots: candles that have a higher low on both sides (for swing lows) or a lower high on both sides (for swing highs). These are actual turning points where price reversed, not just the deepest wick in a selloff.

If no validated pivot exists in the range (common in sharp V-reversals), the indicator falls back to the absolute extreme. This ensures you always get a pivot while preferring structurally meaningful ones when available.

The result is cleaner, more accurate market structure that better reflects how price actually behaved.

Consistent Label Positioning
BOS and CHoCH labels now appear at a fixed position relative to the structure line, eliminating visual inconsistencies across different price scales and timeframes.

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.