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
105 lines of Pine Script v6 from scripts/enum-method-map.pine.txt, published under MPL-2.0. Keep the author's credit and licence lines when you reuse it.
enum-method-map.pine.txt
//@version=6
indicator("Session Stats", overlay = true)
enum Session
asia = "Asia"
london = "London"
newYork = "New York"
focus = input.enum(Session.london, "Highlight session")
tz = "America/New_York"
type SessionStats
int days = 0
float rangeSum = 0.0
int highs = 0
int lows = 0
method update(SessionStats this, float span, bool hi, bool lo) =>
this.days += 1
this.rangeSum += span
this.highs += hi ? 1 : 0
this.lows += lo ? 1 : 0
this
method avgRange(SessionStats this) =>
this.days > 0 ? this.rangeSum / this.days : na
h = hour(time, tz)
Session sess = h >= 17 or h < 3 ? Session.asia :
h < 8 ? Session.london : Session.newYork
newSess = bar_index > 0 and sess != sess[1]
newDay = newSess and sess == Session.asia
col = switch sess
Session.asia => color.blue
Session.london => color.orange
=> color.purple
bgcolor(color.new(col, sess == focus ? 75 : 92), title = "Session")
var stats = map.new<Session, SessionStats>()
if barstate.isfirst
stats.put(Session.asia, SessionStats.new())
stats.put(Session.london, SessionStats.new())
stats.put(Session.newYork, SessionStats.new())
var today = map.new<Session, float>()
var float sessHigh = na
var float sessLow = na
var float dayHigh = na
var float dayLow = na
var Session highSess = na
var Session lowSess = na
var int totalDays = 0
if newSess and not na(sessHigh)
today.put(sess[1], sessHigh - sessLow)
if newDay
if not na(dayHigh)
for [k, r] in today
stats.get(k).update(r, k == highSess, k == lowSess)
totalDays += 1
today.clear()
dayHigh := high
dayLow := low
highSess := sess
lowSess := sess
if newSess
sessHigh := high
sessLow := low
else
sessHigh := math.max(sessHigh, high)
sessLow := math.min(sessLow, low)
if high > dayHigh
dayHigh := high
highSess := sess
if low < dayLow
dayLow := low
lowSess := sess
plot(newSess ? na : sessHigh, "Session high", color.gray, 1,
plot.style_linebr)
plot(newSess ? na : sessLow, "Session low", color.gray, 1,
plot.style_linebr)
pct(int n) =>
totalDays > 0 ? str.tostring(100.0 * n / totalDays, "#") + "%" : "-"
var table panel = table.new(position.top_right, 5, 4,
bgcolor = color.new(color.black, 15), border_width = 1,
frame_width = 1, frame_color = color.gray)
if barstate.islast
heads = array.from("session", "days", "avg range", "day high",
"day low")
for i = 0 to 4
table.cell(panel, i, 0, heads.get(i), text_color = color.white,
bgcolor = color.new(color.teal, 0))
row = 1
for [k, s] in stats
tc = k == focus ? color.yellow : color.white
rng = s.days > 0 ? str.tostring(s.avgRange(), "#.00") : "-"
table.cell(panel, 0, row, str.tostring(k), text_color = tc)
table.cell(panel, 1, row, str.tostring(s.days), text_color = tc)
table.cell(panel, 2, row, rng, text_color = tc)
table.cell(panel, 3, row, pct(s.highs), text_color = tc)
table.cell(panel, 4, row, pct(s.lows), text_color = tc)
row += 1
Overview
Session Stats plots session high and low lines directly on price action and presents a summary table displaying average session ranges and the frequency with which each session sets the daily high or low. The main setting selects a focus session for visual emphasis.
Session background shading with custom focus selection
Dynamic session high and low level plots
Dashboard showing session average range metrics
Daily high and low percentage statistics per session
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Highlight session
enum
Session.london
focus
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 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 overlays an intraday SPX and ES chart with a midnight session range, regular-trading-hours opening levels, and a VWAP projection box. It draws the midnight high, mid, and low, flags edge rejections within an absolute tolerance, and plots optiona
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 a session VWAP of the typical price on the price chart. It marks an up triangle under a bar when close crosses above VWAP and a down triangle above a bar when close crosses below it. A star pinned at the top of the pane marks bars whose vo
This indicator marks forex trading sessions and opening ranges on the price chart. It can draw Sydney, Tokyo, Frankfurt, London, and New York session boxes or five- and fifteen-minute opening ranges, plus an optional opening channel and a day-open range. Day r