Indicator · Pine Script v5 · On the chart

Session Highs and Lows Indicator (SMC Sessions, DST-safe)

by tc3oliver

This overlay indicator tracks the high and low of four SMC/ICT killzones in America/New_York time: the Asian range, London open, New York AM, and London close.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code197
Settings16inputs
LicenceMPL-2.0
Last update6 weeks ago10 Sep 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

197 lines of Pine Script v5 from session-highs-and-lows-indicator/main.v1.pine, published under MPL-2.0. Keep the author's credit and licence lines when you reuse it.

main.v1.pine
// TradingView Pine Script V5 Indicator to mark the latest important levels
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © tc3oliver

//@version=5
indicator("Session Highs and Lows Indicator (SMC Sessions, DST-safe)", overlay=true)

// Session 判斷在日線以上沒有意義(一根 K 涵蓋整天),會靜默畫出錯誤的線
if not timeframe.isintraday and barstate.islast
    runtime.error("This indicator requires an intraday timeframe (< 1D).")

// ======== 顯示開關 ========
showLondon       = input.bool(true, "Show London High/Low")
showNewYork      = input.bool(true, "Show New York High/Low")
showAsia         = input.bool(true, "Show Asia High/Low")
showNewYorkClose = input.bool(true, "Show New York Close High/Low")

