Indicator · Pine Script v6 · On the chart

Simple Sessions

by haydenfowler· code credited to TheTrdFloor

Simple Sessions highlights major global trading sessions including US, Europe, Tokyo, and a custom user-defined session directly on the price chart.

View on GitHub

GitHub stars3on the repository
Pine versionv6current
Lines of code554
Settings35inputs
LicenceNone statedfile: MPL-2.0
Last update6 weeks ago7 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

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

simple-sessions.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TheTrdFloor
//@version=6
indicator(title='Simple Sessions', shorttitle='Simple Sessions', overlay=true, max_labels_count=500, max_lines_count=200)

showUSBg        = input.bool(title="Background", defval=true, group="US Session Display Settings", inline="us1", display=display.none)
usSessionColor  = input.color(title="", defval=color.rgb(229, 204, 255, 85), group="US Session Display Settings", inline="us1", tooltip="Background highlight colour for the US session.", display=display.none)
showUSSession   = input.bool(title="US High/Low Lines", defval=true, group="US Session Display Settings", inline="us2", display=display.none)
usLineColor     = input.color(title="", defval=color.rgb(160, 100, 240, 55), group="US Session Display Settings", inline="us2", tooltip="Colour for US session high/low lines.", display=display.none)
usSessInput     = input.session(title="Local Time (America/New_York)", defval="0800-1600", group="US Session Display Settings", display=display.none)

showEUBg        = input.bool(title="Background", defval=true, group="EU Session Display Settings", inline="eu1", display=display.none)
euSessionColor  = input.color(title="", defval=color.rgb(204, 229, 255, 85), group="EU Session Display Settings", inline="eu1", tooltip="Background highlight colour for the EU session.", display=display.none)
showEUSession   = input.bool(title="EU High/Low Lines", defval=true, group="EU Session Display Settings", inline="eu2", display=display.none)
euLineColor     = input.color(title="", defval=color.rgb(80, 160, 240, 55), group="EU Session Display Settings", inline="eu2", tooltip="Colour for EU session high/low lines.", display=display.none)
euSessInput     = input.session(title="Local Time (Europe/London)", defval="0800-1700", group="EU Session Display Settings", display=display.none)

showMixedSession  = input.bool(title="Mixed (US/Europe) Session", defval=false, group="EU/US Mixed Session Display Settings", inline="mix", display=display.none)
mixedSessionColor = input.color(title="", defval=color.rgb(150, 150, 255, 85), group="EU/US Mixed Session Display Settings", inline="mix", tooltip="Background highlight colour for the US/EU overlap session.\n\nNote: This session is the calculated overlap of the US and EU sessions above, so there is no custom time window for this session.", display=display.none)

showAUSession  = false
auSessionColor = color.rgb(0, 0, 0, 100)
auSessInput    = "0000-0000"

showJPBg        = input.bool(title="Background", defval=true, group="JP Session Display Settings", inline="jp1", display=display.none)
jpSessionColor  = input.color(title="", defval=color.rgb(255, 255, 204, 75), group="JP Session Display Settings", inline="jp1", tooltip="Background highlight colour for the Asia/Tokyo session.", display=display.none)
showJPSession   = input.bool(title="JP High/Low Lines", defval=true, group="JP Session Display Settings", inline="jp2", display=display.none)
jpLineColor     = input.color(title="", defval=color.rgb(220, 190, 30, 55), group="JP Session Display Settings", inline="jp2", tooltip="Colour for Asia session high/low lines.", display=display.none)
jpSessInput     = input.session(title="Local Time (Asia/Tokyo)", defval="0800-1600", group="JP Session Display Settings", display=display.none)

