OPEN-SOURCE SCRIPT
Market Structure (BOS / CHOCH), Advanced & Improved

Market Structure (BOS / CHOCH)
A clean, dual-layer market structure tool that labels Break of Structure and Change of Character from a single, internally consistent trend engine, then projects the resting liquidity those swings leave behind.
The core idea
BOS and CHOCH are the same break. What separates them is direction relative to the current trend, so this script tracks one trend state and derives the label from it:
Because both signals come from one state machine, you never get contradictory labels: a break with the trend is always BOS, a break against it is always CHOCH.
Dual-layer structure
The engine runs twice at the same time:
This lets you see a minor bullish BOS unfolding inside a major downtrend, which is the context most single-length tools miss.
Liquidity pools
Every unbroken swing high (buy-side) and swing low (sell-side) is projected to the right as a resting liquidity line, and removed the moment price wicks through it. What stays on screen is only live, untaken liquidity, the levels most likely to be targeted next.
Features
Inputs
How to use
Notes
Swing pivots confirm a fixed number of bars after they print, which is inherent to all structure tools and not repainting. On the live, unclosed bar a break can update until the bar closes, so set alerts to "Once Per Bar Close" for confirmed signals.
This script is a market analysis tool, not financial advice. Always do your own research and manage risk.
A clean, dual-layer market structure tool that labels Break of Structure and Change of Character from a single, internally consistent trend engine, then projects the resting liquidity those swings leave behind.
The core idea
BOS and CHOCH are the same break. What separates them is direction relative to the current trend, so this script tracks one trend state and derives the label from it:
- BOS (Break of Structure) : price breaks a swing level in the direction of the trend. Continuation.
- CHOCH (Change of Character) : price breaks a swing level against the trend. Reversal, and it flips the trend state.
Because both signals come from one state machine, you never get contradictory labels: a break with the trend is always BOS, a break against it is always CHOCH.
Dual-layer structure
The engine runs twice at the same time:
- Swing structure (longer pivot length) : the major skeleton, drawn bold, with trailing watched-level lines and HH / HL / LH / LL swing labels.
- Internal structure (shorter pivot length) : the minor continuation breaks inside each swing leg, drawn thin and faded so they read as secondary.
This lets you see a minor bullish BOS unfolding inside a major downtrend, which is the context most single-length tools miss.
Liquidity pools
Every unbroken swing high (buy-side) and swing low (sell-side) is projected to the right as a resting liquidity line, and removed the moment price wicks through it. What stays on screen is only live, untaken liquidity, the levels most likely to be targeted next.
Features
- BOS / CHOCH detection with a single coherent trend state
- Dual-layer swing and internal structure
- Trailing lines marking the exact levels currently being watched
- HH / HL / LH / LL swing labels, color coded by structural meaning
- Buy-side and sell-side liquidity pools with auto removal on sweep
- Top-right trend table showing the swing and internal trend state
- Close or Wick break confirmation
- Eight alert conditions: swing and internal, BOS and CHOCH, bullish and bearish
Inputs
- Swing length and Internal length : pivot lookback for each layer. Lower values catch more structure, higher values show only major moves.
- Break confirmation : Close requires a close beyond the level, Wick accepts any wick beyond it.
- Toggles for BOS, CHOCH, active levels, swing labels, liquidity, internal layer and the trend table.
How to use
- Trade with the swing trend, use internal CHOCH for early reversal warnings and internal BOS for continuation entries.
- Watch the liquidity pools as targets, a sweep of one followed by a CHOCH in the opposite direction is a classic reversal setup.
- Tune the swing length to your timeframe so the major structure matches the moves you actually trade.
Notes
Swing pivots confirm a fixed number of bars after they print, which is inherent to all structure tools and not repainting. On the live, unclosed bar a break can update until the bar closes, so set alerts to "Once Per Bar Close" for confirmed signals.
This script is a market analysis tool, not financial advice. Always do your own research and manage risk.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Confluencer
Systematic & Discretionary Trader
Building precision tools for serious market analysis.
The Confluence Array — Indicator Suite for futures, crypto & forex traders.
Systematic & Discretionary Trader
Building precision tools for serious market analysis.
The Confluence Array — Indicator Suite for futures, crypto & forex traders.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Confluencer
Systematic & Discretionary Trader
Building precision tools for serious market analysis.
The Confluence Array — Indicator Suite for futures, crypto & forex traders.
Systematic & Discretionary Trader
Building precision tools for serious market analysis.
The Confluence Array — Indicator Suite for futures, crypto & forex traders.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.