Indicator · Pine Script v6 · On the chart

SMC Structure Context

by skipp-dev· code credited to preuss_steffen

The SMC Structure Context indicator overlays visual elements on the price chart to represent the current market structure state.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code93
Settings8inputs
LicenceNone statedfile: MPL-2.0
Last update2 days ago26 Oct 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

93 lines of Pine Script v6 from SMC_Structure_Context.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

SMC_Structure_Context.pine
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © preuss_steffen

//@version=6

// Product role: companion_operator_only. Pro-only structure-context companion outside the Lite default surface.

// ─────────────────────────────────────────────────────────────────
// SMC Structure Context Overlay — visualizes v5.3 structure state
//
// Reads Structure State fields from the generated micro-profiles library:
//   • STRUCTURE_STATE (BULLISH / BEARISH / NEUTRAL)
//   • CHoCH / BOS event markers
//   • Active support / resistance levels
//   • Structure freshness indicator
//
// Keep on a separate pane — independent of trade signals.
// ─────────────────────────────────────────────────────────────────

indicator("SMC Structure Context", overlay = true, max_labels_count = 100, max_lines_count = 50)

import preuss_steffen/smc_micro_profiles_generated/569 as mp

// ── Inputs ──────────────────────────────────────────────────────

var g_st = "Structure Context"
var bool show_state_label    = input.bool(true,  "Show structure state label",  group = g_st)
var bool show_choch_markers  = input.bool(true,  "Show CHoCH markers",          group = g_st)
var bool show_bos_markers    = input.bool(true,  "Show BOS markers",            group = g_st)
var bool show_sr_levels      = input.bool(true,  "Show support/resistance",     group = g_st)
var bool show_fresh_badge    = input.bool(true,  "Show freshness badge",        group = g_st)
var color col_bullish        = input.color(color.new(color.green, 30), "Bullish color",  group = g_st)
var color col_bearish        = input.color(color.new(color.red, 30),   "Bearish color",  group = g_st)
var color col_neutral        = input.color(color.new(color.gray, 50),  "Neutral color",  group = g_st)

// ── Library fields ──────────────────────────────────────────────

string st_state          = mp.STRUCTURE_STATE
bool   st_bull_active    = mp.STRUCTURE_BULL_ACTIVE
bool   st_bear_active    = mp.STRUCTURE_BEAR_ACTIVE
bool   st_choch_bull     = mp.CHOCH_BULL
bool   st_choch_bear     = mp.CHOCH_BEAR
bool   st_bos_bull       = mp.BOS_BULL
bool   st_bos_bear       = mp.BOS_BEAR
string st_last_event     = mp.STRUCTURE_LAST_EVENT
int    st_event_age      = mp.STRUCTURE_EVENT_AGE_BARS
bool   st_fresh          = mp.STRUCTURE_FRESH
float  st_support        = mp.ACTIVE_SUPPORT
float  st_resistance     = mp.ACTIVE_RESISTANCE
bool   st_support_on     = mp.SUPPORT_ACTIVE
bool   st_resistance_on  = mp.RESISTANCE_ACTIVE

// Library freshness check (shared pattern across all companions)
var label stale_badge = na
if barstate.islast
    float asof_year  = str.tonumber(str.substring(mp.ASOF_DATE, 0, 4))
    float asof_month = str.tonumber(str.substring(mp.ASOF_DATE, 5, 7))
    float asof_day   = str.tonumber(str.substring(mp.ASOF_DATE, 8, 10))
    int asof_ts      = timestamp(int(asof_year), int(asof_month), int(asof_day))
    int days_old     = math.floor((timenow - asof_ts) / 86400000)
    if days_old > 2
        if not na(stale_badge)
            label.delete(stale_badge)
        stale_badge := label.new(bar_index, low,
            "⚠ Library " + str.tostring(days_old) + "d old",
            color = color.new(color.red, 40), textcolor = color.white,
            style = label.style_label_up, size = size.tiny)

// ── State color helper ──────────────────────────────────────────

color state_color = st_state == "BULLISH" ? col_bullish : st_state == "BEARISH" ? col_bearish : col_neutral

// ── CHoCH / BOS markers ────────────────────────────────────────