// ======== 線條樣式設定 ========
londonColor   = input.color(color.new(#47abfd, 70), "London Line Color")
londonWidth   = input.int(1, "London Line Width", minval=1, maxval=5)

newYorkColor  = input.color(color.new(#ff6565, 70), "New York Line Color")
newYorkWidth  = input.int(1, "New York Line Width", minval=1, maxval=5)

nyCloseColor  = input.color(color.new(#ff9f43, 70), "NY Close Line Color")
nyCloseWidth  = input.int(1, "NY Close Line Width", minval=1, maxval=5)

asiaColor     = input.color(color.new(#75ff79, 70), "Asia Line Color")
asiaWidth     = input.int(1, "Asia Line Width", minval=1, maxval=5)


// --- SMC/ICT Sessions in New York time (DST-safe via America/New_York) ---
asianRangeSession = input.session("2000-0000", "Asian Range [NY time]")
londonSession     = input.session("0300-0500", "London Open [NY time]")
newYorkSession    = input.session("0830-1100", "New York AM [NY time]")
nyCloseSession    = input.session("1000-1200", "London Close Killzone (NY time)")

// 是否在各時段內(以 New York 時區判斷,DST 自動處理)
inAsiaSession         = not na(time("", asianRangeSession, "America/New_York"))
inLondonSession       = not na(time("", londonSession,     "America/New_York"))
inNewYorkSession      = not na(time("", newYorkSession,    "America/New_York"))
inNewYorkCloseSession = not na(time("", nyCloseSession,    "America/New_York"))

// Session 切換判斷(用 nz 防第一根 na)
isLondonSessionStart        =  inLondonSession and not nz(inLondonSession[1], false)
isLondonSessionEnd          = not inLondonSession and     nz(inLondonSession[1], false)

isNewYorkSessionStart       =  inNewYorkSession and not nz(inNewYorkSession[1], false)
isNewYorkSessionEnd         = not inNewYorkSession and     nz(inNewYorkSession[1], false)

isAsiaSessionStart          =  inAsiaSession and not nz(inAsiaSession[1], false)
isAsiaSessionEnd            = not inAsiaSession and     nz(inAsiaSession[1], false)

isNewYorkCloseSessionStart  =  inNewYorkCloseSession and not nz(inNewYorkCloseSession[1], false)
isNewYorkCloseSessionEnd    = not inNewYorkCloseSession and     nz(inNewYorkCloseSession[1], false)


// ======== 初始化變數 ========
var float londonHigh = na
var float londonLow = na
var int londonHighBar = na
var int londonLowBar = na
var int londonStartBar = na

var float newYorkHigh = na
var float newYorkLow = na
var int newYorkHighBar = na
var int newYorkLowBar = na
var int newYorkStartBar = na

var float asiaHigh = na
var float asiaLow = na
var int asiaHighBar = na
var int asiaLowBar = na
var int asiaStartBar = na

var float newYorkCloseHigh = na
var float newYorkCloseLow = na
var int newYorkCloseHighBar = na
var int newYorkCloseLowBar = na
var int newYorkCloseStartBar = na

var label londonHighLabel = na
var label londonLowLabel = na
var line londonHighLine = na
var line londonLowLine = na

var label newYorkHighLabel = na
var label newYorkLowLabel = na
var line newYorkHighLine = na
var line newYorkLowLine = na

var label asiaHighLabel = na
var label asiaLowLabel = na
var line asiaHighLine = na
var line asiaLowLine = na

var label newYorkCloseHighLabel = na
var label newYorkCloseLowLabel = na
var line newYorkCloseHighLine = na
var line newYorkCloseLowLine = na

// ======== 更新倫敦 ========
if isLondonSessionStart
    londonHigh := high
    londonLow := low
    londonHighBar := bar_index
    londonLowBar := bar_index
    londonStartBar := bar_index
else if inLondonSession
    if high > londonHigh
        londonHigh := high
        londonHighBar := bar_index
    if low < londonLow
        londonLow := low
        londonLowBar := bar_index
else if isLondonSessionEnd and showLondon
    label.delete(londonHighLabel)
    label.delete(londonLowLabel)
    line.delete(londonHighLine)
    line.delete(londonLowLine)
    londonHighLabel := label.new(londonHighBar, londonHigh, "London Killzone High", yloc=yloc.abovebar, color=londonColor, textcolor=color.white, style=label.style_label_down, size=size.small)
    londonLowLabel  := label.new(londonLowBar,  londonLow,  "London Killzone Low",  yloc=yloc.belowbar, color=londonColor, textcolor=color.white, style=label.style_label_up,   size=size.small)
    londonHighLine := line.new(londonStartBar, londonHigh, bar_index, londonHigh, xloc.bar_index, extend=extend.right, color=londonColor, width=londonWidth, style=line.style_dashed)
    londonLowLine := line.new(londonStartBar, londonLow, bar_index, londonLow, xloc.bar_index, extend=extend.right, color=londonColor, width=londonWidth, style=line.style_dashed)

// ======== 更新紐約 ========
if isNewYorkSessionStart
    newYorkHigh := high
    newYorkLow := low
    newYorkHighBar := bar_index
    newYorkLowBar := bar_index
    newYorkStartBar := bar_index
else if inNewYorkSession
    if high > newYorkHigh
        newYorkHigh := high
        newYorkHighBar := bar_index
    if low < newYorkLow
        newYorkLow := low
        newYorkLowBar := bar_index
else if isNewYorkSessionEnd and showNewYork
    label.delete(newYorkHighLabel)
    label.delete(newYorkLowLabel)
    line.delete(newYorkHighLine)
    line.delete(newYorkLowLine)
    newYorkHighLabel := label.new(newYorkHighBar, newYorkHigh, "New York AM Killzone High", yloc=yloc.abovebar, color=newYorkColor, textcolor=color.white, style=label.style_label_down, size=size.small)
    newYorkLowLabel  := label.new(newYorkLowBar,  newYorkLow,  "New York AM Killzone Low",  yloc=yloc.belowbar, color=newYorkColor, textcolor=color.white, style=label.style_label_up,   size=size.small)
    newYorkHighLine := line.new(newYorkStartBar, newYorkHigh, bar_index, newYorkHigh, xloc.bar_index, extend=extend.right, color=newYorkColor, width=newYorkWidth, style=line.style_dashed)
    newYorkLowLine := line.new(newYorkStartBar, newYorkLow, bar_index, newYorkLow, xloc.bar_index, extend=extend.right, color=newYorkColor, width=newYorkWidth, style=line.style_dashed)

// ======== 更新亞洲(Asian Range, NY 20:00–24:00) ========
if isAsiaSessionStart
    asiaHigh := high
    asiaLow := low
    asiaHighBar := bar_index
    asiaLowBar := bar_index
    asiaStartBar := bar_index
else if inAsiaSession
    if high > asiaHigh
        asiaHigh := high
        asiaHighBar := bar_index
    if low < asiaLow
        asiaLow := low
        asiaLowBar := bar_index
else if isAsiaSessionEnd and showAsia
    label.delete(asiaHighLabel)
    label.delete(asiaLowLabel)
    line.delete(asiaHighLine)
    line.delete(asiaLowLine)
    asiaHighLabel := label.new(asiaHighBar, asiaHigh, "Asian Range High", yloc=yloc.abovebar, color=asiaColor, textcolor=color.white, style=label.style_label_down, size=size.small)
    asiaLowLabel  := label.new(asiaLowBar,  asiaLow,  "Asian Range Low",  yloc=yloc.belowbar, color=asiaColor, textcolor=color.white, style=label.style_label_up,   size=size.small)
    asiaHighLine := line.new(asiaStartBar, asiaHigh, bar_index, asiaHigh, xloc.bar_index, extend=extend.right, color=asiaColor, width=asiaWidth, style=line.style_dashed)
    asiaLowLine := line.new(asiaStartBar, asiaLow, bar_index, asiaLow, xloc.bar_index, extend=extend.right, color=asiaColor, width=asiaWidth, style=line.style_dashed)

// ======== 更新紐約收盤 ========
if isNewYorkCloseSessionStart
    newYorkCloseHigh := high
    newYorkCloseLow := low
    newYorkCloseHighBar := bar_index
    newYorkCloseLowBar := bar_index
    newYorkCloseStartBar := bar_index
else if inNewYorkCloseSession
    if high > newYorkCloseHigh
        newYorkCloseHigh := high
        newYorkCloseHighBar := bar_index
    if low < newYorkCloseLow
        newYorkCloseLow := low
        newYorkCloseLowBar := bar_index
else if isNewYorkCloseSessionEnd and showNewYorkClose
    label.delete(newYorkCloseHighLabel)
    label.delete(newYorkCloseLowLabel)
    line.delete(newYorkCloseHighLine)
    line.delete(newYorkCloseLowLine)
    newYorkCloseHighLabel := label.new(newYorkCloseHighBar, newYorkCloseHigh, "London Close Killzone High", yloc=yloc.abovebar, color=nyCloseColor, textcolor=color.white, style=label.style_label_down, size=size.small)
    newYorkCloseLowLabel  := label.new(newYorkCloseLowBar,  newYorkCloseLow,  "London Close Killzone Low",  yloc=yloc.belowbar, color=nyCloseColor, textcolor=color.white, style=label.style_label_up,   size=size.small)
    newYorkCloseHighLine := line.new(newYorkCloseStartBar, newYorkCloseHigh, bar_index, newYorkCloseHigh, xloc.bar_index, extend=extend.right, color=nyCloseColor, width=nyCloseWidth, style=line.style_dashed)
    newYorkCloseLowLine := line.new(newYorkCloseStartBar, newYorkCloseLow, bar_index, newYorkCloseLow, xloc.bar_index, extend=extend.right, color=nyCloseColor, width=nyCloseWidth, style=line.style_dashed)

Overview

Session Highs and Lows Indicator (SMC Sessions, DST-safe) draws each session’s high and low on the price chart with separate colors and line widths, and users can hide any session or change its window. Session membership follows daylight saving through the New York timezone. It stops with an error on daily and higher charts because a single bar covers a whole day.

Details

Published by

tc3oliver on GitHub

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Sessions & time, Support & resistance, SMC / ICT / price action

Markets

Any symbol

Timeframes

M1-M5, M15-H1, H4 and above

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.

Topics

algorithmic-tradingictpine-scriptpinescriptsmctrading-indicatortradingview

Settings

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

SettingTypeDefaultVariable
Show London High/LowbooltrueshowLondon
Show New York High/LowbooltrueshowNewYork
Show Asia High/LowbooltrueshowAsia
Show New York Close High/LowbooltrueshowNewYorkClose
London Line Colorcolorcolor.new(#47abfd, 70)londonColor
London Line Widthint1londonWidth
New York Line Colorcolorcolor.new(#ff6565, 70)newYorkColor
New York Line Widthint1newYorkWidth
NY Close Line Colorcolorcolor.new(#ff9f43, 70)nyCloseColor
NY Close Line Widthint1nyCloseWidth
Asia Line Colorcolorcolor.new(#75ff79, 70)asiaColor
Asia Line Widthint1asiaWidth
Show all 16 settings
SettingTypeDefaultVariable
Asian Range [NY time]session2000-0000asianRangeSession
London Open [NY time]session0300-0500londonSession
New York AM [NY time]session0830-1100newYorkSession
London Close Killzone (NY time)session1000-1200nyCloseSession
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

This indicator combines six trading tools into a single chart overlay to optimize indicator limits. It calculates Bollinger Bands, projects weekend price boundaries, plots market structure elements like order blocks, breaker blocks, and MSB lines, marks New Yo

Indicator v6 Support & resistanceSMC / ICT / price action Repaints
19 stars

This indicator highlights Inner Circle Trader (ICT) killzones and key session pivot points directly on the price chart. It projects shaded boxes for specific trading sessions, including Asia, London, NY AM, NY Lunch, and NY PM, to help traders identify high-li

Indicator v5 SMC / ICT / price actionSessions & time
Updated 3 years ago · MIT GitHub repository of ICT Killzones & Pivots

Bandz Session Ranges + ORG + Opening Prices plots trading session ranges, killzones, opening RTH gaps, standard deviation projections, and key opening prices directly on the price chart. It calculates gap ranges based on prior regular trading hours close sourc

Indicator v6 Sessions & timeSupport & resistance
Updated 2 weeks ago · MPL-2.0 GitHub repository of Bandz Session Ranges + ORG + Opening Prices

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