showCustBg          = input.bool(title="Background", defval=false, group="User-Defined (Custom) Session", inline="cust1", display=display.none)
custSessionColor    = input.color(title="", defval=color.rgb(125, 125, 125, 85), group="User-Defined (Custom) Session", inline="cust1", tooltip="Background highlight colour for the custom session.", display=display.none)
showCustomSession   = input.bool(title="Custom High/Low Lines", defval=false, group="User-Defined (Custom) Session", inline="cust2", display=display.none)
custLineColor       = input.color(title="", defval=color.rgb(150, 150, 150, 55), group="User-Defined (Custom) Session", inline="cust2", tooltip="Colour for custom session high/low lines.", display=display.none)
custSessionSession  = input.session(defval="0800-1600", title="Custom Session Time Window", group="User-Defined (Custom) Session", tooltip="Time window for the custom session.", display=display.none)
custSessTimezone    = input.string(defval="Etc/UTC", title="Custom Session Timezone",
     options=["UTC", "America/Los_Angeles", "America/Phoenix", "America/Vancouver", "America/El_Salvador", "America/Bogota", "America/Chicago", "America/New_York", "America/Toronto",
             "America/Argentina/Buenos_Aires", "America/Sao_Paulo", "Etc/UTC", "GMT", "Europe/London", "Europe/Berlin", "Europe/Madrid", "Europe/Paris", "Europe/Warsaw", "Europe/Athens",
             "Europe/Moscow", "Asia/Tehran", "Asia/Dubai", "Asia/Ashkhabad", "Asia/Kolkata", "Asia/Almaty", "Asia/Bangkok", "Asia/Hong_Kong", "Asia/Shanghai", "Asia/Singapore",
             "Asia/Taipei", "Asia/Seoul", "Asia/Tokyo", "Australia/ACT", "Australia/Adelaide", "Australia/Brisbane", "Australia/Sydney", "Pacific/Auckland", "Pacific/Fakaofo", "Pacific/Chatham", "Pacific/Honolulu"],
     group="User-Defined (Custom) Session", tooltip="Reference timezone for the custom session time window.", display=display.none)

showSessionHiLo     = input.bool(title="Show Session High/Low Lines", defval=true, group="Session High/Low Settings",
     tooltip="Draws lines from the candle that made the session high/low, extending right until price invalidates that level.", display=display.none)
showCurrentSessHiLo = input.bool(title="Show Current Session High/Low", defval=true, group="Session High/Low Settings",
     tooltip="Draws live high/low lines for the session currently in progress. Lines are removed when the session closes.", display=display.none)
hiLoLookback        = input.int(title="Sessions to Display", defval=1, minval=1, maxval=10, group="Session High/Low Settings",
     tooltip="Number of past closed sessions for which to display high/low lines.", display=display.none)
hiLoLineWidth       = input.int(title="Line Width", defval=1, minval=1, maxval=4, group="Session High/Low Settings", display=display.none)
hiLoLineStyle       = input.string(title="Line Style", defval="Solid", options=["Solid", "Dashed", "Dotted"], group="Session High/Low Settings", display=display.none)

incSun  = input.bool(defval=false, title="Sunday",    group="Session Days of the Week", display=display.none)
incMon  = input.bool(defval=true,  title="Monday",    group="Session Days of the Week", display=display.none)
incTue  = input.bool(defval=true,  title="Tuesday",   group="Session Days of the Week", display=display.none)
incWed  = input.bool(defval=true,  title="Wednesday", group="Session Days of the Week", display=display.none)
incThur = input.bool(defval=true,  title="Thursday",  group="Session Days of the Week", display=display.none)
incFri  = input.bool(defval=true,  title="Friday",    group="Session Days of the Week", display=display.none)
incSat  = input.bool(defval=false, title="Saturday",  group="Session Days of the Week", display=display.none)

sessionDays = (incSun ? "1" : "") + (incMon ? "2" : "") + (incTue ? "3" : "") + (incWed ? "4" : "") + (incThur ? "5" : "") + (incFri ? "6" : "") + (incSat ? "7" : "")

usSession   = usSessInput        + ":" + sessionDays
euSession   = euSessInput        + ":" + sessionDays
auSession   = auSessInput        + ":" + sessionDays
jpSession   = jpSessInput        + ":" + sessionDays
custSession = custSessionSession + ":" + sessionDays

isInSession(simple string session, simple string ref_timezone) =>
    timeframe.isintraday and not na(time(timeframe.period, session, ref_timezone))

isUSSession        = isInSession(usSession,   "America/New_York")
isEUSession        = isInSession(euSession,   "Europe/London")
isAUSession        = isInSession(auSession,   "Australia/Sydney")
isJPSession        = isInSession(jpSession,   "Asia/Tokyo")
isCustomSession    = isInSession(custSession, custSessTimezone)
isUSEUMixedSession = isUSSession and isEUSession

lineStyleVal = hiLoLineStyle == "Dashed" ? line.style_dashed : hiLoLineStyle == "Dotted" ? line.style_dotted : line.style_solid

