OPEN-SOURCE SCRIPT
HTF + LTF Market Structure ICT

HTF + LTF Market Structure ICT
A dual-stream ICT-style market structure tool that detects MSS (Change of Character) and BOS (Break of Structure) events on both a higher timeframe and the current chart timeframe simultaneously — so you can read HTF context and LTF structure on a single chart.
What it does
The indicator runs the same fractal-based structure detector twice in parallel:
HTF stream (default M15) — runs via request.security with lookahead_off, so events are confirmed at the HTF candle close. Each event renders as a small labeled ribbon tag (e.g. M15 CHoCH ↑) on the LTF bar where the HTF candle closed. Bull tags sit below the bar, bear tags above. No projected lines.
LTF stream — runs on the chart TF directly. Each event renders as a break-level line spanning the broken fractal pivot to the firing bar, plus a minimal CHoCH / BOS text label at the line's midpoint — colored text only, no background fill. Bull text floats above the line, bear below.
Each stream tracks its own trend state, so the HTF and LTF can disagree — that disagreement is the actionable read (e.g. HTF still bullish while LTF just printed a CHoCH down = first sign of a pullback against trend).
How structure is classified
Each stream maintains its own directional bias:
MSS / CHoCH — the first break against the prior structural trend (reversal signal).
BOS — a break in the same direction as the current trend (continuation).
The very first event of each stream is classified as MSS by default since there's no prior reference. Line style differs: solid for MSS, dashed for BOS by default.
Detection logic
A fractal swing pivot is confirmed when a high/low is the extreme over a configurable length (default 5).
A break fires when the bar's close crosses through the most recent unbroken fractal (above for bull, below for bear), with barstate.isconfirmed so events don't repaint.
Auto-suppression
When the chart timeframe equals the chosen HTF (e.g. you're viewing the M15 chart with HTF = M15), the HTF ribbon is hidden — both streams would otherwise detect the exact same events on the same bars.
Inputs
HTF stream — HTF (15min / 30min / 1H / 4H / 1D), fractal length, MSS / BOS toggles
LTF stream — fractal length, MSS / BOS toggles
Display — line on/off, forward-extend latest line, LTF text on/off, history depth
Style — line styles (MSS solid / BOS dashed), line width, HTF ribbon size + transparency, LTF text size, bull / bear colors
Alerts
Ten preconfigured alertconditions:
HTF Bull CHoCH / Bear CHoCH / Bull BOS / Bear BOS
LTF Bull CHoCH / Bear CHoCH / Bull BOS / Bear BOS
LTF bull aligned with HTF-bull bias (confluence)
LTF bear aligned with HTF-bear bias (confluence)
Suggested use
Works on any symbol or timeframe. Default M15 HTF on an M1 / M3 / M5 chart gives a clean intraday read; for swing structure, try chart TF = 1H with HTF = 4H or 1D. The fractal length controls signal density — drop to 3 for more frequent events on lower-volatility instruments, raise to 7+ to filter for stronger swings.
This is a structure visualization tool, not a trading system — it doesn't take trades, manage risk, or compute lot sizes. Use it to read HTF context and LTF trigger timing.
Disclaimer
This script is for educational and analytical purposes only. It does not provide financial advice and does not guarantee profitability. Past performance of any structural pattern does not imply future results. Always combine with your own analysis and risk management.
Quick adjustments you might want before publishing: short title for TV (e.g. HTF+LTF MSS ICT), and grab a chart screenshot showing both HTF ribbons and LTF text active.
A dual-stream ICT-style market structure tool that detects MSS (Change of Character) and BOS (Break of Structure) events on both a higher timeframe and the current chart timeframe simultaneously — so you can read HTF context and LTF structure on a single chart.
What it does
The indicator runs the same fractal-based structure detector twice in parallel:
HTF stream (default M15) — runs via request.security with lookahead_off, so events are confirmed at the HTF candle close. Each event renders as a small labeled ribbon tag (e.g. M15 CHoCH ↑) on the LTF bar where the HTF candle closed. Bull tags sit below the bar, bear tags above. No projected lines.
LTF stream — runs on the chart TF directly. Each event renders as a break-level line spanning the broken fractal pivot to the firing bar, plus a minimal CHoCH / BOS text label at the line's midpoint — colored text only, no background fill. Bull text floats above the line, bear below.
Each stream tracks its own trend state, so the HTF and LTF can disagree — that disagreement is the actionable read (e.g. HTF still bullish while LTF just printed a CHoCH down = first sign of a pullback against trend).
How structure is classified
Each stream maintains its own directional bias:
MSS / CHoCH — the first break against the prior structural trend (reversal signal).
BOS — a break in the same direction as the current trend (continuation).
The very first event of each stream is classified as MSS by default since there's no prior reference. Line style differs: solid for MSS, dashed for BOS by default.
Detection logic
A fractal swing pivot is confirmed when a high/low is the extreme over a configurable length (default 5).
A break fires when the bar's close crosses through the most recent unbroken fractal (above for bull, below for bear), with barstate.isconfirmed so events don't repaint.
Auto-suppression
When the chart timeframe equals the chosen HTF (e.g. you're viewing the M15 chart with HTF = M15), the HTF ribbon is hidden — both streams would otherwise detect the exact same events on the same bars.
Inputs
HTF stream — HTF (15min / 30min / 1H / 4H / 1D), fractal length, MSS / BOS toggles
LTF stream — fractal length, MSS / BOS toggles
Display — line on/off, forward-extend latest line, LTF text on/off, history depth
Style — line styles (MSS solid / BOS dashed), line width, HTF ribbon size + transparency, LTF text size, bull / bear colors
Alerts
Ten preconfigured alertconditions:
HTF Bull CHoCH / Bear CHoCH / Bull BOS / Bear BOS
LTF Bull CHoCH / Bear CHoCH / Bull BOS / Bear BOS
LTF bull aligned with HTF-bull bias (confluence)
LTF bear aligned with HTF-bear bias (confluence)
Suggested use
Works on any symbol or timeframe. Default M15 HTF on an M1 / M3 / M5 chart gives a clean intraday read; for swing structure, try chart TF = 1H with HTF = 4H or 1D. The fractal length controls signal density — drop to 3 for more frequent events on lower-volatility instruments, raise to 7+ to filter for stronger swings.
This is a structure visualization tool, not a trading system — it doesn't take trades, manage risk, or compute lot sizes. Use it to read HTF context and LTF trigger timing.
Disclaimer
This script is for educational and analytical purposes only. It does not provide financial advice and does not guarantee profitability. Past performance of any structural pattern does not imply future results. Always combine with your own analysis and risk management.
Quick adjustments you might want before publishing: short title for TV (e.g. HTF+LTF MSS ICT), and grab a chart screenshot showing both HTF ribbons and LTF text active.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.