1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.
Source Code
96 lines of Pine Script v5 from src/indicators/custom/sessions.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.
sessions.pine
//@version=5
indicator("Sessions", overlay = true, max_bars_back = 500, max_lines_count = 500, max_boxes_count = 500, max_labels_count = 500)
//Session A
show_sesa = input(true, '', inline = 'sesa', group = 'Session A')
sesa_txt = input('New York', '', inline = 'sesa', group = 'Session A')
sesa_ses = input.session('1300-2200', '', inline = 'sesa', group = 'Session A')
sesa_css = input.color(#ff5d00, '', inline = 'sesa', group = 'Session A')
//Session B
show_sesb = input(true, '', inline = 'sesb', group = 'Session B')
sesb_txt = input('London', '', inline = 'sesb', group = 'Session B')
sesb_ses = input.session('0700-1600', '', inline = 'sesb', group = 'Session B')
sesb_css = input.color(#2157f3, '', inline = 'sesb', group = 'Session B')
//Session C
show_sesc = input(true, '', inline = 'sesc', group = 'Session C')
sesc_txt = input('Tokyo', '', inline = 'sesc', group = 'Session C')
sesc_ses = input.session('0000-0900', '', inline = 'sesc', group = 'Session C')
sesc_css = input.color(#e91e63, '', inline = 'sesc', group = 'Session C')
//Ranges Options
bg_transp = input.float(90, 'Range Area Transparency', group = 'Ranges Settings')
show_txt = input(true, 'Range Label', group = 'Ranges Settings')
//Functions
n = bar_index
//Set session range
get_range(session, session_name, session_css)=>
var t = 0
var max = high
var min = low
var box bx = na
var label lbl = na
if session > session[1]
t := time
max := high
min := low
bx := box.new(n, max, n, min
, bgcolor = color.new(session_css, bg_transp)
, border_style = line.style_dotted)
if show_txt
lbl := label.new(t, max, session_name
, xloc = xloc.bar_time
, textcolor = session_css
, style = label.style_label_down
, color = color.new(color.white, 100)
, size = size.tiny)
if session and session == session[1]
max := math.max(high, max)
min := math.min(low, min)
box.set_top(bx, max)
box.set_rightbottom(bx, n, min)
label.set_xy(lbl, int(math.avg(t, time)), max)
[session ? na : max, session ? na : min]
//Sessions
//-----------------------------------------------------------------------------{
tf = timeframe.period
is_sesa = math.sign(nz(time(tf, sesa_ses,'GMT+1')))
is_sesb = math.sign(nz(time(tf, sesb_ses,'GMT+1')))
is_sesc = math.sign(nz(time(tf, sesc_ses,'GMT+1')))
//-----------------------------------------------------------------------------}
//Overlays
//-----------------------------------------------------------------------------{
var float max_sesa = na
var float min_sesa = na
var float max_sesb = na
var float min_sesb = na
var float max_sesc = na
var float min_sesc = na
//Ranges
if show_sesa
[max, min] = get_range(is_sesa, sesa_txt, sesa_css)
max_sesa := max
min_sesa := min
if show_sesb
[max, min] = get_range(is_sesb, sesb_txt, sesb_css)
max_sesb := max
min_sesb := min
if show_sesc
[max, min] = get_range(is_sesc, sesc_txt, sesc_css)
max_sesc := max
min_sesc := min
Overview
Each session has its own name, time window, colour and on or off toggle. While a session is active, a box tracks its running high and low, and an optional label shows the session name. A transparency setting controls the shading. Session times are evaluated against a fixed GMT plus one time offset.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
show_sesa
bool
true
show_sesa
sesa_txt
string
New York
sesa_txt
sesa_ses
session
1300-2200
sesa_ses
sesa_css
color
#ff5d00
sesa_css
show_sesb
bool
true
show_sesb
sesb_txt
string
London
sesb_txt
sesb_ses
session
0700-1600
sesb_ses
sesb_css
color
#2157f3
sesb_css
show_sesc
bool
true
show_sesc
sesc_txt
string
Tokyo
sesc_txt
sesc_ses
session
0000-0900
sesc_ses
sesc_css
color
#e91e63
sesc_css
Show all 14 settings
Setting
Type
Default
Variable
Range Area Transparency
float
90
bg_transp
Range Label
bool
true
show_txt
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.
This indicator counts down to a fixed Litecoin halving timestamp in August 2019, using Greenwich Mean Time. It subtracts the current time from that stamp and formats the remaining days, hours, minutes, and seconds. The day, hour, and minute of the target are u
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-
This indicator identifies and plots key options expiration dates on the price chart. It calculates monthly OpEx (the third Friday of each month), quarterly OpEx (March, June, September, December), and corresponding VIX expiration dates, drawing vertical lines
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
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
Indicatorv6SMC / ICT / price actionSessions & time
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