nullColor = color.rgb(0, 0, 0, 100)
bgcolor(title="US Session",          color=showUSBg         ? isUSSession        ? usSessionColor    : nullColor : nullColor, editable=false)
bgcolor(title="EU Session",          color=showEUBg         ? isEUSession        ? euSessionColor    : nullColor : nullColor, editable=false)
bgcolor(title="AU Session",          color=showAUSession    ? isAUSession        ? auSessionColor    : nullColor : nullColor, editable=false)
bgcolor(title="JP Session",          color=showJPBg         ? isJPSession        ? jpSessionColor    : nullColor : nullColor, editable=false)
bgcolor(title="US/EU Mixed Session", color=showMixedSession ? isUSEUMixedSession ? mixedSessionColor : nullColor : nullColor, editable=false)
bgcolor(title="User-Defined Session",color=showCustBg       ? isCustomSession    ? custSessionColor  : nullColor : nullColor, editable=false)

// ─── JP/Asia Session High/Low Lines ───────────────────────────────────────────
var float   jpSessHigh     = na
var float   jpSessLow      = na
var float   jpSessOpen     = na
var int     jpSessHighBar  = na
var int     jpSessLowBar   = na
var bool    jpWasInSess    = false
var line    jpOpenLine     = na
var line    jpCurrHighLine = na
var line    jpCurrLowLine  = na
var line[]  jpHighLines    = array.new_line()
var line[]  jpLowLines    = array.new_line()
var float[] jpHighLevels  = array.new_float()
var float[] jpLowLevels   = array.new_float()
var bool[]  jpHighDone    = array.new_bool()
var bool[]  jpLowDone     = array.new_bool()

if isJPSession and not jpWasInSess
    if showSessionHiLo and showJPSession and array.size(jpHighLines) > 0
        for i = 0 to array.size(jpHighLines) - 1
            if not array.get(jpHighDone, i)
                line.set_x2(array.get(jpHighLines, i), bar_index)
                array.set(jpHighDone, i, true)
        for i = 0 to array.size(jpLowLines) - 1
            if not array.get(jpLowDone, i)
                line.set_x2(array.get(jpLowLines, i), bar_index)
                array.set(jpLowDone, i, true)
    jpSessHighBar := bar_index
    jpSessLowBar  := bar_index
    jpSessOpen    := open
    jpSessHigh    := high
    jpSessLow     := low
    if showSessionHiLo and showJPSession
        if not na(jpOpenLine)
            line.delete(jpOpenLine)
        jpOpenLine := line.new(bar_index, jpSessOpen, bar_index, jpSessOpen,
                               color=jpLineColor, style=line.style_dashed,
                               width=hiLoLineWidth, extend=extend.right)
    if showCurrentSessHiLo and showJPSession
        if not na(jpCurrHighLine)
            line.delete(jpCurrHighLine)
        if not na(jpCurrLowLine)
            line.delete(jpCurrLowLine)
        jpCurrHighLine := line.new(bar_index, jpSessHigh, bar_index, jpSessHigh,
                                   color=jpLineColor, style=lineStyleVal, width=hiLoLineWidth)
        jpCurrLowLine  := line.new(bar_index, jpSessLow,  bar_index, jpSessLow,
                                   color=jpLineColor, style=lineStyleVal, width=hiLoLineWidth)

if isJPSession
    if high > jpSessHigh
        jpSessHigh    := high
        jpSessHighBar := bar_index
    if low < jpSessLow
        jpSessLow    := low
        jpSessLowBar := bar_index
    if showCurrentSessHiLo and showJPSession
        if not na(jpCurrHighLine)
            line.set_x1(jpCurrHighLine, jpSessHighBar)
            line.set_x2(jpCurrHighLine, bar_index)
            line.set_y1(jpCurrHighLine, jpSessHigh)
            line.set_y2(jpCurrHighLine, jpSessHigh)
        if not na(jpCurrLowLine)
            line.set_x1(jpCurrLowLine, jpSessLowBar)
            line.set_x2(jpCurrLowLine, bar_index)
            line.set_y1(jpCurrLowLine, jpSessLow)
            line.set_y2(jpCurrLowLine, jpSessLow)

