Indicator · Pine Script v6 · On the chart

SMC Long-Dip Alerts

by skipp-dev· code credited to preuss_steffen

SMC Long-Dip Alerts is an indicator that provides selectable alertcondition() signals for an SMC Long-Dip Suite.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code113
Settings6inputs
LicenceNone statedfile: MPL-2.0
Last update4 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

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

SMC_Long_Dip_Alerts.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: alert companion for SMC Long-Dip Suite. Exposes the 16 lifecycle,
// structure, trust and risk events as individually-selectable alertcondition()
// slots. The Suite itself fires the same events via alert() (a single "Any
// alert() function call" alert) so it stays within TradingView's 64-plot budget;
// this companion restores per-event selection for users who want it.
//
// Sources (no per-event value is invented):
//   - Product state + Zone lifecycle : decoded from the Suite's hidden
//     `BUS StateCode` / `BUS Armed` / `BUS ZoneActive` outputs via input.source,
//     using eng.resolve_core_product_state (the same decoder the Suite uses).
//   - Structure (BOS/CHoCH)          : recomputed locally with the same
//     eng.detect_structure detector and swing length as the Suite.
//   - Trust tier                     : eng.resolve_trust_tier over the published
//     mp.* signal-quality / freshness / provider consts.
//   - Event / Macro / Earnings       : mp.* calendar consts.
// Structure and risk alerts work standalone; product-state and zone alerts
// require the BUS inputs to be bound to the Suite (engine-bound probe below).

indicator("SMC Long-Dip Alerts", overlay = true)

import preuss_steffen/smc_engine_private/5 as eng
import preuss_steffen/smc_micro_profiles_generated/569 as mp
import preuss_steffen/smc_utils/4 as u

// ── Inputs ───────────────────────────────────────────────────────────────────
// Group labels are plain consts — `var` on them is redundant and would only
// inflate the var-budget ledger (tests/test_pine_var_budget_pin.py).
g_gate = 'Alert Gate'
bool bar_close_only = input.bool(true, 'Bar-close only', group = g_gate, tooltip = 'When on, every alert fires only on confirmed (closed) bars — non-repainting. Turn off to allow intrabar firing.')

g_struct = 'Structure'
// No explicit type annotation: eng.detect_structure takes a `simple int`, and
// letting Pine infer the input's qualifier keeps it simple rather than series.
swing_len = input.int(50, 'Swing length', minval = 5, group = g_struct, tooltip = 'Pivot length for the recomputed BOS/CHoCH detector. Keep equal to the Suite for matching structure events.')

g_bus = 'Chart Link - SMC Long-Dip Suite'
// Declared in the Suite's BUS plot() order (SchemaVersion, ZoneActive, Armed,
// StateCode). TradingView lists a source study's outputs in that plot order, so
// matching it here means the dropdown pick for each row moves strictly downwards
// — no scrolling back up while binding.
float src_schema     = input.source(close, 'BUS SchemaVersion', group = g_bus, display = display.none, tooltip = "Connected automatically by SMC Onboarding. Each row binds to the hidden SMC Long-Dip Suite output of the same name, in the Suite's dropdown order.")
float src_zone       = input.source(close, 'BUS ZoneActive',    group = g_bus, display = display.none)
float src_armed      = input.source(close, 'BUS Armed',         group = g_bus, display = display.none)
float src_state_code = input.source(close, 'BUS StateCode',     group = g_bus, display = display.none)

// ── Gate + engine-bound probe ────────────────────────────────────────────────
bool _alertGate = bar_close_only ? barstate.isconfirmed : true
int expected_bus_version = 7001
bool engine_bound = math.round(src_schema) == expected_bus_version

state_on(float v) => not na(v) and v > 0.5

// ── Product state (decoded from BUS StateCode via the Suite's own decoder) ────
string prod_state = engine_bound ? eng.resolve_core_product_state(int(math.round(src_state_code))) : na
// NOTE: Pine function definitions take no return-type prefix — `bool f(...) =>`
// is parsed as a method declaration and fails with CE10152.
prod_changed_to(string s) => engine_bound and prod_state == s and (na(prod_state[1]) or prod_state[1] != s)

// ── Zone lifecycle (from BUS Armed / ZoneActive) ─────────────────────────────
bool armed_now = engine_bound and state_on(src_armed) and not state_on(src_armed[1])
bool zone_invalidated_now = engine_bound and state_on(src_zone[1]) and not state_on(src_zone)

// ── Structure (recomputed with the same detector as the Suite) ───────────────
[_trend, bull_bos_alert, bull_choch_alert, _tx, _ty, _tux, _tu, _hh, bear_bos_alert, bear_choch_alert, _bx, _by, _tdx, _td, _sl, _hx] = eng.detect_structure(swing_len)

// ── Trust tier (recomputed from published mp.* consts, Suite's own resolver) ──
string normalized_signal_freshness = mp.SIGNAL_FRESHNESS == 'very_fresh' ? 'fresh' : mp.SIGNAL_FRESHNESS == 'expired' ? 'stale' : mp.SIGNAL_FRESHNESS
string trust_tier = eng.resolve_trust_tier(mp.SIGNAL_QUALITY_TIER, normalized_signal_freshness, mp.EVENT_PROVIDER_STATUS)
bool trust_degraded = trust_tier == 'Degraded' and (na(trust_tier[1]) or trust_tier[1] != 'Degraded')
bool trust_insufficient = trust_tier == 'Insufficient' and (na(trust_tier[1]) or trust_tier[1] != 'Insufficient')

// ── Event / macro / earnings (from mp.* calendar consts) ─────────────────────
bool symbol_event_risk_active = mp.SYMBOL_EVENT_BLOCKED and (u.csv_has_symbol_token(mp.HIGH_RISK_EVENT_TICKERS, syminfo.ticker, syminfo.tickerid) or u.csv_has_symbol_token(mp.EARNINGS_SOON_TICKERS, syminfo.ticker, syminfo.tickerid))
bool event_risk_active = mp.MARKET_EVENT_BLOCKED or symbol_event_risk_active
bool has_earnings = u.csv_has_symbol_token(mp.EARNINGS_TODAY_TICKERS, syminfo.ticker, syminfo.tickerid)
bool _new_day = ta.change(time('D')) != 0
bool event_risk_alert_now = barstate.isrealtime and event_risk_active and (barstate.islastconfirmedhistory[1] or _new_day)

// ── Alerts (individually selectable; all bar-close gated) ────────────────────
// Product state transitions
alertcondition(_alertGate and prod_changed_to('ENTER LONG'),   'SMC: Enter Long',    'SMC Trigger is live. Entry level reached.')
alertcondition(_alertGate and prod_changed_to('READY LONG'),   'SMC: Ready Long',    'SMC Setup is ready. Confirmed reclaim, watching for trigger.')
alertcondition(_alertGate and prod_changed_to('PREPARE LONG'), 'SMC: Prepare Long',  'SMC Setup is preparing. Zone is active, waiting for confirmation.')
alertcondition(_alertGate and prod_changed_to('BLOCKED'),      'SMC: Setup Blocked', 'SMC Setup is now blocked. Invalidation hit or regime issue.')
alertcondition(_alertGate and prod_changed_to('WAIT'),         'SMC: Wait',          'No active setup — back to wait state.')

// Structure break alerts
alertcondition(_alertGate and bull_bos_alert,   'SMC: Bullish BOS',   'Bullish Break of Structure confirmed. Trend continuation signal.')
alertcondition(_alertGate and bull_choch_alert, 'SMC: Bullish CHoCH', 'Bullish Change of Character confirmed. Potential trend reversal to the upside.')
alertcondition(_alertGate and bear_choch_alert, 'SMC: Bearish CHoCH', 'Bearish Change of Character confirmed. Potential trend reversal to the downside.')
alertcondition(_alertGate and bear_bos_alert,   'SMC: Bearish BOS',   'Bearish Break of Structure confirmed. Downtrend continuation signal.')

// Zone lifecycle alerts
alertcondition(_alertGate and armed_now,            'SMC: Zone Armed',       'A bullish zone has been armed. Price reclaimed a demand zone — watching for confirmation.')
alertcondition(_alertGate and zone_invalidated_now, 'SMC: Zone Invalidated', 'Active zone setup invalidated. Price broke below invalidation level.')

// Trust & risk alerts
alertcondition(_alertGate and trust_degraded,     'SMC: Trust Degraded',          'Trust tier dropped to degraded')
alertcondition(_alertGate and trust_insufficient, 'SMC: Trust Insufficient',      'Trust tier dropped to insufficient')
alertcondition(_alertGate and event_risk_alert_now,  'SMC: Event Risk Active',       'High-impact macro event blocking trades')
alertcondition(_alertGate and mp.HIGH_IMPACT_MACRO_TODAY and _new_day, 'SMC: High Impact Macro Today', 'High impact macro event today. Reduce position sizes.')
alertcondition(_alertGate and has_earnings and _new_day,               'SMC: Earnings Today',          'This ticker has earnings today. Exercise caution.')

// Minimal on-chart status so the study has a visible footprint when added.
var table status_tbl = table.new(position.bottom_right, 1, 1)
if barstate.islast
    string status = engine_bound ? 'Chart link active' : 'Chart link missing — bind SchemaVersion/StateCode/Armed/ZoneActive'
    table.cell(status_tbl, 0, 0, 'SMC Long-Dip Alerts: ' + status, text_size = size.small, text_color = chart.fg_color)

Overview

SMC Long-Dip Alerts detects structure events such as BOS and CHoCH using a configurable swing length and resolves product state, zone activity, and trust tier from bound BUS inputs. The script draws on the price chart as an overlay and emits individual alerts for lifecycle, structure, trust, and risk events. The bar-close-only setting prevents repainting while the swing length controls structure detection. It requires binding to the SMC Long-Dip Suite for full functionality and serves as a decision-support companion rather than an autonomous trading tool.

Details

Published by

skipp-dev on GitHub

Code credit

preuss_steffen, as written in the script's header

Draws

On the price chart

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
Bar-close onlybooltruebar_close_only
Swing lengthint50swing_len
BUS SchemaVersionsourceclosesrc_schema
BUS ZoneActivesourceclosesrc_zone
BUS Armedsourceclosesrc_armed
BUS StateCodesourceclosesrc_state_code
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

575 stars

The indicator plots ICT displacement candles on the price chart and can switch to retracement scanning. Displacement requires a move larger than a set share of the 14-bar average high-low range, lasting at least a chosen number of bars, with optional close, pr

Indicator v6 SMC / ICT / price actionCandlestick patterns
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Displacement Candles Indicator

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

Fair Value Gaps - Basic

by TradersPost
228 stars

This indicator detects bullish and bearish fair value gaps on the price chart and draws a translucent box for each gap. A bullish gap needs the high two bars back below the current low and a bullish middle candle; a bearish gap uses the opposite gap and a bear

Indicator v6 SMC / ICT / price action
Updated 3 months ago · None stated GitHub repository of Fair Value Gaps - Basic

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 SMC / ICT scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

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

Compare brokers