ICT Killzone by Jeaw
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/

//@version=5
indicator("ICT Killzone", "ICT Killzones by Jeaw", true, max_boxes_count = 500, max_labels_count = 500)


lno_time = input.session(title="London Open Killzone", defval="0700-1000")
nyo_time = input.session(title="New York Open Killzone", defval="1200-1500")
asb_time = input.session(title="Asian Range", defval="1500-1700")
lnc_time = input.session(title="London Close Killzone", defval="0000-0600")


lno_ = input.bool(true, "London Open Killzone", "07:00-10:00 London timezone", "", "Session")
nyo_ = input.bool(true, "New York Open Killzone", "12:00-15:00 London timezone", "", "Session")
lnc_ = input.bool(false, "London Close Killzone", "15:00-17:00 London timezone", "", "Session")
asb_ = input.bool(true, "Asian Range", "00:00-0600 London timezone", "", "Session")
lno_b = input.bool(true, "London Open box", "", "", "session in box")
nyo_b = input.bool(true, "New York Open box", "", "", "session in box")
lnc_b = input.bool(true, "London Close box", "", "", "session in box")
asb_b = input.bool(true, "Asian Range box", "", "", "session in box")
info = input.bool(false, "info over box", "this will show the range of the session in pips (make sense only on forex)", "", "session in box")
spec = input.int(90, "Transparency", 0, 100, 1, "from 0 to 100, how much you want the color transparent?", "", "Visual Features")
lno_c = input.color(color.green, "London Open Killzone", "", "", "Visual Features")
nyo_c = input.color(color.blue, "New York Open Killzone", "", "", "Visual Features")
lnc_c = input.color(color.orange, "London Close Killzone", "", "", "Visual Features")
asb_c = input.color(color.yellow, "Asian Range", "", "", "Visual Features")

b_color = color.new(color.gray,95)

lno = time('', lno_time, 'Europe/London') and lno_ and timeframe.isintraday and timeframe.multiplier <= 60
nyo = time('', nyo_time, 'Europe/London') and nyo_ and timeframe.isintraday and timeframe.multiplier <= 60
lnc = time('', asb_time, 'Europe/London') and lnc_ and timeframe.isintraday and timeframe.multiplier <= 60
asb = time('', lnc_time, 'Europe/London') and asb_ and timeframe.isintraday and timeframe.multiplier <= 60

bgcolor(lno and not lno_b and lno_? color.new(lno_c, spec) : na)
bgcolor(nyo and not nyo_b and nyo_? color.new(nyo_c, spec) : na)
bgcolor(lnc and not lnc_b and lnc_? color.new(lnc_c, spec) : na)
bgcolor(asb and not asb_b and asb_? color.new(asb_c, spec) : na)

var box lno_box = na
var box nyo_box = na
var box lnc_box = na
var box asb_box = na

var label lno_l = na
var label nyo_l = na
var label lnc_l = na
var label asb_l = na

if lno_ and lno_b and timeframe.multiplier<=60 and timeframe.isintraday
    if lno and not lno[1]
        lno_box := box.new(bar_index,high,bar_index+1,low,b_color,bgcolor = color.new(lno_c,spec))
        if info
            lno_l := label.new(bar_index,high,str.tostring((high-low)/10/syminfo.mintick)+" pip",textcolor = #ffffff, size = size.small,style = label.style_none)
    if lno and lno[1]
        if high > box.get_top(lno_box)
            box.set_top(lno_box,high)
        if low < box.get_bottom(lno_box)
            box.set_bottom(lno_box,low)
        box.set_right(lno_box,bar_index+1)
        if info
            label.set_text(lno_l,str.tostring((box.get_top(lno_box)-box.get_bottom(lno_box))/10/syminfo.mintick)+" pip")
            label.set_x(lno_l,(box.get_left(lno_box)+box.get_right(lno_box))/2)
            label.set_y(lno_l,box.get_top(lno_box))
    if not lno and lno[1]
        box.set_right(lno_box,bar_index-1)

if nyo_ and nyo_b and timeframe.multiplier<=60 and timeframe.isintraday
    if nyo and not nyo[1]
        nyo_box := box.new(bar_index,high,bar_index+1,low,b_color,bgcolor = color.new(nyo_c,spec))
        if info
            nyo_l := label.new(bar_index,high,str.tostring((high-low)/10/syminfo.mintick)+" pip",textcolor = #ffffff, size = size.small,style = label.style_none)
    if nyo and nyo[1]
        if high > box.get_top(nyo_box)
            box.set_top(nyo_box,high)
        if low < box.get_bottom(nyo_box)
            box.set_bottom(nyo_box,low)
        box.set_right(nyo_box,bar_index+1)
        if info
            label.set_text(nyo_l,str.tostring((box.get_top(nyo_box)-box.get_bottom(nyo_box))/10/syminfo.mintick)+" pip")
            label.set_x(nyo_l,(box.get_left(nyo_box)+box.get_right(nyo_box))/2)
            label.set_y(nyo_l,box.get_top(nyo_box))
    if not nyo and nyo[1]
        box.set_right(nyo_box,bar_index-1)

if lnc_ and lnc_b and timeframe.multiplier<=60 and timeframe.isintraday
    if lnc and not lnc[1]
        lnc_box := box.new(bar_index,high,bar_index+1,low,b_color,bgcolor = color.new(lnc_c,spec))
        if info
            lnc_l := label.new(bar_index,high,str.tostring((high-low)/10/syminfo.mintick)+" pip",textcolor = #ffffff, size = size.small,style = label.style_none)
    if lnc and lnc[1]
        if high > box.get_top(lnc_box)
            box.set_top(lnc_box,high)
        if low < box.get_bottom(lnc_box)
            box.set_bottom(lnc_box,low)
        box.set_right(lnc_box,bar_index+1)
        if info
            label.set_text(lnc_l,str.tostring((box.get_top(lnc_box)-box.get_bottom(lnc_box))/10/syminfo.mintick)+" pip")
            label.set_x(lnc_l,(box.get_left(lnc_box)+box.get_right(lnc_box))/2)
            label.set_y(lnc_l,box.get_top(lnc_box))
    if not lnc and lnc[1]
        box.set_right(lnc_box,bar_index-1)

if asb_ and asb_b and timeframe.multiplier<=60 and timeframe.isintraday
    if asb and not asb[1]
        asb_box := box.new(bar_index,high,bar_index+1,low,b_color,bgcolor = color.new(asb_c,spec))
        if info
            asb_l := label.new(bar_index,high,str.tostring((high-low)/10/syminfo.mintick)+" pip",textcolor = #ffffff, size = size.small,style = label.style_none)
    if asb and asb[1]
        if high > box.get_top(asb_box)
            box.set_top(asb_box,high)
        if low < box.get_bottom(asb_box)
            box.set_bottom(asb_box,low)
        box.set_right(asb_box,bar_index+1)
        if info
            label.set_text(asb_l,str.tostring((box.get_top(asb_box)-box.get_bottom(asb_box))/10/syminfo.mintick)+" pip")
            label.set_x(asb_l,(box.get_left(asb_box)+box.get_right(asb_box))/2)
            label.set_y(asb_l,box.get_top(asb_box))
    if not asb and asb[1]
        box.set_right(asb_box,bar_index-1)