if not isJPSession and jpWasInSess
    if showCurrentSessHiLo and showJPSession
        if not na(jpCurrHighLine)
            line.delete(jpCurrHighLine)
            jpCurrHighLine := na
        if not na(jpCurrLowLine)
            line.delete(jpCurrLowLine)
            jpCurrLowLine  := na
    if showSessionHiLo and showJPSession
        if not na(jpOpenLine)
            line.delete(jpOpenLine)
            jpOpenLine := na
        _h = line.new(jpSessHighBar, jpSessHigh, bar_index, jpSessHigh,
                      color=jpLineColor, style=lineStyleVal, width=hiLoLineWidth)
        _l = line.new(jpSessLowBar,  jpSessLow,  bar_index, jpSessLow,
                      color=jpLineColor, style=lineStyleVal, width=hiLoLineWidth)
        array.push(jpHighLines,  _h)
        array.push(jpLowLines,   _l)
        array.push(jpHighLevels, jpSessHigh)
        array.push(jpLowLevels,  jpSessLow)
        array.push(jpHighDone,   false)
        array.push(jpLowDone,    false)
        if array.size(jpHighLines) > hiLoLookback
            line.delete(array.shift(jpHighLines))
            line.delete(array.shift(jpLowLines))
            array.shift(jpHighLevels)
            array.shift(jpLowLevels)
            array.shift(jpHighDone)
            array.shift(jpLowDone)

if showSessionHiLo and showJPSession and array.size(jpHighLines) > 0
    for i = 0 to array.size(jpHighLines) - 1
        if not array.get(jpHighDone, i)
            ln = array.get(jpHighLines, i)
            if high >= array.get(jpHighLevels, i)
                line.set_x2(ln, bar_index)
                array.set(jpHighDone, i, true)
            else
                line.set_x2(ln, bar_index)
    for i = 0 to array.size(jpLowLines) - 1
        if not array.get(jpLowDone, i)
            ln = array.get(jpLowLines, i)
            if low <= array.get(jpLowLevels, i)
                line.set_x2(ln, bar_index)
                array.set(jpLowDone, i, true)
            else
                line.set_x2(ln, bar_index)

jpWasInSess := isJPSession

// ─── EU/London Session High/Low Lines ─────────────────────────────────────────
var float   euSessHigh     = na
var float   euSessLow      = na
var float   euSessOpen     = na
var int     euSessHighBar  = na
var int     euSessLowBar   = na
var bool    euWasInSess    = false
var line    euOpenLine     = na
var line    euCurrHighLine = na
var line    euCurrLowLine  = na
var line[]  euHighLines    = array.new_line()
var line[]  euLowLines    = array.new_line()
var float[] euHighLevels  = array.new_float()
var float[] euLowLevels   = array.new_float()
var bool[]  euHighDone    = array.new_bool()
var bool[]  euLowDone     = array.new_bool()

if isEUSession and not euWasInSess
    if showSessionHiLo and showEUSession and array.size(euHighLines) > 0
        for i = 0 to array.size(euHighLines) - 1
            if not array.get(euHighDone, i)
                line.set_x2(array.get(euHighLines, i), bar_index)
                array.set(euHighDone, i, true)
        for i = 0 to array.size(euLowLines) - 1
            if not array.get(euLowDone, i)
                line.set_x2(array.get(euLowLines, i), bar_index)
                array.set(euLowDone, i, true)
    euSessHighBar := bar_index
    euSessLowBar  := bar_index
    euSessOpen    := open
    euSessHigh    := high
    euSessLow     := low
    if showSessionHiLo and showEUSession
        if not na(euOpenLine)
            line.delete(euOpenLine)
        euOpenLine := line.new(bar_index, euSessOpen, bar_index, euSessOpen,
                               color=euLineColor, style=line.style_dashed,
                               width=hiLoLineWidth, extend=extend.right)
    if showCurrentSessHiLo and showEUSession
        if not na(euCurrHighLine)
            line.delete(euCurrHighLine)
        if not na(euCurrLowLine)
            line.delete(euCurrLowLine)
        euCurrHighLine := line.new(bar_index, euSessHigh, bar_index, euSessHigh,
                                   color=euLineColor, style=lineStyleVal, width=hiLoLineWidth)
        euCurrLowLine  := line.new(bar_index, euSessLow,  bar_index, euSessLow,
                                   color=euLineColor, style=lineStyleVal, width=hiLoLineWidth)

