本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © malk1903
//@version=5
indicator("ICT Session Opening Gaps", overlay=true, max_bars_back = 5000, max_boxes_count = 500)
Session ="Sessions"
//INPUTS
i_maxtf_og = input.int (15, "Max Timeframe", 1, 240)
disp_og = timeframe.isintraday and timeframe.multiplier <= i_maxtf_og
timeZone = input.string("GMT-4", title="Time Zone", options=["GMT-10","GMT-9","GMT-8","GMT-7","GMT-6","GMT-5","GMT-4","GMT-3","GMT-2","GMT-1","GMT","GMT+1","GMT+2","GMT+3","GMT+4","GMT+5","GMT+6","GMT+7","GMT+8","GMT+9","GMT+10"])
tf=input.timeframe(defval="5", title="Timeframe", options=["1", "2", "3", "4", "5", "15"], tooltip="Timeframe used for FVG detection")
fvg_imb = true
ext_imb = false
t1H = input.int(16, title = 'Hour', inline="1", group="Extend/Labels")
t1m = input.int(01, title = 'Minute', inline="1", group="Extend/Labels")
ext_2last = input.bool(defval=true, title="Extend to Future Time", inline="1", group="Extend/Labels")
bxtxt = input.bool(defval=true, title="Show Labels", inline="1", group="Extend/Labels")
txt_c = input.color(defval=color.new(color.silver,0),title="", inline="1", group="Extend/Labels")
showLine1x = input(defval = false, title = "Show Vertical Line", inline="1", group="Extend/Labels")
futcol = input.color(defval = color.gray, title = '', inline="1", group="Extend/Labels")
//calc UNIX time of hour and minute input
t1 = timestamp(timeZone, year, month, dayofmonth, t1H, t1m, 00)
if barstate.islast and showLine1x
line.new(t1, 0, t1, 1, xloc=xloc.bar_time, extend=extend.both, color=futcol)
//Session Periods. Send FVGs/Imbs to arrays in these times.
Ldn_Kz_2 = input.session ('0201-0259:1234567', "LDn KZ 0200", inline='1', group="Sessions")
Ldn_Kz_3 = input.session ('0301-0359:1234567', "LDn KZ 0300", inline='2', group="Sessions")
Ldn_Kz_4 = input.session ('0401-0459:1234567', "LDn KZ 0400", inline='3', group="Sessions")
Dead_Kz_5 = input.session ('0501-0559:1234567', "Dead KZ 0500", inline='4', group="Sessions")
Dead_Kz_6 = input.session ('0601-0659:1234567', "Dead KZ 0600", inline='5', group="Sessions")
NY_Kz_7 = input.session ('0701-0829:1234567', "NY KZ 0700", inline='6', group="Sessions")
NY_Kz_830 = input.session ('0831-0929:1234567', "NY KZ 0830", inline='7', group="Sessions")
NY_Kz_930 = input.session ('0931-0959:1234567', "NY KZ 0930", inline='8', group="Sessions")
NY_Kz_10 = input.session ('1001-1059:1234567', "NY KZ 1000 (Silver Bullet)", inline='9', group="Sessions")
i_kx2 = input.bool(defval=true, title="", inline='1', group="Sessions")
i_kx3 = input.bool(defval=true, title="", inline='2', group="Sessions")
i_kx4 = input.bool(defval=true, title="", inline='3', group="Sessions")
i_kx5 = input.bool(defval=false, title="", inline='4', group="Sessions")
i_kx6 = input.bool(defval=false, title="", inline='5', group="Sessions")
i_kx7 = input.bool(defval=true, title="", inline='6', group="Sessions")
i_kx830 = input.bool(defval=true, title="", inline='7', group="Sessions")
i_kx930 = input.bool(defval=true, title="", inline='8', group="Sessions")
i_kx10 = input.bool(defval=true, title="", inline='9', group="Sessions")
//Box Colors,Borders, Text Colors
fvgb_imb_c = input.color(defval=color.new(color.yellow,70),title="FVG Bull Box", inline="1", group="Box + Border Colors")
fvgb_imb_bc = input.color(defval=color.new(color.white,80),title="FVG Bull Border", inline="1", group="Box + Border Colors")
fvgbr_imb_c = input.color(defval=color.new(color.blue,70),title="FVG Bear Box", inline="2", group="Box + Border Colors")
fvgbr_imb_bc = input.color(defval=color.new(color.white,80),title="FVG Bear Border", inline="2", group="Box + Border Colors")
fvgb_sb_c = input.color(defval=color.new(color.silver,50),title="Silver Bullet Box", inline="3", group="Box + Border Colors")
fvgb_sb_bc = input.color(defval=color.new(color.silver,80),title="Silver Bullet Border", inline="3", group="Box + Border Colors")
//Arrays for fvgs/imbalnces found within the session periods
var Ldn_Kz_2_arr = array.new_box()
var Ldn_Kz_2_arr2 = array.new_box()
var Ldn_Kz_3_arr = array.new_box()
var Ldn_Kz_3_arr2 = array.new_box()
var Ldn_Kz_4_arr = array.new_box()
var Ldn_Kz_4_arr2 = array.new_box()
var Dead_Kz_5_arr = array.new_box()
var Dead_Kz_5_arr2 = array.new_box()
var Dead_Kz_6_arr = array.new_box()
var Dead_Kz_6_arr2 = array.new_box()
var NY_Kz_7_arr = array.new_box()
var NY_Kz_7_arr2 = array.new_box()
var NY_Kz_830_arr = array.new_box()
var NY_Kz_830_arr2 = array.new_box()
var NY_Kz_930_arr = array.new_box()
var NY_Kz_930_arr2 = array.new_box()
var NY_Kz_10_arr = array.new_box()
var NY_Kz_10_arr2 = array.new_box()
//function ask if within session period
InSession(sessionTimes) =>
not na(time(timeframe.period, sessionTimes,timeZone))
// use to only check fvg/imbs are only shown for current day trading
isToday = false
if year(timenow) == year(time) and month(timenow) == month(time) and dayofmonth(timenow) == dayofmonth(time)
isToday := true
// get higher timeframe price values
_getHLvalues(_ticker,_tf,_high2,_high1,_high,_low2,_low1,_low) =>
request.security(_ticker,tf,[_high2,_high1,_high,_low2,_low1,_low],lookahead = barmerge.lookahead_on)
//request values using chosen TF
[_high2,_high1,_high,_low2,_low1,_low] = _getHLvalues(syminfo.tickerid,tf,high[2],high[1],high,low[2],low[1],low)
//detect bull and bear FVGs AND
bull_fvg = _high2 < _low and _high2 > _low1 and _high2 < _high1
bear_fvg = _low2 > _high and _low2 < _high1 and _low2 > _low1
///NY 2
////finds first bull FVG
if InSession(Ldn_Kz_2) and i_kx2 and isToday and disp_og
if bull_fvg
array.unshift(Ldn_Kz_2_arr, box.new(time[2], _high2, time[0], _low, color.new(color.yellow,100), 1, line.style_solid, ext_imb ? extend.right : extend.none, xloc.bar_time, color.new(color.yellow,100),"0200",text_color = color.new(color.black,100),text_halign = text.align_right,text_valign=text.align_center, text_size = size.normal))
if array.size(Ldn_Kz_2_arr) > 1
box.delete(array.shift(Ldn_Kz_2_arr))
// array.shift(Dead_Kz_5_arr)
if bear_fvg
array.unshift(Ldn_Kz_2_arr2, box.new(time[2], _low2, time[0], _high, color.new(color.yellow,100), 1, line.style_solid, ext_imb ? extend.right : extend.none, xloc.bar_time, color.new(color.yellow,100),"0200", text_color = color.new(color.black,100),text_halign = text.align_right,text_valign=text.align_center, text_size = size.normal))
if array.size(Ldn_Kz_2_arr2) > 1
box.delete(array.shift(Ldn_Kz_2_arr2))
if barstate.isconfirmed and disp_og
if array.size(Ldn_Kz_2_arr) > 0 and array.size(Ldn_Kz_2_arr2) > 0 //if theres a box in both arrays
for i = array.size(Ldn_Kz_2_arr) - 1 to 0 by 1
box2b = array.get(Ldn_Kz_2_arr, i)
box2l = box.get_left(box2b)
box2br = array.get(Ldn_Kz_2_arr2, i)
box2lbr = box.get_left(box2br)
if box2l < box2lbr //if bull older, turn yellow
box.set_bgcolor(box2b,fvgb_imb_c)
box.set_border_color(box2b,fvgb_imb_bc)
if ext_2last
box.set_right(box2b, t1)
if bxtxt
box.set_text_color(box2b, txt_c)
if box2l > box2lbr //if bear older turn yellow
box.set_bgcolor(box2br,fvgbr_imb_c)
box.set_border_color(box2br,fvgb_imb_bc)
if ext_2last
box.set_right(box2br, t1)
if bxtxt
box.set_text_color(box2br, txt_c)
if barstate.isconfirmed and disp_og
if array.size(Ldn_Kz_2_arr) > 0 and array.size(Ldn_Kz_2_arr2) == 0 //if theres only a box in the bull array
for i = array.size(Ldn_Kz_2_arr) - 1 to 0 by 1
box2b = array.get(Ldn_Kz_2_arr, i)
// box4l = box.get_left(box4b)
box.set_bgcolor(box2b,fvgb_imb_c)
box.set_border_color(box2b,fvgb_imb_bc)
if ext_2last
box.set_right(box2b, t1)
if bxtxt
box.set_text_color(box2b, txt_c)
if barstate.isconfirmed and disp_og
if array.size(Ldn_Kz_2_arr2) > 0 and array.size(Ldn_Kz_2_arr) == 0 //if theres only a box in the bull array
for i = array.size(Ldn_Kz_2_arr2) - 1 to 0 by 1
box2br = array.get(Ldn_Kz_2_arr2, i)
// box4l = box.get_left(box4b)
box.set_bgcolor(box2br,fvgbr_imb_c)
box.set_border_color(box2br,fvgbr_imb_bc)
if ext_2last
box.set_right(box2br, t1)
if bxtxt
box.set_text_color(box2br, txt_c)
///NY 3
////finds first bull FVG
if InSession(Ldn_Kz_3) and i_kx3 and isToday and disp_og
if bull_fvg
array.unshift(Ldn_Kz_3_arr, box.new(time[2], _high2, time[0], _low, color.new(color.yellow,100), 1, line.style_solid, ext_imb ? extend.right : extend.none, xloc.bar_time, color.new(color.yellow,100),"0300",text_color = color.new(color.black,100),text_halign = text.align_right,text_valign=text.align_center, text_size = size.normal))
if array.size(Ldn_Kz_3_arr) > 1
box.delete(array.shift(Ldn_Kz_3_arr))
// array.shift(Dead_Kz_5_arr)
if bear_fvg
array.unshift(Ldn_Kz_3_arr2, box.new(time[2], _low2, time[0], _high, color.new(color.yellow,100), 1, line.style_solid, ext_imb ? extend.right : extend.none, xloc.bar_time, color.new(color.yellow,100),"0300",text_color = color.new(color.black,100),text_halign = text.align_right,text_valign=text.align_center, text_size = size.normal))
if array.size(Ldn_Kz_3_arr2) > 1
box.delete(array.shift(Ldn_Kz_3_arr2))
if barstate.isconfirmed and disp_og
if array.size(Ldn_Kz_3_arr) > 0 and array.size(Ldn_Kz_3_arr2) > 0 //if theres a box in both arrays
for i = array.size(Ldn_Kz_3_arr) - 1 to 0 by 1
box3b = array.get(Ldn_Kz_3_arr, i)
box3l = box.get_left(box3b)
box3br = array.get(Ldn_Kz_3_arr2, i)
box3lbr = box.get_left(box3br)
if box3l < box3lbr //if bull older, turn yellow
box.set_bgcolor(box3b,fvgb_imb_c)
box.set_border_color(box3b,fvgb_imb_bc)
if ext_2last
box.set_right(box3b, t1)
if bxtxt
box.set_text_color(box3b, txt_c)
if box3l > box3lbr //if bear older turn yellow
box.set_bgcolor(box3br,fvgbr_imb_c)
box.set_border_color(box3br,fvgb_imb_bc)
if ext_2last
box.set_right(box3br, t1)
if bxtxt
box.set_text_color(box3br, txt_c)
if barstate.isconfirmed and disp_og
if array.size(Ldn_Kz_3_arr) > 0 and array.size(Ldn_Kz_3_arr2) == 0 //if theres only a box in the bull array
for i = array.size(Ldn_Kz_3_arr) - 1 to 0 by 1
box3b = array.get(Ldn_Kz_3_arr, i)
// box4l = box.get_left(box4b)
box.set_bgcolor(box3b,fvgb_imb_c)
box.set_border_color(box3b,fvgb_imb_bc)
if ext_2last
box.set_right(box3b, t1)
if bxtxt
box.set_text_color(box3b, txt_c)
if barstate.isconfirmed and disp_og
if array.size(Ldn_Kz_3_arr2) > 0 and array.size(Ldn_Kz_3_arr) == 0 //if theres only a box in the bull array
for i = array.size(Ldn_Kz_3_arr2) - 1 to 0 by 1
box3br = array.get(Ldn_Kz_3_arr2, i)
// box4l = box.get_left(box4b)
box.set_bgcolor(box3br,fvgbr_imb_c)
box.set_border_color(box3br,fvgbr_imb_bc)
if ext_2last
box.set_right(box3br, t1)
if bxtxt
box.set_text_color(box3br, txt_c)
///NY 4
////finds first bull FVG
if InSession(Ldn_Kz_4) and i_kx4 and isToday and disp_og
if bull_fvg
array.unshift(Ldn_Kz_4_arr, box.new(time[2], _high2, time[0], _low, color.new(color.yellow,100), 1, line.style_solid, ext_imb ? extend.right : extend.none, xloc.bar_time, color.new(color.yellow,100),"0400",text_color = color.new(color.black,100),text_halign = text.align_right,text_valign=text.align_center, text_size = size.normal))
if array.size(Ldn_Kz_4_arr) > 1
box.delete(array.shift(Ldn_Kz_4_arr))
// array.shift(Dead_Kz_5_arr)
if bear_fvg
array.unshift(Ldn_Kz_4_arr2, box.new(time[2], _low2, time[0], _high, color.new(color.yellow,100), 1, line.style_solid, ext_imb ? extend.right : extend.none, xloc.bar_time, color.new(color.yellow,100),"0400",text_color = color.new(color.black,100),text_halign = text.align_right,text_valign=text.align_center, text_size = size.normal))
if array.size(Ldn_Kz_4_arr2) > 1
box.delete(array.shift(Ldn_Kz_4_arr2))
if barstate.isconfirmed and disp_og
if array.size(Ldn_Kz_4_arr) > 0 and array.size(Ldn_Kz_4_arr2) > 0 //if theres a box in both arrays
for i = array.size(Ldn_Kz_4_arr) - 1 to 0 by 1
box4b = array.get(Ldn_Kz_4_arr, i)
box4l = box.get_left(box4b)
box4br = array.get(Ldn_Kz_4_arr2, i)
box4lbr = box.get_left(box4br)
if box4l < box4lbr //if bull older, turn yellow
box.set_bgcolor(box4b,fvgb_imb_c)
box.set_border_color(box4b,fvgbr_imb_bc)
if ext_2last
box.set_right(box4b, t1)
if bxtxt
box.set_text_color(box4b, txt_c)
if box4l > box4lbr //if bear older turn yellow
box.set_bgcolor(box4br,fvgbr_imb_c)
box.set_border_color(box4br,fvgbr_imb_bc)
if ext_2last
box.set_right(box4br, t1)
if bxtxt
box.set_text_color(box4br, txt_c)
if barstate.isconfirmed and disp_og
if array.size(Ldn_Kz_4_arr) > 0 and array.size(Ldn_Kz_4_arr2) == 0 //if theres only a box in the bull array
for i = array.size(Ldn_Kz_4_arr) - 1 to 0 by 1
box4b = array.get(Ldn_Kz_4_arr, i)
// box4l = box.get_left(box4b)
box.set_bgcolor(box4b,fvgb_imb_c)
box.set_border_color(box4b,fvgbr_imb_bc)
if ext_2last
box.set_right(box4b, t1)
if bxtxt
box.set_text_color(box4b, txt_c)
if barstate.isconfirmed and disp_og
if array.size(Ldn_Kz_4_arr2) > 0 and array.size(Ldn_Kz_4_arr) == 0 //if theres only a box in the bull array
for i = array.size(Ldn_Kz_4_arr2) - 1 to 0 by 1
box4br = array.get(Ldn_Kz_4_arr2, i)
// box4l = box.get_left(box4b)
box.set_bgcolor(box4br,fvgbr_imb_c)
box.set_border_color(box4br,fvgbr_imb_bc)
if ext_2last
box.set_right(box4br, t1)
if bxtxt
box.set_text_color(box4br, txt_c)
///Dead Zone 5
////finds first bull FVG
if InSession(Dead_Kz_5) and i_kx5 and isToday and disp_og
if bull_fvg
array.unshift(Dead_Kz_5_arr, box.new(time[2], _high2, time[0], _low, color.new(color.yellow,100), 1, line.style_solid, ext_imb ? extend.right : extend.none, xloc.bar_time, color.new(color.yellow,100),"0500",text_color = color.new(color.black,100),text_halign = text.align_right,text_valign=text.align_center, text_size = size.normal))
if array.size(Dead_Kz_5_arr) > 1
box.delete(array.shift(Dead_Kz_5_arr))
// array.shift(Dead_Kz_5_arr)
if bear_fvg
array.unshift(Dead_Kz_5_arr2, box.new(time[2], _low2, time[0], _high, color.new(color.yellow,100), 1, line.style_solid, ext_imb ? extend.right : extend.none, xloc.bar_time, color.new(color.yellow,100),"0500",text_color = color.new(color.black,100),text_halign = text.align_right,text_valign=text.align_center, text_size = size.normal))
if array.size(Dead_Kz_5_arr2) > 1
box.delete(array.shift(Dead_Kz_5_arr2))
if barstate.isconfirmed and disp_og
if array.size(Dead_Kz_5_arr) > 0 and array.size(Dead_Kz_5_arr2) > 0 //if theres a box in both arrays
for i = array.size(Dead_Kz_5_arr) - 1 to 0 by 1
box5b = array.get(Dead_Kz_5_arr, i)
box5l = box.get_left(box5b)
box5br = array.get(Dead_Kz_5_arr2, i)
box5lbr = box.get_left(box5br)
if box5l < box5lbr //if bull older, turn yellow
box.set_bgcolor(box5b,fvgb_imb_c)
box.set_border_color(box5b,fvgbr_imb_bc)
if ext_2last
box.set_right(box5b, t1)
if bxtxt
box.set_text_color(box5b, txt_c)
if box5l > box5lbr //if bear older turn yellow
box.set_bgcolor(box5br,fvgbr_imb_c)
box.set_border_color(box5br,fvgbr_imb_bc)
if ext_2last
box.set_right(box5br, t1)
if bxtxt
box.set_text_color(box5br, txt_c)
if barstate.isconfirmed and disp_og
if array.size(Dead_Kz_5_arr) > 0 and array.size(Dead_Kz_5_arr2) == 0 //if theres only a box in the bull array
for i = array.size(Dead_Kz_5_arr) - 1 to 0 by 1
box5b = array.get(Dead_Kz_5_arr, i)
// box4l = box.get_left(box4b)
box.set_bgcolor(box5b,fvgb_imb_c)
box.set_border_color(box5b,fvgbr_imb_bc)
if ext_2last
box.set_right(box5b, t1)
if bxtxt
box.set_text_color(box5b, txt_c)
if barstate.isconfirmed and disp_og
if array.size(Dead_Kz_5_arr2) > 0 and array.size(Dead_Kz_5_arr) == 0 //if theres only a box in the bull array
for i = array.size(Dead_Kz_5_arr2) - 1 to 0 by 1
box5br = array.get(Dead_Kz_5_arr2, i)
// box4l = box.get_left(box4b)
box.set_bgcolor(box5br,fvgbr_imb_c)
box.set_border_color(box5br,fvgbr_imb_bc)
if ext_2last
box.set_right(box5br, t1)
if bxtxt
box.set_text_color(box5br, txt_c)
///Dead Zone 6
////finds first bull FVG
if InSession(Dead_Kz_6) and i_kx6 and isToday and disp_og
if bull_fvg
array.unshift(Dead_Kz_6_arr, box.new(time[2], _high2, time[0], _low, color.new(color.yellow,100), 1, line.style_solid, ext_imb ? extend.right : extend.none, xloc.bar_time, color.new(color.yellow,100),"0600",text_color = color.new(color.black,100),text_halign = text.align_right,text_valign=text.align_center, text_size = size.normal))
if array.size(Dead_Kz_6_arr) > 1
box.delete(array.shift(Dead_Kz_6_arr))
// array.shift(Dead_Kz_5_arr)
if bear_fvg
array.unshift(Dead_Kz_6_arr2, box.new(time[2], _low2, time[0], _high, color.new(color.yellow,100), 1, line.style_solid, ext_imb ? extend.right : extend.none, xloc.bar_time, color.new(color.yellow,100),"0600",text_color = color.new(color.black,100),text_halign = text.align_right,text_valign=text.align_center, text_size = size.normal))
if array.size(Dead_Kz_6_arr2) > 1
box.delete(array.shift(Dead_Kz_6_arr2))
if barstate.isconfirmed and disp_og
if array.size(Dead_Kz_6_arr) > 0 and array.size(Dead_Kz_6_arr2) > 0 //if theres a box in both arrays
for i = array.size(Dead_Kz_6_arr) - 1 to 0 by 1
box6b = array.get(Dead_Kz_6_arr, i)
box6l = box.get_left(box6b)
box6br = array.get(Dead_Kz_6_arr2, i)
box6lbr = box.get_left(box6br)
if box6l < box6lbr //if bull older, turn yellow
box.set_bgcolor(box6b,fvgb_imb_c)
box.set_border_color(box6b,fvgb_imb_bc)
if ext_2last
box.set_right(box6b, t1)
if bxtxt
box.set_text_color(box6b, txt_c)
if box6l > box6lbr //if bear older turn yellow
box.set_bgcolor(box6br,fvgbr_imb_c)
box.set_border_color(box6br,fvgb_imb_bc)
if ext_2last
box.set_right(box6br, t1)
if bxtxt
box.set_text_color(box6br, txt_c)
if barstate.isconfirmed and disp_og
if array.size(Dead_Kz_6_arr) > 0 and array.size(Dead_Kz_6_arr2) == 0 //if theres only a box in the bull array
for i = array.size(Dead_Kz_6_arr) - 1 to 0 by 1
box6b = array.get(Dead_Kz_6_arr, i)
// box4l = box.get_left(box4b)
box.set_bgcolor(box6b,fvgb_imb_c)
box.set_border_color(box6b,fvgb_imb_bc)
if ext_2last
box.set_right(box6b, t1)
if bxtxt
box.set_text_color(box6b, txt_c)
if barstate.isconfirmed and disp_og
if array.size(Dead_Kz_6_arr2) > 0 and array.size(Dead_Kz_6_arr) == 0 //if theres only a box in the bull array
for i = array.size(Dead_Kz_6_arr2) - 1 to 0 by 1
box6br = array.get(Dead_Kz_6_arr2, i)
// box4l = box.get_left(box4b)
box.set_bgcolor(box6br,fvgbr_imb_c)
box.set_border_color(box6br,fvgb_imb_bc)
if ext_2last
box.set_right(box6br, t1)
if bxtxt
box.set_text_color(box6br, txt_c)
///NY 7
////finds first bull FVG
if InSession(NY_Kz_7) and i_kx7 and isToday and disp_og
if bull_fvg
array.unshift(NY_Kz_7_arr, box.new(time[2], _high2, time[0], _low, color.new(color.yellow,100), 1, line.style_solid, ext_imb ? extend.right : extend.none, xloc.bar_time, color.new(color.yellow,100),"0700",text_color = color.new(color.black,100),text_halign = text.align_right,text_valign=text.align_center, text_size = size.normal))
if array.size(NY_Kz_7_arr) > 1
box.delete(array.shift(NY_Kz_7_arr))
// array.shift(Dead_Kz_5_arr)
if bear_fvg
array.unshift(NY_Kz_7_arr2, box.new(time[2], _low2, time[0], _high, color.new(color.yellow,100), 1, line.style_solid, ext_imb ? extend.right : extend.none, xloc.bar_time, color.new(color.yellow,100),"0700",text_color = color.new(color.black,100),text_halign = text.align_right,text_valign=text.align_center, text_size = size.normal))
if array.size(NY_Kz_7_arr2) > 1
box.delete(array.shift(NY_Kz_7_arr2))
if barstate.isconfirmed and disp_og
if array.size(NY_Kz_7_arr) > 0 and array.size(NY_Kz_7_arr2) > 0 //if theres a box in both arrays
for i = array.size(NY_Kz_7_arr) - 1 to 0 by 1
box7b = array.get(NY_Kz_7_arr, i)
box7l = box.get_left(box7b)
box7br = array.get(NY_Kz_7_arr2, i)
box7lbr = box.get_left(box7br)
if box7l < box7lbr //if bull older, turn yellow
box.set_bgcolor(box7b,fvgb_imb_c)
box.set_border_color(box7b,fvgb_imb_bc)
if ext_2last
box.set_right(box7b, t1)
if bxtxt
box.set_text_color(box7b, txt_c)
if box7l > box7lbr //if bear older turn yellow
box.set_bgcolor(box7br,fvgbr_imb_c)
box.set_border_color(box7br,fvgb_imb_bc)
if ext_2last
box.set_right(box7br, t1)
if bxtxt
box.set_text_color(box7br, txt_c)
if barstate.isconfirmed and disp_og
if array.size(NY_Kz_7_arr) > 0 and array.size(NY_Kz_7_arr2) == 0 //if theres only a box in the bull array
for i = array.size(NY_Kz_7_arr) - 1 to 0 by 1
box7b = array.get(NY_Kz_7_arr, i)
// box4l = box.get_left(box4b)
box.set_bgcolor(box7b,fvgb_imb_c)
box.set_border_color(box7b,fvgb_imb_bc)
if ext_2last
box.set_right(box7b, t1)
if bxtxt
box.set_text_color(box7b, txt_c)
if barstate.isconfirmed and disp_og
if array.size(NY_Kz_7_arr2) > 0 and array.size(NY_Kz_7_arr) == 0 //if theres only a box in the bull array
for i = array.size(NY_Kz_7_arr2) - 1 to 0 by 1
box7br = array.get(NY_Kz_7_arr2, i)
// box4l = box.get_left(box4b)
box.set_bgcolor(box7br,fvgbr_imb_c)
box.set_border_color(box7br,fvgb_imb_bc)
if ext_2last
box.set_right(box7br, t1)
if bxtxt
box.set_text_color(box7br, txt_c)
///NY 830
////finds first bull FVG
if InSession(NY_Kz_830) and i_kx830 and isToday and disp_og
if bull_fvg
array.unshift(NY_Kz_830_arr, box.new(time[2], _high2, time[0], _low, color.new(color.yellow,100), 1, line.style_solid, ext_imb ? extend.right : extend.none, xloc.bar_time, color.new(color.yellow,100),"0830",text_color = color.new(color.black,100),text_halign = text.align_right,text_valign=text.align_center, text_size = size.normal))
if array.size(NY_Kz_830_arr) > 1
box.delete(array.shift(NY_Kz_830_arr))
// array.shift(Dead_Kz_5_arr)
if bear_fvg
array.unshift(NY_Kz_830_arr2, box.new(time[2], _low2, time[0], _high, color.new(color.yellow,100), 1, line.style_solid, ext_imb ? extend.right : extend.none, xloc.bar_time, color.new(color.yellow,100),"0830",text_color = color.new(color.black,100),text_halign = text.align_right,text_valign=text.align_center, text_size = size.normal))
if array.size(NY_Kz_830_arr2) > 1
box.delete(array.shift(NY_Kz_830_arr2))
if barstate.isconfirmed and disp_og
if array.size(NY_Kz_830_arr) > 0 and array.size(NY_Kz_830_arr2) > 0 //if theres a box in both arrays
for i = array.size(NY_Kz_830_arr) - 1 to 0 by 1
box8b = array.get(NY_Kz_830_arr, i)
box8l = box.get_left(box8b)
box8br = array.get(NY_Kz_830_arr2, i)
box8lbr = box.get_left(box8br)
if box8l < box8lbr //if bull older, turn yellow
box.set_bgcolor(box8b,fvgb_imb_c)
box.set_border_color(box8b,fvgb_imb_bc)
if ext_2last
box.set_right(box8b, t1)
if bxtxt
box.set_text_color(box8b, txt_c)
if box8l > box8lbr //if bear older turn yellow
box.set_bgcolor(box8br,fvgbr_imb_c)
box.set_border_color(box8br,fvgbr_imb_bc)
if ext_2last
box.set_right(box8br, t1)
if bxtxt
box.set_text_color(box8br, txt_c)
if barstate.isconfirmed and disp_og
if array.size(NY_Kz_830_arr) > 0 and array.size(NY_Kz_830_arr2) == 0 //if theres only a box in the bull array
for i = array.size(NY_Kz_830_arr) - 1 to 0 by 1
box8b = array.get(NY_Kz_830_arr, i)
// box4l = box.get_left(box4b)
box.set_bgcolor(box8b,fvgb_imb_c)
box.set_border_color(box8b,fvgb_imb_bc)
if ext_2last
box.set_right(box8b, t1)
if bxtxt
box.set_text_color(box8b, txt_c)
if barstate.isconfirmed and disp_og
if array.size(NY_Kz_830_arr2) > 0 and array.size(NY_Kz_830_arr) == 0 //if theres only a box in the bull array
for i = array.size(NY_Kz_830_arr2) - 1 to 0 by 1
box8br = array.get(NY_Kz_830_arr2, i)
// box4l = box.get_left(box4b)
box.set_bgcolor(box8br,fvgbr_imb_c)
box.set_border_color(box8br,fvgbr_imb_bc)
if ext_2last
box.set_right(box8br, t1)
if bxtxt
box.set_text_color(box8br, txt_c)
///NY 930
////finds first bull FVG
if InSession(NY_Kz_930) and i_kx930 and isToday and disp_og
if bull_fvg
array.unshift(NY_Kz_930_arr, box.new(time[2], _high2, time[0], _low, color.new(color.yellow,100), 1, line.style_solid, ext_imb ? extend.right : extend.none, xloc.bar_time, color.new(color.yellow,100),"0930",text_color = color.new(color.black,100),text_halign = text.align_right,text_valign=text.align_center, text_size = size.normal))
if array.size(NY_Kz_930_arr) > 1
box.delete(array.shift(NY_Kz_930_arr))
// array.shift(Dead_Kz_5_arr)
if bear_fvg
array.unshift(NY_Kz_930_arr2, box.new(time[2], _low2, time[0], _high, color.new(color.yellow,100), 1, line.style_solid, ext_imb ? extend.right : extend.none, xloc.bar_time, color.new(color.yellow,100),"0930",text_color = color.new(color.black,100),text_halign = text.align_right,text_valign=text.align_center, text_size = size.normal))
if array.size(NY_Kz_930_arr2) > 1
box.delete(array.shift(NY_Kz_930_arr2))
if barstate.isconfirmed and disp_og
if array.size(NY_Kz_930_arr) > 0 and array.size(NY_Kz_930_arr2) > 0 //if theres a box in both arrays
for i = array.size(NY_Kz_930_arr) - 1 to 0 by 1
box9b = array.get(NY_Kz_930_arr, i)
box9l = box.get_left(box9b)
box9br = array.get(NY_Kz_930_arr2, i)
box9lbr = box.get_left(box9br)
if box9l < box9lbr //if bull older, turn yellow
box.set_bgcolor(box9b,fvgb_imb_c)
box.set_border_color(box9b,fvgb_imb_bc)
if ext_2last
box.set_right(box9b, t1)
if bxtxt
box.set_text_color(box9b, txt_c)
if box9l > box9lbr //if bear older turn yellow
box.set_bgcolor(box9br,fvgbr_imb_c)
box.set_border_color(box9br,fvgb_imb_bc)
if ext_2last
box.set_right(box9br, t1)
if bxtxt
box.set_text_color(box9br, txt_c)
if barstate.isconfirmed and disp_og
if array.size(NY_Kz_930_arr) > 0 and array.size(NY_Kz_930_arr2) == 0 //if theres only a box in the bull array
for i = array.size(NY_Kz_930_arr) - 1 to 0 by 1
box9b = array.get(NY_Kz_930_arr, i)
// box4l = box.get_left(box4b)
box.set_bgcolor(box9b,fvgb_imb_c)
box.set_border_color(box9b,fvgb_imb_bc)
if ext_2last
box.set_right(box9b, t1)
if bxtxt
box.set_text_color(box9b, txt_c)
if barstate.isconfirmed and disp_og
if array.size(NY_Kz_930_arr2) > 0 and array.size(NY_Kz_930_arr) == 0 //if theres only a box in the bull array
for i = array.size(NY_Kz_930_arr2) - 1 to 0 by 1
box9br = array.get(NY_Kz_930_arr2, i)
// box4l = box.get_left(box4b)
box.set_bgcolor(box9br,fvgbr_imb_c)
box.set_border_color(box9br,fvgb_imb_bc)
if ext_2last
box.set_right(box9br, t1)
if bxtxt
box.set_text_color(box9br, txt_c)
///NY 1000 Silver Bullet
////finds first bull FVG
if InSession(NY_Kz_10) and i_kx10 and isToday and disp_og
if bull_fvg
array.unshift(NY_Kz_10_arr, box.new(time[2], _high2, time[0], _low, color.new(color.yellow,100), 1, line.style_solid, ext_imb ? extend.right : extend.none, xloc.bar_time, color.new(color.yellow,100),"1000",text_color = color.new(color.black,100),text_halign = text.align_right,text_valign=text.align_center, text_size = size.normal))
if array.size(NY_Kz_10_arr) > 1
box.delete(array.shift(NY_Kz_10_arr))
// array.shift(Dead_Kz_5_arr)
if bear_fvg
array.unshift(NY_Kz_10_arr2, box.new(time[2], _low2, time[0], _high, color.new(color.yellow,100), 1, line.style_solid, ext_imb ? extend.right : extend.none, xloc.bar_time, color.new(color.yellow,100),"1000",text_color = color.new(color.black,100),text_halign = text.align_right,text_valign=text.align_center, text_size = size.normal))
if array.size(NY_Kz_10_arr2) > 1
box.delete(array.shift(NY_Kz_10_arr2))
if barstate.isconfirmed and disp_og
if array.size(NY_Kz_10_arr) > 0 and array.size(NY_Kz_10_arr2) > 0 //if theres a box in both arrays
for i = array.size(NY_Kz_10_arr) - 1 to 0 by 1
box10b = array.get(NY_Kz_10_arr, i)
box10l = box.get_left(box10b)
box10br = array.get(NY_Kz_10_arr2, i)
box10lbr = box.get_left(box10br)
if box10l < box10lbr //if bull older, turn yellow
box.set_bgcolor(box10b,fvgb_sb_c)
box.set_border_color(box10b,fvgb_sb_bc)
if ext_2last
box.set_right(box10b, t1)
if bxtxt
box.set_text_color(box10b, txt_c)
if box10l > box10lbr //if bear older turn yellow
box.set_bgcolor(box10br,fvgb_sb_c)
box.set_border_color(box10br,fvgb_sb_bc)
if ext_2last
box.set_right(box10br, t1)
if bxtxt
box.set_text_color(box10br, txt_c)
if barstate.isconfirmed and disp_og
if array.size(NY_Kz_10_arr) > 0 and array.size(NY_Kz_10_arr2) == 0 //if theres only a box in the bull array
for i = array.size(NY_Kz_10_arr) - 1 to 0 by 1
box10b = array.get(NY_Kz_10_arr, i)
// box4l = box.get_left(box4b)
box.set_bgcolor(box10b,fvgb_sb_c)
box.set_border_color(box10b,fvgb_sb_bc)
if ext_2last
box.set_right(box10b, t1)
if bxtxt
box.set_text_color(box10b, txt_c)
if barstate.isconfirmed and disp_og
if array.size(NY_Kz_10_arr2) > 0 and array.size(NY_Kz_10_arr) == 0 //if theres only a box in the bull array
for i = array.size(NY_Kz_10_arr2) - 1 to 0 by 1
box10br = array.get(NY_Kz_10_arr2, i)
// box4l = box.get_left(box4b)
box.set_bgcolor(box10br,fvgb_sb_c)
box.set_border_color(box10br,fvgb_sb_bc)
if ext_2last
box.set_right(box10br, t1)
if bxtxt
box.set_text_color(box10br, txt_c)