Indicator · Pine Script v5 · On the chart

Hotch Session

by rajatjpatel

A session overlay that shades the chart background for the Asian, European and American trading sessions, plus an optional custom session.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code208
Settings30inputs
LicenceNone statedfile: MPL-2.0
Last update4 years ago18 Oct 2022

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

208 lines of Pine Script v5 from Hotch Session.txt, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

Hotch Session.txt
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Hotchachachaaa

//@version=5
indicator("Hotch Session",overlay=true,max_bars_back=500)
tz                  = "UTC"
tsAsia              = input.bool(   title="Show Asian Session",     defval=true, group = "Asian Trade Session")
startHourAsia       = input.int(    title="Asia Start hour",        defval=0,   minval=0, maxval=23,    group = "Asian Trade Session")
startMinuteAsia     = input.int(    title="Asia Start minute",      defval=0,  minval=0, maxval=59,    group = "Asian Trade Session")
endHour2Asia        = input.int(    title="Asia End hour",          defval=8,   minval=0, maxval=23,    group = "Asian Trade Session")
endMinute2Asia      = input.int(    title="Asia End minute",        defval=0,   minval=0, maxval=59,    group = "Asian Trade Session")
tsEurope            = input.bool(   title="Show European Session",  defval=true,                        group = "European Trade Session")
startHourEurope     = input.int(    title="Europen Start hour",     defval=8,   minval=0, maxval=23,    group = "European Trade Session")
startMinuteEurope   = input.int(    title="Europen Start minute",   defval=00,  minval=0, maxval=59,    group = "European Trade Session")
endHour2Europe      = input.int(    title="Europen End hour",       defval=14,  minval=0, maxval=23,    group = "European Trade Session")
endMinute2Europe    = input.int(    title="Europen End minute",     defval=0,   minval=0, maxval=59,    group = "European Trade Session")
tsAmericas          = input.bool(   title="Show American Session",  defval=true,                        group = "American Trade Session")
startHourAmericas   = input.int(    title="Americas Start hour",    defval=12,  minval=0, maxval=23,    group = "American Trade Session")
startMinuteAmericas = input.int(    title="Americas Start minute",  defval=30,  minval=0, maxval=59,    group = "American Trade Session")
endHour2Americas    = input.int(    title="Americas End hour",      defval=16,  minval=0, maxval=23,    group = "American Trade Session")
endMinute2Americas  = input.int(    title="Americas End minute",    defval=0,   minval=0, maxval=59,    group = "American Trade Session")
tsCustom            = input.bool(   title="Show Custom Session",    defval=false,                       group = "Custom Trade Session")
startHourCustom     = input.int(    title="Custom Start hour",      defval=16,  minval=0, maxval=23,    group = "Custom Trade Session")
startMinuteCustom   = input.int(    title="Custom Start minute",    defval=00,  minval=0, maxval=59,    group = "Custom Trade Session")
endHour2Custom      = input.int(    title="Custom End hour",        defval=20,  minval=0, maxval=23,    group = "Custom Trade Session")
endMinute2Custom    = input.int(    title="Custom End minute",      defval=0,   minval=0, maxval=59,    group = "Custom Trade Session")
displayCustomBG     = input.bool(   title="Show Custom Background", defval=false,                       group = "Custom Trade Session")
showMon = input(title="Monday",     defval=true, group = "Trade Session")
showTue = input(title="Tuesday",    defval=true, group = "Trade Session")
showWed = input(title="Wednesday",  defval=true, group = "Trade Session")
showThu = input(title="Thursday",   defval=true, group = "Trade Session")
showFri = input(title="Friday",     defval=true, group = "Trade Session")
showSat = input(title="Saturday",   defval=false, group = "Trade Session")
showSun = input(title="Sunday",     defval=false, group = "Trade Session")
tzYear = year(time, tz)
tzMonth = month(time, tz)
tzDay = dayofmonth(time, tz)
tzDayOfWeek = dayofweek(time, tz)
displayBG   = input.bool(title="Display Session as Background Color", defval = true)
displayHiLo = input.bool(title="Display Session High/Low", defval= true)
////////////////asia session
startTime1Asia = timestamp(tz, tzYear, tzMonth, tzDay, startHourAsia, startMinuteAsia)
endTime1Asia = timestamp(tz, tzYear, tzMonth, tzDay, endHour2Asia, endMinute2Asia)
activeAsia = if startTime1Asia <= time and time <= endTime1Asia and tsAsia
    if tzDayOfWeek == dayofweek.monday and showMon
        true
    else if tzDayOfWeek == dayofweek.tuesday and showTue
        true
    else if tzDayOfWeek == dayofweek.wednesday and showWed
        true
    else if tzDayOfWeek == dayofweek.thursday and showThu
        true
    else if tzDayOfWeek == dayofweek.friday and showFri
        true
    else if tzDayOfWeek == dayofweek.saturday and showSat
        true
    else if tzDayOfWeek == dayofweek.sunday and showSun
        true
    else
        false