if isEUSession
    if high > euSessHigh
        euSessHigh    := high
        euSessHighBar := bar_index
    if low < euSessLow
        euSessLow    := low
        euSessLowBar := bar_index
    if showCurrentSessHiLo and showEUSession
        if not na(euCurrHighLine)
            line.set_x1(euCurrHighLine, euSessHighBar)
            line.set_x2(euCurrHighLine, bar_index)
            line.set_y1(euCurrHighLine, euSessHigh)
            line.set_y2(euCurrHighLine, euSessHigh)
        if not na(euCurrLowLine)
            line.set_x1(euCurrLowLine, euSessLowBar)
            line.set_x2(euCurrLowLine, bar_index)
            line.set_y1(euCurrLowLine, euSessLow)
            line.set_y2(euCurrLowLine, euSessLow)

if not isEUSession and euWasInSess
    if showCurrentSessHiLo and showEUSession
        if not na(euCurrHighLine)
            line.delete(euCurrHighLine)
            euCurrHighLine := na
        if not na(euCurrLowLine)
            line.delete(euCurrLowLine)
            euCurrLowLine  := na
    if showSessionHiLo and showEUSession
        if not na(euOpenLine)
            line.delete(euOpenLine)
            euOpenLine := na
        _h = line.new(euSessHighBar, euSessHigh, bar_index, euSessHigh,
                      color=euLineColor, style=lineStyleVal, width=hiLoLineWidth)
        _l = line.new(euSessLowBar,  euSessLow,  bar_index, euSessLow,
                      color=euLineColor, style=lineStyleVal, width=hiLoLineWidth)
        array.push(euHighLines,  _h)
        array.push(euLowLines,   _l)
        array.push(euHighLevels, euSessHigh)
        array.push(euLowLevels,  euSessLow)
        array.push(euHighDone,   false)
        array.push(euLowDone,    false)
        if array.size(euHighLines) > hiLoLookback
            line.delete(array.shift(euHighLines))
            line.delete(array.shift(euLowLines))
            array.shift(euHighLevels)
            array.shift(euLowLevels)
            array.shift(euHighDone)
            array.shift(euLowDone)

if showSessionHiLo and showEUSession and array.size(euHighLines) > 0
    for i = 0 to array.size(euHighLines) - 1
        if not array.get(euHighDone, i)
            ln = array.get(euHighLines, i)
            if high >= array.get(euHighLevels, i)
                line.set_x2(ln, bar_index)
                array.set(euHighDone, i, true)
            else
                line.set_x2(ln, bar_index)
    for i = 0 to array.size(euLowLines) - 1
        if not array.get(euLowDone, i)
            ln = array.get(euLowLines, i)
            if low <= array.get(euLowLevels, i)
                line.set_x2(ln, bar_index)
                array.set(euLowDone, i, true)
            else
                line.set_x2(ln, bar_index)

euWasInSess := isEUSession

// ─── US/NY Session High/Low Lines ─────────────────────────────────────────────
var float   usSessHigh     = na
var float   usSessLow      = na
var float   usSessOpen     = na
var int     usSessHighBar  = na
var int     usSessLowBar   = na
var bool    usWasInSess    = false
var line    usOpenLine     = na
var line    usCurrHighLine = na
var line    usCurrLowLine  = na
var line[]  usHighLines    = array.new_line()
var line[]  usLowLines    = array.new_line()
var float[] usHighLevels  = array.new_float()
var float[] usLowLevels   = array.new_float()
var bool[]  usHighDone    = array.new_bool()
var bool[]  usLowDone     = array.new_bool()

if isUSSession and not usWasInSess
    if showSessionHiLo and showUSSession and array.size(usHighLines) > 0
        for i = 0 to array.size(usHighLines) - 1
            if not array.get(usHighDone, i)
                line.set_x2(array.get(usHighLines, i), bar_index)
                array.set(usHighDone, i, true)
        for i = 0 to array.size(usLowLines) - 1
            if not array.get(usLowDone, i)
                line.set_x2(array.get(usLowLines, i), bar_index)
                array.set(usLowDone, i, true)
    usSessHighBar := bar_index
    usSessLowBar  := bar_index
    usSessOpen    := open
    usSessHigh    := high
    usSessLow     := low
    if showSessionHiLo and showUSSession
        if not na(usOpenLine)
            line.delete(usOpenLine)
        usOpenLine := line.new(bar_index, usSessOpen, bar_index, usSessOpen,
                               color=usLineColor, style=line.style_dashed,
                               width=hiLoLineWidth, extend=extend.right)
    if showCurrentSessHiLo and showUSSession
        if not na(usCurrHighLine)
            line.delete(usCurrHighLine)
        if not na(usCurrLowLine)
            line.delete(usCurrLowLine)
        usCurrHighLine := line.new(bar_index, usSessHigh, bar_index, usSessHigh,
                                   color=usLineColor, style=lineStyleVal, width=hiLoLineWidth)
        usCurrLowLine  := line.new(bar_index, usSessLow,  bar_index, usSessLow,
                                   color=usLineColor, style=lineStyleVal, width=hiLoLineWidth)

