TT Killzones
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Chill00r

//@version=5
indicator('TT Killzones', overlay= true)
// INFO: Trading Days for Sessions: 1 = Sunday, 7 = Saturday

//**************************************************************************************************************
// INPUTS{
//**************************************************************************************************************
bool showAsia       = input.bool(true   , 'Asia'        , inline = 'Asia')
color AsiaColor     = input(#ffcc00   , '    '        , inline = 'Asia')

bool showEU         = input.bool(true   , 'London'      , inline = 'EU')
color EUColor       = input(#00b386   , '  '          , inline = 'EU')

bool showUS         = input.bool(true   , 'New York'    , inline = 'US')
color USColor       = input(#0077b3   , ''            , inline = 'US')

bool showHighVol    = input.bool(false  , 'High Trading Volume' , inline = 'highVol')
string highVol      = input.session("1300-1700" , ''            , inline = 'highVol')
color highVolColor  = input.color(color.red   , ''            , inline = 'highVol')

bool showCME         = input.bool(true  , 'CME open/close' , inline = 'CME')
color CMEColor       = input(#0077b3  , ''               , inline = 'CME')
//}

//**************************************************************************************************************
// FUNCTION{
//**************************************************************************************************************
var tf_is_below_1h  = timeframe.isminutes and timeframe.multiplier < 60 ? true : false

f_session(_session, _days) =>
    session = _session + ":" + _days
    if not na(time(timeframe.period, session)) and tf_is_below_1h
        true
//}

//**************************************************************************************************************
// PLOTTING{
//**************************************************************************************************************
//Asia
plotshape(showAsia ? f_session("0000-0900", "23456"): na , location = location.bottom, style = shape.square, size = size.tiny, color = AsiaColor)
plotshape(showAsia ? f_session("0000-0001", "23456"): na , location = location.bottom, style = shape.square, size = size.tiny, color = AsiaColor, textcolor = AsiaColor, text='Asia')
//London
plotshape(showEU   ? f_session("0700-1600", "23456"): na , location = location.bottom, style = shape.square, size = size.tiny, color = EUColor)
plotshape(showEU   ? f_session("0700-0701", "23456"): na , location = location.bottom, style = shape.square, size = size.tiny, color = EUColor, textcolor = EUColor, text='London')
//New York
plotshape(showUS   ? f_session("1300-2200", "23456"): na , location = location.bottom, style = shape.square, size = size.tiny, color = USColor)
plotshape(showUS   ? f_session("1300-1301", "23456"): na , location = location.bottom, style = shape.square, size = size.tiny, color = USColor, textcolor = USColor, text='New York')
//High Volume
plotshape(showEU and showUS and showHighVol ? f_session(highVol, "23456") : na , location = location.bottom, style = shape.square, size = size.tiny, color = highVolColor)

//CME
plotshape(showCME ? f_session("2300-0000", "1")     : na , location = location.top, style = shape.square, size = size.tiny, color = CMEColor)
plotshape(showCME ? f_session("2300-2301", "1")     : na , location = location.top, style = shape.square, size = size.tiny, color = CMEColor, textcolor = CMEColor, text='CME Open')
plotshape(showCME ? f_session("2100-2200", "6")     : na , location = location.top, style = shape.square, size = size.tiny, color = CMEColor)
plotshape(showCME ? f_session("2100-2101", "6")     : na , location = location.top, style = shape.square, size = size.tiny, color = CMEColor, textcolor = CMEColor, text='CME Close')
//}