else
    false

var float Asiahigh  = na
var float Asialow   = na
bgColorAsia         = color.new(color.red,85)
rangeColorAsia      = activeAsia[1] ? color.new(color.red,0): color.new(color.red,100)  

AsiaLookback= nz(ta.barssince(ta.change(activeAsia))) + 1

if activeAsia
    
    Asiahigh := nz(ta.highest(high,AsiaLookback))
    Asialow  := nz(ta.lowest(low,AsiaLookback))

if not activeAsia[1]
    Asiahigh := high[1]
    Asialow := low[1]
    
plot(displayHiLo?Asiahigh :na  , color= rangeColorAsia, title= "Asia High",linewidth=2)   
plot(displayHiLo?Asialow  :na, color= rangeColorAsia, title= "Asia Low",linewidth=2) 
bgcolor(activeAsia and displayBG ? bgColorAsia : na, title = "Asia Session Background")

////////////////Europe session
startTime1Europe = timestamp(tz, tzYear, tzMonth, tzDay, startHourEurope, startMinuteEurope)
endTime1Europe = timestamp(tz, tzYear, tzMonth, tzDay, endHour2Europe, endMinute2Europe)
activeEurope = if startTime1Europe <= time and time <= endTime1Europe and tsEurope
    if tzDayOfWeek == dayofweek.monday and showMon
        true
    else if tzDayOfWeek == dayofweek.tuesday and showTue
        true
    else if tzDayOfWeek == dayofweek.wednesday and showWed
        true
    else if tzDayOfWeek == dayofweek.thursday and showThu
        true
    else if tzDayOfWeek == dayofweek.friday and showFri
        true
    else if tzDayOfWeek == dayofweek.saturday and showSat
        true
    else if tzDayOfWeek == dayofweek.sunday and showSun
        true
    else
        false
else
    false

var float Europehigh  = na
var float Europelow   = na
bgColorEurope         = color.new(color.green,85)
rangeColorEurope      = activeEurope[1] ? color.new(color.green,0): color.new(color.green,100)  

EuropeLookback= nz(ta.barssince(ta.change(activeEurope))) + 1
if activeEurope
    
    Europehigh := nz(ta.highest(high,EuropeLookback))
    Europelow  := nz(ta.lowest(low,EuropeLookback))
    
if not activeEurope[1]
    Europehigh := high[1]
    Europelow := low[1]
    
plot(displayHiLo?Europehigh:na  , color= rangeColorEurope, title= "Europe High",linewidth=2)   
plot(displayHiLo?Europelow :na , color= rangeColorEurope, title= "Europe Low",linewidth=2) 
bgcolor(activeEurope and displayBG ? bgColorEurope : na, title = "Europe Session Background")

////////////////Americas session
startTime1Americas = timestamp(tz, tzYear, tzMonth, tzDay, startHourAmericas, startMinuteAmericas)
endTime1Americas = timestamp(tz, tzYear, tzMonth, tzDay, endHour2Americas, endMinute2Americas)
activeAmericas = if startTime1Americas <= time and time <= endTime1Americas and tsAmericas
    if tzDayOfWeek == dayofweek.monday and showMon
        true
    else if tzDayOfWeek == dayofweek.tuesday and showTue
        true
    else if tzDayOfWeek == dayofweek.wednesday and showWed
        true
    else if tzDayOfWeek == dayofweek.thursday and showThu
        true
    else if tzDayOfWeek == dayofweek.friday and showFri
        true
    else if tzDayOfWeek == dayofweek.saturday and showSat
        true
    else if tzDayOfWeek == dayofweek.sunday and showSun
        true
    else
        false
else
    false

var float Americashigh  = na
var float Americaslow   = na
bgColorAmericas         = color.new(color.blue,85)
rangeColorAmericas      = activeAmericas[1] ? color.new(color.blue,0): color.new(color.blue,100)  

AmericasLookback= nz(ta.barssince(ta.change(activeAmericas))) + 1 
if activeAmericas
    
    Americashigh := nz(ta.highest(high,AmericasLookback))
    Americaslow  := nz(ta.lowest(low,AmericasLookback))
    