if isUSSession
    if high > usSessHigh
        usSessHigh    := high
        usSessHighBar := bar_index
    if low < usSessLow
        usSessLow    := low
        usSessLowBar := bar_index
    if showCurrentSessHiLo and showUSSession
        if not na(usCurrHighLine)
            line.set_x1(usCurrHighLine, usSessHighBar)
            line.set_x2(usCurrHighLine, bar_index)
            line.set_y1(usCurrHighLine, usSessHigh)
            line.set_y2(usCurrHighLine, usSessHigh)
        if not na(usCurrLowLine)
            line.set_x1(usCurrLowLine, usSessLowBar)
            line.set_x2(usCurrLowLine, bar_index)
            line.set_y1(usCurrLowLine, usSessLow)
            line.set_y2(usCurrLowLine, usSessLow)

if not isUSSession and usWasInSess
    if showCurrentSessHiLo and showUSSession
        if not na(usCurrHighLine)
            line.delete(usCurrHighLine)
            usCurrHighLine := na
        if not na(usCurrLowLine)
            line.delete(usCurrLowLine)
            usCurrLowLine  := na
    if showSessionHiLo and showUSSession
        if not na(usOpenLine)
            line.delete(usOpenLine)
            usOpenLine := na
        _h = line.new(usSessHighBar, usSessHigh, bar_index, usSessHigh,
                      color=usLineColor, style=lineStyleVal, width=hiLoLineWidth)
        _l = line.new(usSessLowBar,  usSessLow,  bar_index, usSessLow,
                      color=usLineColor, style=lineStyleVal, width=hiLoLineWidth)
        array.push(usHighLines,  _h)
        array.push(usLowLines,   _l)
        array.push(usHighLevels, usSessHigh)
        array.push(usLowLevels,  usSessLow)
        array.push(usHighDone,   false)
        array.push(usLowDone,    false)
        if array.size(usHighLines) > hiLoLookback
            line.delete(array.shift(usHighLines))
            line.delete(array.shift(usLowLines))
            array.shift(usHighLevels)
            array.shift(usLowLevels)
            array.shift(usHighDone)
            array.shift(usLowDone)

if showSessionHiLo and showUSSession and array.size(usHighLines) > 0
    for i = 0 to array.size(usHighLines) - 1
        if not array.get(usHighDone, i)
            ln = array.get(usHighLines, i)
            if high >= array.get(usHighLevels, i)
                line.set_x2(ln, bar_index)
                array.set(usHighDone, i, true)
            else
                line.set_x2(ln, bar_index)
    for i = 0 to array.size(usLowLines) - 1
        if not array.get(usLowDone, i)
            ln = array.get(usLowLines, i)
            if low <= array.get(usLowLevels, i)
                line.set_x2(ln, bar_index)
                array.set(usLowDone, i, true)
            else
                line.set_x2(ln, bar_index)

usWasInSess := isUSSession

// ─── Custom Session High/Low Lines ────────────────────────────────────────────
var float   custSessHigh     = na
var float   custSessLow      = na
var float   custSessOpen     = na
var int     custSessHighBar  = na
var int     custSessLowBar   = na
var bool    custWasInSess    = false
var line    custOpenLine     = na
var line    custCurrHighLine = na
var line    custCurrLowLine  = na
var line[]  custHighLines    = array.new_line()
var line[]  custLowLines    = array.new_line()
var float[] custHighLevels  = array.new_float()
var float[] custLowLevels   = array.new_float()
var bool[]  custHighDone    = array.new_bool()
var bool[]  custLowDone     = array.new_bool()