plotshape(show_choch_markers and st_choch_bull, "CHoCH Bull", shape.triangleup,   location.belowbar, col_bullish, text = "CHoCH", size = size.small)
plotshape(show_choch_markers and st_choch_bear, "CHoCH Bear", shape.triangledown, location.abovebar, col_bearish, text = "CHoCH", size = size.small)
plotshape(show_bos_markers   and st_bos_bull,   "BOS Bull",   shape.triangleup,   location.belowbar, col_bullish, text = "BOS",   size = size.tiny)
plotshape(show_bos_markers   and st_bos_bear,   "BOS Bear",   shape.triangledown, location.abovebar, col_bearish, text = "BOS",   size = size.tiny)

// ── Support / Resistance lines ──────────────────────────────────

plot(show_sr_levels and st_support_on    ? st_support    : na, "Support",    col_bullish, 1, plot.style_linebr)
plot(show_sr_levels and st_resistance_on ? st_resistance : na, "Resistance", col_bearish, 1, plot.style_linebr)

// ── Freshness badge ─────────────────────────────────────────────

plotshape(show_fresh_badge and st_fresh, "Fresh", shape.diamond, location.abovebar, color.new(color.orange, 20), size = size.tiny)

// ── Status label ────────────────────────────────────────────────

if barstate.islast and show_state_label
    string lbl_text = st_state + " | " + st_last_event + " (age " + str.tostring(st_event_age) + ")"
    label.new(bar_index, st_resistance_on ? st_resistance : close, lbl_text, color = color.new(color.black, 80), textcolor = chart.fg_color, size = size.small, style = label.style_label_down)

Overview

SMC Structure Context displays a state label indicating bullish, bearish, or neutral conditions, along with markers for change of character (CHoCH) and break of structure (BOS) events. Support and resistance levels are shown when active, along with a freshness badge for recent structure updates. Inputs allow users to enable or disable each visual component independently. The indicator depends on data from an external micro-profiles library and plots directly on the chart without separate panes.

Details

Published by

skipp-dev on GitHub

Code credit

preuss_steffen, as written in the script's header

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

SMC / ICT / price action, Support & resistance

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Show structure state labelbooltrueshow_state_label
Show CHoCH markersbooltrueshow_choch_markers
Show BOS markersbooltrueshow_bos_markers
Show support/resistancebooltrueshow_sr_levels
Show freshness badgebooltrueshow_fresh_badge
Bullish colorcolorcolor.new(color.green, 30)col_bullish
Bearish colorcolorcolor.new(color.red, 30)col_bearish
Neutral colorcolorcolor.new(color.gray, 50)col_neutral
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

ICT Equal Highs and Lows

by ArunKBhaskar
575 stars

This overlay indicator finds pivot highs and lows on the price chart and compares the last two highs and the last two lows. When the percentage difference between a pair is below the Equal HL threshold, it treats them as equal levels and draws a box. Left and

Indicator v5 SMC / ICT / price actionSupport & resistance
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Equal Highs and Lows

DE-tracker

by Allen1212
303 stars

This indicator plots labels on the TradingView price chart to mark ARK Invest's buy and sell trades for the DE stock. Buy transactions appear in green with X1 or X2 multipliers showing the number of ARK ETFs involved on the same day; sells appear in red. The m

Indicator v4 Support & resistanceSMC / ICT / price action
Updated 2 years ago · None stated GitHub repository of DE-tracker

This Pine Script indicator plots a ZigZag on the price chart. It identifies reversal points when price moves more than a set percentage from the last pivot. The script calculates forecasts using zigzag data and labels detected geometric patterns including harm

Indicator v4 TrendSupport & resistance

Golden Bullet Strategy

by TradersPost
218 stars

The Golden Bullet Strategy is an overlay signal indicator based on Smart Money Concepts and time-based liquidity models. It identifies liquidity sweeps of a designated reference session range during a specified hunt window. It then confirms Market Structure Sh

Indicator v6 SMC / ICT / price actionSessions & time
Updated 3 months ago · None stated GitHub repository of Golden Bullet Strategy

Open Source Fractal

by cantolab
183 stars

This indicator implements the Fractal Model concept to plot market structure shifts, liquidity sweeps, and Change in State of Delivery (CISD) levels. It overlays custom higher-timeframe candle previews, open prices, and time markers directly on the price chart

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 2 months ago · MIT GitHub repository of Open Source Fractal

Swing Failure Signals

by Ganador1
154 stars

This indicator calculates pivot highs and pivot lows to detect liquidity sweeps and Swing Failure Patterns. It identifies when price breaks past recent key swing highs or lows within a configurable historical window, then looks for a quick reversal or change i

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 2 months ago · Apache-2.0 GitHub repository of Swing Failure Signals

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers