Indicator · Pine Script v6 · Own pane

SMC Session Context

by skipp-dev· code credited to preuss_steffen

SMC Session Context is an indicator that tracks trading sessions across Tokyo, London, and New York time zones.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code135
Settings5inputs
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

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

SMC_Session_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 confirmed session context.
//
// Session membership is evaluated in each market's IANA timezone. TradingView
// therefore applies US and European daylight-saving transitions independently.

indicator("SMC Session Context", overlay = false, max_labels_count = 20)

const int SESSION_OUTSIDE = 0
const int SESSION_ASIA = 1
const int SESSION_LONDON = 2
const int SESSION_NY_AM = 3
const int SESSION_NY_PM = 4

const string TZ_NEW_YORK = "America/New_York"
const string TZ_LONDON = "Europe/London"
const string TZ_TOKYO = "Asia/Tokyo"

string GROUP_VIEW = "Session Context"
bool show_session_table = input.bool(true, "Show session status", group = GROUP_VIEW)
bool show_killzone_bg = input.bool(true, "Show active-session background", group = GROUP_VIEW)
bool show_mss_markers = input.bool(true, "Show confirmed MSS markers", group = GROUP_VIEW)
bool show_context_score = input.bool(true, "Show context score", group = GROUP_VIEW)
int opening_minutes = input.int(30, "Opening-range minutes", minval = 15, maxval = 60, step = 15, group = GROUP_VIEW)

_in_session(string session_spec, string timezone) =>
    not na(time(timeframe.period, session_spec, timezone))

_session_code() =>
    bool ny_am = _in_session("0930-1200:23456", TZ_NEW_YORK)
    bool ny_pm = _in_session("1300-1600:23456", TZ_NEW_YORK)
    bool london = _in_session("0800-1200:23456", TZ_LONDON)
    bool asia = _in_session("0000-0900:23456", TZ_TOKYO)
    ny_am ? SESSION_NY_AM : ny_pm ? SESSION_NY_PM : london ? SESSION_LONDON : asia ? SESSION_ASIA : SESSION_OUTSIDE

_session_label(int code) =>
    code == SESSION_ASIA ? "Asia" : code == SESSION_LONDON ? "London" : code == SESSION_NY_AM ? "NY AM" : code == SESSION_NY_PM ? "NY PM" : "Outside"

int detected_session = _session_code()

var int active_session = SESSION_OUTSIDE
var int session_start = na
var int source_close = na
var float session_high = na
var float session_low = na
var float previous_session_high = na
var float previous_session_low = na
var float cumulative_volume = 0.0
var float cumulative_price_volume = 0.0
var float opening_high = na
var float opening_low = na
var bool opening_active = false
var bool session_mss_bull = false
var bool session_mss_bear = false
var int direction_bias = 0
var int context_score = 0

bool session_changed = detected_session != active_session

if barstate.isconfirmed
    session_mss_bull := false
    session_mss_bear := false
    if session_changed
        if active_session != SESSION_OUTSIDE
            previous_session_high := session_high
            previous_session_low := session_low
        active_session := detected_session
        session_start := detected_session == SESSION_OUTSIDE ? na : time
        session_high := detected_session == SESSION_OUTSIDE ? na : high
        session_low := detected_session == SESSION_OUTSIDE ? na : low
        cumulative_volume := detected_session == SESSION_OUTSIDE ? 0.0 : volume
        cumulative_price_volume := detected_session == SESSION_OUTSIDE ? 0.0 : hlc3 * volume
        opening_high := detected_session == SESSION_OUTSIDE ? na : high
        opening_low := detected_session == SESSION_OUTSIDE ? na : low
    else if active_session != SESSION_OUTSIDE
        session_high := math.max(nz(session_high, high), high)
        session_low := math.min(nz(session_low, low), low)
        cumulative_volume += volume
        cumulative_price_volume += hlc3 * volume

    opening_active := active_session != SESSION_OUTSIDE and time - nz(session_start, time) < opening_minutes * 60000
    if active_session != SESSION_OUTSIDE and opening_active
        opening_high := math.max(nz(opening_high, high), high)
        opening_low := math.min(nz(opening_low, low), low)

    session_mss_bull := active_session != SESSION_OUTSIDE and not na(previous_session_high) and close > previous_session_high and close[1] <= previous_session_high
    session_mss_bear := active_session != SESSION_OUTSIDE and not na(previous_session_low) and close < previous_session_low and close[1] >= previous_session_low

    float session_vwap = cumulative_volume > 0 ? cumulative_price_volume / cumulative_volume : na
    direction_bias := active_session == SESSION_OUTSIDE or na(session_vwap) ? 0 : close > session_vwap and close > open ? 1 : close < session_vwap and close < open ? -1 : 0
    context_score := active_session == SESSION_OUTSIDE ? 0 : direction_bias * 2 + (session_mss_bull ? 2 : 0) - (session_mss_bear ? 2 : 0) + (opening_active ? 1 : 0)
    source_close := time_close

bool in_killzone = active_session != SESSION_OUTSIDE
float confirmed_session_vwap = cumulative_volume > 0 ? cumulative_price_volume / cumulative_volume : na
color score_color = context_score > 0 ? color.new(color.green, 20) : context_score < 0 ? color.new(color.red, 20) : color.new(color.gray, 55)

plot(show_context_score ? context_score : na, "Session Context Score", score_color, 2, plot.style_columns)
hline(0, "Neutral", color.new(color.gray, 70), hline.style_dotted)
bgcolor(show_killzone_bg and in_killzone ? color.new(score_color, 88) : na, title = "Confirmed session")
plotshape(show_mss_markers and session_mss_bull, "Session MSS Bull", shape.triangleup, location.bottom, color.new(color.green, 10), size = size.tiny)
plotshape(show_mss_markers and session_mss_bear, "Session MSS Bear", shape.triangledown, location.top, color.new(color.red, 10), size = size.tiny)

plot(active_session, "Session Code", display = display.data_window)
plot(source_close, "Session Source Close", display = display.data_window)
plot(session_start, "Session Start", display = display.data_window)
plot(session_high, "Session High", display = display.data_window)
plot(session_low, "Session Low", display = display.data_window)
plot(opening_high, "Opening Range High", display = display.data_window)
plot(opening_low, "Opening Range Low", display = display.data_window)
plot(confirmed_session_vwap, "Session VWAP", display = display.data_window)
plot(cumulative_volume, "Session Cumulative Volume", display = display.data_window)
plot(direction_bias, "Session Direction Bias", display = display.data_window)
plot(session_mss_bull ? 1 : 0, "Session MSS Bull Confirmed", display = display.data_window)
plot(session_mss_bear ? 1 : 0, "Session MSS Bear Confirmed", display = display.data_window)

string direction_label = direction_bias > 0 ? "Bullish" : direction_bias < 0 ? "Bearish" : "Neutral"
string freshness_label = barstate.isconfirmed ? "confirmed" : "waiting for close"

var table status = table.new(position.top_right, 2, 5, border_width = 1)
if barstate.islast and show_session_table
    table.cell(status, 0, 0, "Session", bgcolor = color.new(color.gray, 75))
    table.cell(status, 1, 0, _session_label(active_session), bgcolor = color.new(score_color, 75))
    table.cell(status, 0, 1, "State")
    table.cell(status, 1, 1, freshness_label)
    table.cell(status, 0, 2, "Bias")
    table.cell(status, 1, 2, direction_label, text_color = score_color)
    table.cell(status, 0, 3, "Score")
    table.cell(status, 1, 3, str.tostring(context_score))
    table.cell(status, 0, 4, "Timezone")
    table.cell(status, 1, 4, active_session == SESSION_LONDON ? TZ_LONDON : active_session == SESSION_ASIA ? TZ_TOKYO : active_session == SESSION_OUTSIDE ? "—" : TZ_NEW_YORK)

Overview

Operating in a separate pane, it monitors session highs and lows, previous session extremes, cumulative volume, and initial opening ranges. It identifies confirmed market structure shifts (MSS) and calculates a contextual bias score. Configurable options allow users to toggle the session status table, active killzone backgrounds, MSS markers, context score display, and opening-range duration. Designed for intraday market context, it updates structural metrics on confirmed bar closes.

Details

Published by

skipp-dev on GitHub

Code credit

preuss_steffen, as written in the script's header

Type

Indicator, Pine Script v6

Draws

Separate pane below the chart

Category

Sessions & time, SMC / ICT / price action, Screeners & dashboards

Markets

Any symbol

Timeframes

M1-M5, M15-H1

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 session statusbooltrueshow_session_table
Show active-session backgroundbooltrueshow_killzone_bg
Show confirmed MSS markersbooltrueshow_mss_markers
Show context scorebooltrueshow_context_score
Opening-range minutesint30opening_minutes
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

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

This indicator detects and draws the first Fair Value Gap (FVG) that forms in each hourly session based on a selected lower timeframe, with specialized handling for Regular Trading Hours (RTH) confluence windows. It draws FVG range boxes, midpoint lines, hourl

Indicator v5 SMC / ICT / price actionSupport & resistance Repaints

Clusterbreak

by Jferheart
15 stars

This indicator identifies Break of Structure (BOS) and Market Structure Shift (MSS) zones, plotting automated bracket levels on the price chart. It triggers signals when a reversal breaks a swing point formed inside an opposing zone, projecting stop loss and t

Indicator v5 SMC / ICT / price actionSupport & resistance
Updated 4 weeks ago · None stated GitHub repository of Clusterbreak

MyTTFM - Clean

by dbruce1990
12 stars

MyTTFM - Clean draws a higher-timeframe candle overlay on the price chart and marks related ICT fractal structure. It plots configurable HTF candles, period separator lines, midpoint levels, a T-Spot box, and labels for recent C2 and C3 patterns plus swept lev

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 1 year ago · None stated GitHub repository of MyTTFM - Clean
9 stars

Smart Money Dashboard plots key Smart Money Concepts on the price chart, including Order Blocks with mitigation tracking, Fair Value Gaps, and Equal Highs or Lows sweeps. It analyzes Cumulative Volume Delta for divergence and combines multi-timeframe structure

Indicator v6 SMC / ICT / price actionVolume
Updated yesterday · MIT GitHub repository of Smart Money Dashboard

This indicator overlays a market structure dashboard on the price chart. It reads up to seven user-selected timeframes, each with an on/off switch and a trend weight, and shows columns for EMA trend, swing highs and lows, structure, order blocks, and fair valu

Indicator v6 Screeners & dashboardsSMC / ICT / price action
Updated 3 months ago · None stated GitHub repository of Market Structure Dashboard | Flux Charts

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