ICT Sessions (Kill Zones)
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © BlueBeardIt 2022
// Version 1.1

// Inspired by @ICT_MHuddleston concepts

//
//  ________   ___        ___  ___   _______    ________   _______    ________   ________   ________   ___   _________   
// |\   __  \ |\  \      |\  \|\  \ |\  ___ \  |\   __  \ |\  ___ \  |\   __  \ |\   __  \ |\   ___ \ |\  \ |\___   ___\ 
// \ \  \|\ /_\ \  \     \ \  \\\  \\ \   __/| \ \  \|\ /_\ \   __/| \ \  \|\  \\ \  \|\  \\ \  \_|\ \\ \  \\|___ \  \_| 
//  \ \   __  \\ \  \     \ \  \\\  \\ \  \_|/__\ \   __  \\ \  \_|/__\ \   __  \\ \   _  _\\ \  \ \\ \\ \  \    \ \  \  
//   \ \  \|\  \\ \  \____ \ \  \\\  \\ \  \_|\ \\ \  \|\  \\ \  \_|\ \\ \  \ \  \\ \  \\  \|\ \  \_\\ \\ \  \    \ \  \ 
//    \ \_______\\ \_______\\ \_______\\ \_______\\ \_______\\ \_______\\ \__\ \__\\ \__\\ _\ \ \_______\\ \__\    \ \__\
//     \|_______| \|_______| \|_______| \|_______| \|_______| \|_______| \|__|\|__| \|__|\|__| \|_______| \|__|     \|__|
//                                                                                                                      
//  

//@version=5


indicator("ICT Sessions (Kill Zones)", shorttitle="ICT Sessions (KZ)", overlay=true)
_as = time(timeframe.period, "1800-0300")
ls = time(timeframe.period, "0300-1200")
ns = time(timeframe.period, "0800-1800")
Asia = na(_as) ? na : color.new(color.blue, 90)
London = na(ls) ? na : color.new(color.green, 90)
NY = na(ns) ? na : color.new(color.red, 90)

bgcolor(Asia, title="Asia")
bgcolor(London, title="London")
bgcolor(NY, title="New York")



//Midnight NewYork

sessNum = 1
sh = input(true, title="Show NY Midnight Open?")
First = input.session('0000-0001', title="NY Midnight Open")

sessToUse = sessNum == 1 ? First : '0000-0000'

bartimeSess = (sessNum == 0 ? time('D') : time('D', sessToUse))
bgPlot = (sessNum == 0 ? time(timeframe.period) : time(timeframe.period, sessToUse)) 

bgcolor(sh and bgPlot > 0 ? color.new(color.purple, 50): na, title="New York Midnight Open")


                  

//London Kill Zone

sessNum2 = 2
sh2= input(true, title="Show London Kill Zone?")
Second = input.session('0200-0500', title="London Kill Zone")

sessToUse2 = sessNum2 == 2 ? Second : '0000-0000'

bartimeSess2 = (sessNum2 == 0 ? time('D') : time('D', sessToUse2))
bgPlot2 = (sessNum2 == 0 ? time(timeframe.period) : time(timeframe.period, sessToUse2)) 

bgcolor(sh2 and bgPlot2 > 0 ? color.new(color.purple, 80): na, title="London Kill Zone")


               

//London Kill Zone line

sessNum2b = 2
sh2b= input(true, title="Show London Kill Zone Central Line?")
Secondb = input.session('0330-0331', title="London Kill Zone CL")

sessToUse2b = sessNum2b == 2 ? Secondb : '0000-0000'

bartimeSess2b = (sessNum2b == 0 ? time('D') : time('D', sessToUse2b))
bgPlot2b = (sessNum2b == 0 ? time(timeframe.period) : time(timeframe.period, sessToUse2b)) 

bgcolor(sh2b and bgPlot2b > 0 ? color.new(color.purple, 80): na, title="London Kill Zone CL")




//New York 8:30

sessNum3 = 3
sh3= input(true, title="Show NY 8:30 Opening?")
Third = input.session('0830-0831', title="NY 8:30 Opening")

sessToUse3 = sessNum3 == 3 ? Third : '0000-0000'

bartimeSess3 = (sessNum3 == 0 ? time('D') : time('D', sessToUse3))
bgPlot3 = (sessNum3 == 0 ? time(timeframe.period) : time(timeframe.period, sessToUse3)) 

bgcolor(sh3 and bgPlot3 > 0 ? color.new(color.purple, 50): na, title="New York 8:30")



//New York 9:30

sessNum4 = 4
sh4= input(true, title="Show NY 9:30 Opening?")
Fourth = input.session('0930-0931', title="NY 9:30 Opening")

sessToUse4 = sessNum4 == 4 ? Fourth : '0000-0000'

bartimeSess4 = (sessNum4 == 0 ? time('D') : time('D', sessToUse4))
bgPlot4 = (sessNum4 == 0 ? time(timeframe.period) : time(timeframe.period, sessToUse4)) 

bgcolor(sh4 and bgPlot4 > 0 ? color.new(color.purple, 50): na, title="New York 9:30")



//New York Lunch Hour

sessNum5 = 5
sh5= input(true, title="Show New York Lunch Hour?")
Fifth = input.session('1200-1300', title="New York Lunch Hour")

sessToUse5 = sessNum5 == 5 ? Fifth : '0000-0000'

bartimeSess5 = (sessNum5 == 0 ? time('D') : time('D', sessToUse5))
bgPlot5 = (sessNum5 == 0 ? time(timeframe.period) : time(timeframe.period, sessToUse5)) 