if isCustomSession and not custWasInSess
    if showSessionHiLo and showCustomSession and array.size(custHighLines) > 0
        for i = 0 to array.size(custHighLines) - 1
            if not array.get(custHighDone, i)
                line.set_x2(array.get(custHighLines, i), bar_index)
                array.set(custHighDone, i, true)
        for i = 0 to array.size(custLowLines) - 1
            if not array.get(custLowDone, i)
                line.set_x2(array.get(custLowLines, i), bar_index)
                array.set(custLowDone, i, true)
    custSessHighBar := bar_index
    custSessLowBar  := bar_index
    custSessOpen    := open
    custSessHigh    := high
    custSessLow     := low
    if showSessionHiLo and showCustomSession
        if not na(custOpenLine)
            line.delete(custOpenLine)
        custOpenLine := line.new(bar_index, custSessOpen, bar_index, custSessOpen,
                                 color=custLineColor, style=line.style_dashed,
                                 width=hiLoLineWidth, extend=extend.right)
    if showCurrentSessHiLo and showCustomSession
        if not na(custCurrHighLine)
            line.delete(custCurrHighLine)
        if not na(custCurrLowLine)
            line.delete(custCurrLowLine)
        custCurrHighLine := line.new(bar_index, custSessHigh, bar_index, custSessHigh,
                                     color=custLineColor, style=lineStyleVal, width=hiLoLineWidth)
        custCurrLowLine  := line.new(bar_index, custSessLow,  bar_index, custSessLow,
                                     color=custLineColor, style=lineStyleVal, width=hiLoLineWidth)

if isCustomSession
    if high > custSessHigh
        custSessHigh    := high
        custSessHighBar := bar_index
    if low < custSessLow
        custSessLow    := low
        custSessLowBar := bar_index
    if showCurrentSessHiLo and showCustomSession
        if not na(custCurrHighLine)
            line.set_x1(custCurrHighLine, custSessHighBar)
            line.set_x2(custCurrHighLine, bar_index)
            line.set_y1(custCurrHighLine, custSessHigh)
            line.set_y2(custCurrHighLine, custSessHigh)
        if not na(custCurrLowLine)
            line.set_x1(custCurrLowLine, custSessLowBar)
            line.set_x2(custCurrLowLine, bar_index)
            line.set_y1(custCurrLowLine, custSessLow)
            line.set_y2(custCurrLowLine, custSessLow)

if not isCustomSession and custWasInSess
    if showCurrentSessHiLo and showCustomSession
        if not na(custCurrHighLine)
            line.delete(custCurrHighLine)
            custCurrHighLine := na
        if not na(custCurrLowLine)
            line.delete(custCurrLowLine)
            custCurrLowLine  := na
    if showSessionHiLo and showCustomSession
        if not na(custOpenLine)
            line.delete(custOpenLine)
            custOpenLine := na
        _h = line.new(custSessHighBar, custSessHigh, bar_index, custSessHigh,
                      color=custLineColor, style=lineStyleVal, width=hiLoLineWidth)
        _l = line.new(custSessLowBar,  custSessLow,  bar_index, custSessLow,
                      color=custLineColor, style=lineStyleVal, width=hiLoLineWidth)
        array.push(custHighLines,  _h)
        array.push(custLowLines,   _l)
        array.push(custHighLevels, custSessHigh)
        array.push(custLowLevels,  custSessLow)
        array.push(custHighDone,   false)
        array.push(custLowDone,    false)
        if array.size(custHighLines) > hiLoLookback
            line.delete(array.shift(custHighLines))
            line.delete(array.shift(custLowLines))
            array.shift(custHighLevels)
            array.shift(custLowLevels)
            array.shift(custHighDone)
            array.shift(custLowDone)

if showSessionHiLo and showCustomSession and array.size(custHighLines) > 0
    for i = 0 to array.size(custHighLines) - 1
        if not array.get(custHighDone, i)
            ln = array.get(custHighLines, i)
            if high >= array.get(custHighLevels, i)
                line.set_x2(ln, bar_index)
                array.set(custHighDone, i, true)
            else
                line.set_x2(ln, bar_index)
    for i = 0 to array.size(custLowLines) - 1
        if not array.get(custLowDone, i)
            ln = array.get(custLowLines, i)
            if low <= array.get(custLowLevels, i)
                line.set_x2(ln, bar_index)
                array.set(custLowDone, i, true)
            else
                line.set_x2(ln, bar_index)

custWasInSess := isCustomSession

Overview

Simple Sessions projects shaded background areas for active session hours and optionally draws high and low price reference lines across historical and current sessions. The indicator also calculates and displays overlap periods between US and European sessions. Settings allow users to customize time windows, timezones, visual styling, lookback periods, and active days of the week.