if not activeAmericas[1]
    Americashigh := high[1]
    Americaslow := low[1]
    
plot(displayHiLo?Americashigh:na  , color= rangeColorAmericas, title= "Americas High",linewidth=2)   
plot(displayHiLo?Americaslow:na  , color= rangeColorAmericas, title= "Americas Low",linewidth=2) 
bgcolor(activeAmericas and displayBG ? bgColorAmericas : na, title = "Americas Session Background")

////////////////Custom session
startTime1Custom = timestamp(tz, tzYear, tzMonth, tzDay, startHourCustom, startMinuteCustom)
endTime1Custom = timestamp(tz, tzYear, tzMonth, tzDay, endHour2Custom, endMinute2Custom)
activeCustom = if startTime1Custom <= time and time <= endTime1Custom and tsCustom
    if tzDayOfWeek == dayofweek.monday and showMon
        true
    else if tzDayOfWeek == dayofweek.tuesday and showTue
        true
    else if tzDayOfWeek == dayofweek.wednesday and showWed
        true
    else if tzDayOfWeek == dayofweek.thursday and showThu
        true
    else if tzDayOfWeek == dayofweek.friday and showFri
        true
    else if tzDayOfWeek == dayofweek.saturday and showSat
        true
    else if tzDayOfWeek == dayofweek.sunday and showSun
        true
    else
        false
else
    false

var float Customhigh  = na
var float Customlow   = na
bgColorCustom         = color.new(color.yellow,85)
rangeColorCustom      = activeCustom[1] ? color.new(color.yellow,0): color.new(color.yellow,100)  

CustomLookback=  nz(ta.barssince(ta.change(activeCustom))) + 1 
if activeCustom
    
    Customhigh := nz(ta.highest(high,CustomLookback))
    Customlow  :=nz(ta.lowest(low,CustomLookback))
    
if not activeCustom[1]
    Customhigh := high[1]
    Customlow := low[1] 
    
plot(displayHiLo?Customhigh:na  , color= rangeColorCustom, title= "Custom High",linewidth=2)   
plot(displayHiLo?Customlow:na  , color= rangeColorCustom, title= "Custom Low",linewidth=2) 
bgcolor(activeCustom and displayBG and displayCustomBG ? bgColorCustom : na, title = "Custom Session Background")

Overview

Start and end hours and minutes are editable for each, using UTC, and individual weekdays can be switched on or off, with Saturday and Sunday off by default. It can also draw each session's high and low. The defaults run from 0:00 to 8:00 for Asia, 8:00 to 14:00 for Europe and 12:30 to 16:00 for the Americas.

Details

Published by

rajatjpatel on GitHub

Draws

On the price chart

Markets

Any symbol

Timeframes

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 Asian SessionbooltruetsAsia
Asia Start hourint0startHourAsia
Asia Start minuteint0startMinuteAsia
Asia End hourint8endHour2Asia
Asia End minuteint0endMinute2Asia
Show European SessionbooltruetsEurope
Europen Start hourint8startHourEurope
Europen Start minuteint00startMinuteEurope
Europen End hourint14endHour2Europe
Europen End minuteint0endMinute2Europe
Show American SessionbooltruetsAmericas
Americas Start hourint12startHourAmericas
Show all 30 settings
SettingTypeDefaultVariable
Americas Start minuteint30startMinuteAmericas
Americas End hourint16endHour2Americas
Americas End minuteint0endMinute2Americas
Show Custom SessionboolfalsetsCustom
Custom Start hourint16startHourCustom
Custom Start minuteint00startMinuteCustom
Custom End hourint20endHour2Custom
Custom End minuteint0endMinute2Custom
Show Custom BackgroundboolfalsedisplayCustomBG
MondaybooltrueshowMon
TuesdaybooltrueshowTue
WednesdaybooltrueshowWed
ThursdaybooltrueshowThu
FridaybooltrueshowFri
SaturdayboolfalseshowSat
SundayboolfalseshowSun
Display Session as Background ColorbooltruedisplayBG
Display Session High/LowbooltruedisplayHiLo
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

947 stars

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

Indicator v4 Sessions & time
Updated 12 days ago · GPL-3.0 GitHub repository of Litecoin Halving UTC Countdown
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

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

Indicator v6 Sessions & time
Updated 2 months ago · MIT GitHub repository of Expiration Highlights: Opex, Quarterly Opex & VIX with Vanna/Charm
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 7 weeks 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 3 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 昨日高低點標示

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