bgcolor(sh5 and bgPlot5 > 0 ? color.new(color.purple, 80): na, title="New York Lunch Hour")


               

//New York Lunch Hour line

sessNum5b = 5
sh5b= input(true, title="Show New York Lunch Hour Central Line?")
Fifthb = input.session('1230-1231', title="New York Lunch Hour CL")

sessToUse5b = sessNum5b == 5 ? Fifthb : '0000-0000'

bartimeSess5b = (sessNum5b == 0 ? time('D') : time('D', sessToUse5b))
bgPlot5b = (sessNum5b == 0 ? time(timeframe.period) : time(timeframe.period, sessToUse5b)) 

bgcolor(sh5b and bgPlot5b > 0 ? color.new(color.purple, 80): na, title="New York Lunch Hour CL")



//New York 13:30

sessNum6 = 6
sh6= input(true, title="Show NY 13:30 Opening?")
sixth = input.session('1330-1331', title="NY 13:30 Opening")

sessToUse6 = sessNum6 == 6 ? sixth : '0000-0000'

bartimeSess6 = (sessNum6 == 0 ? time('D') : time('D', sessToUse6))
bgPlot6 = (sessNum6 == 0 ? time(timeframe.period) : time(timeframe.period, sessToUse6)) 

bgcolor(sh6 and bgPlot6 > 0 ? color.new(color.purple, 50): na, title="New York 13:30")



//New York 7:00

sessNum7 = 7
sh7= input(true, title="Show 07:00 NY KZ Opening?")
seventh = input.session('0700-0701', title="NY 07:00 KZ Opening")

sessToUse7 = sessNum7 == 7 ? seventh : '0000-0000'

bartimeSess7 = (sessNum7 == 0 ? time('D') : time('D', sessToUse7))
bgPlot7 = (sessNum7 == 0 ? time(timeframe.period) : time(timeframe.period, sessToUse7)) 

bgcolor(sh7 and bgPlot7 > 0 ? color.new(color.purple, 50): na, title="NY 07:00 KZ Opening")






anchorTime = time('D', sessToUse) 
anchorBarIndex = (time - anchorTime) / (1000 * timeframe.in_seconds(timeframe.period))
anchorBarsBack = bar_index - anchorBarIndex
//plot(anchorBarsBack)

labelNYMidnight= label.new(anchorBarsBack, high, 
                  text="NY Midnight Open",  
                  color=color.new(color.white, 0), 
                  textcolor= color.red,
                  size=size.large,
                  style =  label.style_label_down,
                  yloc = yloc.abovebar)




anchorTime2 = time('D', sessToUse2b) 
anchorBarIndex2 = (time - anchorTime2) / (1000 * timeframe.in_seconds(timeframe.period))
anchorBarsBack2 = bar_index - anchorBarIndex2


labelLondonKZ= label.new(anchorBarsBack2, high,
                  text="London Kill Zone",  
                  color=color.new(color.white, 0), 
                  textcolor= color.red,
                  size=size.large,
                  style =  label.style_label_down,
                  yloc = yloc.abovebar)




anchorTime3 = time('D', sessToUse3) 
anchorBarIndex3 = (time - anchorTime3) / (1000 * timeframe.in_seconds(timeframe.period))
anchorBarsBack3 = bar_index - anchorBarIndex3


labelNY830= label.new(anchorBarsBack3, high,
                  text="NY 8:30",  
                  color=color.new(color.white, 0), 
                  textcolor= color.red,
                  size=size.large,
                  style =  label.style_label_down,
                  yloc = yloc.abovebar)




anchorTime4 = time('D', sessToUse4) 
anchorBarIndex4 = (time - anchorTime4) / (1000 * timeframe.in_seconds(timeframe.period))
anchorBarsBack4 = bar_index - anchorBarIndex4


labelNY930= label.new(anchorBarsBack4, high,
                  text="NY 9:30",  
                  color=color.new(color.white, 0), 
                  textcolor= color.red,
                  size=size.large,
                  style =  label.style_label_down,
                  yloc = yloc.abovebar)




anchorTime5 = time('D', sessToUse5b) 
anchorBarIndex5 = (time - anchorTime5) / (1000 * timeframe.in_seconds(timeframe.period))
anchorBarsBack5 = bar_index - anchorBarIndex5


labelNYLunch= label.new(anchorBarsBack5, high,
                  text="NY Lunch",  
                  color=color.new(color.white, 0), 
                  textcolor= color.red,
                  size=size.large,
                  style =  label.style_label_down,
                  yloc = yloc.abovebar)




anchorTime6 = time('D', sessToUse6) 
anchorBarIndex6 = (time - anchorTime6) / (1000 * timeframe.in_seconds(timeframe.period))
anchorBarsBack6 = bar_index - anchorBarIndex6


labelNY1330= label.new(anchorBarsBack6, high,
                  text="NY 13:30",  
                  color=color.new(color.white, 0), 
                  textcolor= color.red,
                  size=size.large,
                  style =  label.style_label_down,
                  yloc = yloc.abovebar)




anchorTime7 = time('D', sessToUse7) 
anchorBarIndex7 = (time - anchorTime7) / (1000 * timeframe.in_seconds(timeframe.period))
anchorBarsBack7 = bar_index - anchorBarIndex7


labelNY0700= label.new(anchorBarsBack7, high,
                  text="NY 07:00 KZ Open",  
                  color=color.new(color.white, 0), 
                  textcolor= color.red,
                  size=size.large,
                  style =  label.style_label_down,
                  yloc = yloc.abovebar)