Details

Published by

haydenfowler on GitHub

Code credit

TheTrdFloor, as written in the script's header

Draws

On the price chart

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
BackgroundbooltrueshowUSBg
usSessionColorcolorcolor.rgb(229, 204, 255, 85)usSessionColor
US High/Low LinesbooltrueshowUSSession
usLineColorcolorcolor.rgb(160, 100, 240, 55)usLineColor
Local Time (America/New_York)session0800-1600usSessInput
BackgroundbooltrueshowEUBg
euSessionColorcolorcolor.rgb(204, 229, 255, 85)euSessionColor
EU High/Low LinesbooltrueshowEUSession
euLineColorcolorcolor.rgb(80, 160, 240, 55)euLineColor
Local Time (Europe/London)session0800-1700euSessInput
Mixed (US/Europe) SessionboolfalseshowMixedSession
mixedSessionColorcolorcolor.rgb(150, 150, 255, 85)mixedSessionColor
Show all 35 settings
SettingTypeDefaultVariable
BackgroundbooltrueshowJPBg
jpSessionColorcolorcolor.rgb(255, 255, 204, 75)jpSessionColor
JP High/Low LinesbooltrueshowJPSession
jpLineColorcolorcolor.rgb(220, 190, 30, 55)jpLineColor
Local Time (Asia/Tokyo)session0800-1600jpSessInput
BackgroundboolfalseshowCustBg
custSessionColorcolorcolor.rgb(125, 125, 125, 85)custSessionColor
Custom High/Low LinesboolfalseshowCustomSession
custLineColorcolorcolor.rgb(150, 150, 150, 55)custLineColor
Custom Session Time Windowsession0800-1600custSessionSession
Custom Session TimezonestringEtc/UTCcustSessTimezone
Show Session High/Low LinesbooltrueshowSessionHiLo
Show Current Session High/LowbooltrueshowCurrentSessHiLo
Sessions to Displayint1hiLoLookback
Line Widthint1hiLoLineWidth
Line StylestringSolidhiLoLineStyle
SundayboolfalseincSun
MondaybooltrueincMon
TuesdaybooltrueincTue
WednesdaybooltrueincWed
ThursdaybooltrueincThur
FridaybooltrueincFri
SaturdayboolfalseincSat
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

This indicator builds Market Profile Time Price Opportunity (TPO) structures across defined session timeframes directly on the main price chart. It visualizes the Point of Control (POC) and Value Area boundaries using dynamic box drawings. An integrated multi-

Indicator v5 Support & resistanceScreeners & dashboards
Updated 1 year ago · MPL-2.0 GitHub repository of Market Profile with Screener
257 stars

This indicator plots auto trade signals for E-mini S&P 500 futures on the price chart. It computes an EMA200 filter along with day ETH RTH session levels and percentage-based entry zones. Signals trigger CALL or PUT cases when price crosses defined thresholds

Indicator v6 TrendSupport & resistance
Updated 2 months ago · None stated GitHub repository of Auto Trade Futures ES

Golden Bullet Strategy

by TradersPost
228 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 4 months ago · None stated GitHub repository of Golden Bullet Strategy
219 stars

This indicator plots reference levels for previous daily high and low prices directly on the price chart. It requests daily timeframe data using the security function and plots the offset values as continuous lines, displaying resistance in red and support in

Indicator v4 Support & resistanceSessions & time
Updated 5 years ago · None stated GitHub repository of 昨日高低點標示

Moon Dev GEX Arrows

by moondevonyt
98 stars

This overlay indicator plots option strike walls and an optional session VWAP on the price chart for SPY or ES. It spaces major strikes by the selected instrument, draws a set number of strikes on each side, and marks wall-trap and sweep events after a cooldow

Indicator v5 Support & resistanceSessions & time
Updated 2 months ago · Custom licence GitHub repository of Moon Dev GEX Arrows

Key Levels

by cryptorife
75 stars

This indicator plots reference levels and session markers directly on the price chart. It calculates and draws lines for the daily open, weekly open, monthly open, previous day OHLC, and previous week extremes, along with a selectable day-of-week range and ini

Indicator v4 Support & resistanceSessions & time Repaints
Updated 3 years ago · GPL-3.0 GitHub repository of Key Levels

More Sessions & time 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