EzSMC Compact
EzSMC Compact
EzSMC Compact
//---------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------
//--------------------------------------------------------------- Input
Settings
//---------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------
//----------------------------------------}
//Order Blocks
//----------------------------------------{
v_buy = #00dbff4d
v_sell = #e91e634d
timeframe1=' : '
show_iob = 'All'=='All' or 'All'=='Internal' //input(true, 'Internal', inline =
'ob', group = 'Order Blocks')
show_ob = 'All'=='All' or 'All'=='External' //input(false, 'External', inline =
'ob', group = 'Order Blocks')
ob_showlast = 5//input.int(10, 'LookBack', minval = 1, inline = 'ob', group =
'Order Blocks')
iob_showlast = 5//input.int(5, 'LookBack', minval = 1, inline = 'iob', group =
'Order Blocks')
style = 'Colored'
v_lookback= 10
ob_loockback=10
timediff=(time[1]-time[101])/100
//----------------------------------------}
//Liquidity Levels
//----------------------------------------{
i_bullishfvgcolor = color.new(color.green,100)
i_bearishfvgcolor = color.new(color.green,90)
i_fillByMid = true
i_deleteonfill = true
i_textColor = color.white
i_mtf = "HTF"
i_tfos = 10
i_mtfos = 50
//----------------------------------------}
//BOS and ChoCH
//----------------------------------------{
// Constants
color CLEAR = color.rgb(0,0,0,100)
// Inputs
showms=input(true,title="ChoCH & BoS ", inline="0")
bosColor1 = input.color(#787b86 , '', inline="0")
bosColor2 = input.color(#787b86 , '', inline="0")
swingSize = 3
//-----------------------------------------------------------------------------}
//Global variables
//-----------------------------------------------------------------------------{
color transparent = #ffffff00
length = 50
is_newbar(res) =>
t = time(res)
not na(t) and (na(t[1]) or t > t[1])
//Swings detection/measurements
calculate_swing_points(length)=>
var prev = 0
prev := high[length] > ta.highest(length) ? 0 : low[length] < ta.lowest(length)
? 1 : prev[1]
t = prev == 0 and prev[1] != 0 ? high[length] : 0
b = prev == 1 and prev[1] != 1 ? low[length] : 0
[t, b]
var t_MS = 0, var int_t_MS = 0
var internal_y_up = 0., var internal_x_up = 0, var internal_y_dn = 0., var
internal_x_dn = 0
var y_up = 0., var x_up = 0 , var y_dn = 0., var x_dn = 0
var crossed_up = true, var crossed_down = true
var internal_up_broke = true, var internal_dn_broke = true
var up_trailing = high, var down_trailing = low
var up_trailing_x = 0, var down_trailing_x = 0
var high_text = '', var low_text = ''
bullish_OB_Break = false
bearish_OB_Break = false
//---------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------
//--------------------------------------------------------------- Market
Structure
//---------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------
// Functions
lineStyle(x) =>
switch x
'Solid' => line.style_solid
'Dashed' => line.style_dashed
'Dotted' => line.style_dotted
pivot_high_found = ta.pivothigh(high, 10, 10)
pivot_low_found = ta.pivotlow(low, 10, 10)
var float prevHigh_s = na,var float prevLow_s = na,var int prevHighIndex_s = na,var
int prevLowIndex_s = na
bool higher_highs = false, bool lower_highs = false, bool higher_lows = false, bool
lower_lows = false
if not na(pivot_high_found)
if pivot_high_found >= prevHigh_s
higher_highs := true
prevSwing_s := 2
else
lower_highs := true
prevSwing_s := 1
prevHigh_s := pivot_high_found
prevHighIndex_s := bar_index - 10
if not na(pivot_low_found)
if pivot_low_found >= prevLow_s
higher_lows := true
prevSwing_s := -1
else
lower_lows := true
prevSwing_s := -2
prevLow_s := pivot_low_found
prevLowIndex_s := bar_index - 10
//---------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------
//--------------------------------------------------------------- Fair Value
Gaps
//---------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------
// }
// }
//var keyword can be used to hold data in memory, with pinescript all data is lost
including variables unless the var keyword is used to preserve this data
var bullishgapholder = array.new_box(0)
var bearishgapholder = array.new_box(0)
var fvg_apper=false
var fvg_break=false
fvg_apper:=false
fvg_break:=false
// ———————————————————— Functions {
//function paramaters best declared with '_' this helps defer from variables in the
function scope declaration and elsewhere e.g. close => _close
create_fvg_func(_upperlimit,_lowerlimit,_midlimit,_bar,_boxholder,_boxholder_fill,_
midholder,_highholder,_lowholder,_labelholder,_boxcolor,_mtfboxcolor, _htf)=>
timeholder = str.tostring(i_tf)
offset = i_mtfos
boxbgcolor = _mtfboxcolor
bg_color = color.new(_mtfboxcolor,90)
if _htf == false
timeholder := str.tostring(timeframe.period)
offset := i_tfos
boxbgcolor := _boxcolor
array.push(_boxholder,box.new(_bar,_upperlimit,_bar+
(timediff)*20,_lowerlimit,border_color=true? bg_color : na,bgcolor = true? bg_color
: na, extend = false ? extend.right:extend.none,xloc =
xloc.bar_time,text='',text_color=#787b86,text_halign=text.align_right,text_size=siz
e.small))
array.push(_boxholder_fill,box.new(_bar,_upperlimit,_bar+
(timediff)*20,_lowerlimit,border_color=true? bg_color : na ,bgcolor = true?
bg_color : na, extend = false ? extend.right:extend.none,xloc = xloc.bar_time))
array.push(_midholder,line.new(_bar,(_lowerlimit+_upperlimit)/2.0,_bar+
(timediff)*20,_midlimit,color = #787b86, extend = false ?
extend.right:extend.none,style=line.style_solid,width=1,xloc = xloc.bar_time))
array.push(_lowholder,line.new(_bar,_lowerlimit,_bar+
(timediff)*20,_lowerlimit,color = i_fillByMid?boxbgcolor:na, extend = false ?
extend.right:extend.none,width=1,xloc = xloc.bar_time))
array.push(_highholder,line.new(_bar,_upperlimit,_bar+
(timediff)*20,_upperlimit,color = i_fillByMid?boxbgcolor:na, extend = false ?
extend.right:extend.none,width=1,xloc = xloc.bar_time))
//checks for gap between current candle and 2 previous candle e.g. low of current
candle and high of the candle before last, this is the fair value gap.
check_fvg_func(_close,_high,_highp2,_low,_lowp2,_open,_bar,_htf)=>
gap=0
thold_ = (ta.highest(_high,300) - ta.lowest(_low,300)) * math.max(1.5, 0.1) /
100.
if _open > _close // red
if _lowp2>_high
if not(true) or math.abs(_lowp2 -_high) > thold_
upperlimit = _high//_close - (_close - _lowp2 )
lowerlimit = _lowp2//_close - (_close-_high)
midlimit = lowerlimit + ((upperlimit - lowerlimit) / 2.)
gap:=1
create_fvg_func(upperlimit,lowerlimit,midlimit,_bar,bullishgapholder,bullishgaphold
er_fill,bullishmidholder,bullish_high_holder,bullish_low_holder,bullishlabelholder,
i_bullishfvgcolor,i_mtfbullishfvgcolor,_htf)
else
if _low>_highp2
if not(true) or math.abs(_low - _highp2) > thold_
upperlimit = _low//_close - (_close-_low)
lowerlimit = _highp2//_close- (_close - _highp2),
midlimit = lowerlimit + ((upperlimit - lowerlimit) / 2.)
gap:=-1
create_fvg_func(upperlimit,lowerlimit,midlimit,_bar,bearishgapholder,bearishgaphold
er_fill,bearishmidholder,bearish_high_holder,bearish_low_holder,bearishlabelholder,
i_bearishfvgcolor,i_mtfbearishfvgcolor,_htf)
gap
//Used to remove the gap from its relevant array as a result of it being filled.
delete_fvg_func(_currentgap,_currentgap_fill,_i,_boxholder,_boxholder_fill,_midhold
er,_highholder,_lowholder,_labelholder)=>
array.remove(_boxholder,_i)
array.remove(_boxholder_fill,_i)
currentmid=array.get(_midholder,_i)
currenthigh=array.get(_highholder,_i)
currentlow=array.get(_lowholder,_i)
array.remove(_midholder,_i)
array.remove(_highholder,_i)
array.remove(_lowholder,_i)
if i_deleteonfill
line.delete(currentmid)
line.delete(currenthigh)
line.delete(currentlow)
else
line.set_extend(currentmid, extend.none)
line.set_x2(currentmid,time)
line.set_extend(currenthigh, extend.none)
line.set_x2(currenthigh,time)
line.set_extend(currentlow, extend.none)
line.set_x2(currentlow,time)
if i_deleteonfill
box.delete(_currentgap)
box.delete(_currentgap_fill)
else
box.set_extend(_currentgap,extend.none)
box.set_right(_currentgap,time)
//checks if gap has been filled either by 0.5 fill (i_fillByMid) or SHRINKS the gap
to reflect the true value gap left.
validate_fvg_func(_high,_low)=>
fvg_removed=0
if array.size(bullishgapholder) > 0
for i = array.size(bullishgapholder)-1 to 0
currentgap_fill = array.get(bullishgapholder_fill,i)
currentgap = array.get(bullishgapholder,i)
cmid = array.get(bullishmidholder,i)
chigh = array.get(bullish_high_holder,i)
clow = array.get(bullish_low_holder,i)
line.set_x2(cmid,timenow+(timediff)*20)
line.set_x2(chigh,timenow+(timediff)*20)
line.set_x2(clow,timenow+(timediff)*20)
box.set_right(currentgap_fill,timenow+(timediff)*20)
box.set_right(currentgap,timenow+(timediff)*20)
currentmid = array.get(bullishmidholder,i)
currenthigh = array.get(bullish_high_holder,i)
currentlow = array.get(bullish_low_holder,i)
currenttop = box.get_top(currentgap)
delete_fvg_func(currentgap,currentgap_fill,i,bullishgapholder,bullishgapholder_fill
,bullishmidholder,bullish_high_holder,bullish_low_holder,bullishlabelholder)
if array.size(bearishgapholder) > 0
for i = array.size(bearishgapholder)-1 to 0
currentgap_fill = array.get(bearishgapholder_fill,i)
currentgap = array.get(bearishgapholder,i)
cmid = array.get(bearishmidholder,i)
chigh = array.get(bearish_high_holder,i)
clow = array.get(bearish_low_holder,i)
line.set_x2(cmid,timenow+(timediff)*20)
line.set_x2(chigh,timenow+(timediff)*20)
line.set_x2(clow,timenow+(timediff)*20)
box.set_right(currentgap_fill,timenow+(timediff)*20)
box.set_right(currentgap,timenow+(timediff)*20)
currenttop = box.get_top(currentgap)
currentmid = array.get(bearishmidholder,i)
currenthigh = array.get(bearish_high_holder,i)
currentlow = array.get(bearish_low_holder,i)
delete_fvg_func(currentgap,currentgap_fill,i,bearishgapholder,bearishgapholder_fill
,bearishmidholder,bearish_high_holder,bearish_low_holder,bearishlabelholder)
fvg_removed
if is_newbar(i_tf)
htfH := high
htfL := low
// }
fvg_gap=0
fvg_removed=validate_fvg_func(high,low)
if array.size(bullishgapholder) > 4
d_box=array.shift(bullishgapholder)
box.delete(d_box)
if array.size(bullishgapholder_fill) > 4
d_box=array.shift(bullishgapholder_fill)
box.delete(d_box)
if array.size(bullishmidholder) > 4
d_line=array.shift(bullishmidholder)
line.delete(d_line)
if array.size(bullish_high_holder) > 4
d_line=array.shift(bullish_high_holder)
line.delete(d_line)
if array.size(bullish_low_holder) > 4
d_line=array.shift(bullish_low_holder)
line.delete(d_line)
if array.size(bearishgapholder) > 4
d_box_=array.shift(bearishgapholder)
box.delete(d_box_)
if array.size(bearishgapholder_fill) > 4
d_box_=array.shift(bearishgapholder_fill)
box.delete(d_box_)
if array.size(bearishmidholder) > 4
d_line_=array.shift(bearishmidholder)
line.delete(d_line_)
if array.size(bearish_high_holder) > 4
d_line_=array.shift(bearish_high_holder)
line.delete(d_line_)
if array.size(bearish_low_holder) > 4
d_line_=array.shift(bearish_low_holder)
line.delete(d_line_)
n=bar_index
//---------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------
//--------------------------------------------------------------- Liquidity
Levels
//---------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------
// --
highLineColor = highLineColorHTF//input.color(#1f4ef5, "High Line ", group =
liquidity_level_group, inline = "1")
lowLineColor = lowLineColorHTF//input.color(#fd441c, "Low Line", group =
liquidity_level_group, inline = "1")
highBoxBgColor = highLineColorHTF//input.color(color.new(#1f4ef5, 80), "High Box
Bg ", group = liquidity_level_group, inline = "2")
highBoxBorderColor = highBoxBorderColorHTF//input.color(color.new(#1f4ef5, 80),
"Box Border", group = liquidity_level_group, inline = "2")
lowBoxBgColor = lowLineColorHTF//input.color(color.new(#fd441c, 80), "Low Box
Bg ", group = liquidity_level_group, inline = "3")
lowBoxBorderColor = lowBoxBorderColorHTF//input.color(color.new(#fd441c, 80), "Box
Border", group = liquidity_level_group, inline = "3")
atr_liq = ta.atr(300)
tf_multi(tf) =>
ts = timeframe.in_seconds("")
htfs = timeframe.in_seconds(tf)
htfs/ts
display_limit_line(_array) =>
if array.size(_array) > 6/2
a = array.shift(_array)
line.delete(a)
display_limit_box(_array) =>
if array.size(_array) > 6/2
a = array.shift(_array)
box.delete(a)
extend_line_to_current(lineArray) =>
if array.size(lineArray) > 0
for i = array.size(lineArray) - 1 to 0 by 1
l = array.get(lineArray, i)
timeExt = timenow + ((timediff)*20)
line.set_x2(l, timeExt)
extend_box_to_current(boxArray) =>
if array.size(boxArray) > 0
for i = array.size(boxArray) - 1 to 0 by 1
b = array.get(boxArray, i)
timeExt = timenow + ((timediff)*20)
box.set_right(b, timeExt)
// ----------------------------------------------------
// Higher TimeFrame
// ----------------------------------------------------
// Varibles
// Lines
var highLineArrayHTF = array.new_line()
var lowLineArrayHTF = array.new_line()
// Boxes
var highBoxArrayHTF = array.new_box()
var lowBoxArrayHTF = array.new_box()
// Get HTF
[_time, _open, _high, _low, _close] = request.security(syminfo.tickerid, htfTF,
[time, open, high, low, close])
// Pivots
pivotHighHTF = ta.pivothigh(_high, 8*tf_multi(htfTF), 8+tf_multi(htfTF))
pivotLowHTF = ta.pivotlow(_low, 8*tf_multi(htfTF), 8+tf_multi(htfTF))
if currentTF
timeExt = time+((time[1]-time[2])*10)
dis = 8+tf_multi(htfTF)
if pivotHighHTF
if displayStyle_liq == "Lines"
array.push(highLineArrayHTF,
line.new(_time[dis],_high[dis],_time[+1],_high[dis],color = highLineColorHTF,
style=highLineStyleHTF, xloc=xloc.bar_time, width = lineWidthHTF))
else
y1 = _high[dis]-thold_liq//math.max(_open[dis], _close[dis])
array.push(highBoxArrayHTF,
box.new(_time[dis],_high[dis],_time[+1],y1,bgcolor = highLineColorHTF,
border_color=highBoxBorderColorHTF, xloc=xloc.bar_time, border_style =
highLineStyleHTF, border_width = lineWidthHTF))
if pivotLowHTF
if displayStyle_liq == "Lines"
array.push(lowLineArrayHTF,
line.new(_time[dis],_low[dis],_time[+1],_low[dis],color = lowLineColorHTF,
style=highLineStyleHTF, xloc=xloc.bar_time, width = lineWidthHTF))
else
y1 = _low[dis]+thold_liq//math.min(_open[dis], _close[dis])
array.push(lowBoxArrayHTF,
box.new(_time[dis],_low[dis],_time[+1],y1,bgcolor = lowLineColorHTF,
border_color=lowBoxBorderColorHTF, xloc=xloc.bar_time, border_style =
highLineStyleHTF, border_width = lineWidthHTF))
// ----------------------------------------------------
// Run Functions
// ----------------------------------------------------
highLineAlertHTF = remove_mitigated_lines(highLineArrayHTF, "High")
lowLineAlertHTF = remove_mitigated_lines(lowLineArrayHTF, "Low")
highBoxAlertHTF = remove_mitigated_boxes(highBoxArrayHTF, "High")
lowBoxAlertHTF = remove_mitigated_boxes(lowBoxArrayHTF, "Low")
extend_line_to_current(highLineArrayHTF)
extend_line_to_current(lowLineArrayHTF)
extend_box_to_current(highBoxArrayHTF)
extend_box_to_current(lowBoxArrayHTF)
// Alerts
alertcondition(pivotHighHTF, "High Liquidity Level", "High Liquidity Level Found
Ez-SMC")
alertcondition(pivotLowHTF, "Low Liquidity Level", "Low Liquidity Level Found Ez-
SMC")
swing_bull_css = bosColor1
swing_bear_css = bosColor2
var bullish_col_ChoCH = swing_bull_css
var bearish_col_ChoCH = swing_bear_css
var internal_bullish_col_ChoCH = bosColor1
var internal_bearish_col_ChoCH = bosColor2
[high_ms, low_ms] = calculate_swing_points(length)
n := bar_index
//HL Output function
hl() => [high, low]
var float thold = (ta.highest(300) - ta.lowest(300)) * math.max(0.5, 0.1) / 100.
internal_structure_lbl_size=size.small
[int_high_ms, int_low_ms] = calculate_swing_points(swingSize)
swing_structure_lbl_size=size.small
if low_ms
crossed_down := true
y_dn := low_ms
x_dn := n-length
if high_ms
crossed_up := true
y_up := high_ms
x_up := n - length
if int_low_ms
internal_dn_broke := true
internal_y_dn := int_low_ms
internal_x_dn := n - swingSize
if int_high_ms
internal_up_broke := true
internal_y_up := int_high_ms
internal_x_up := n - swingSize
bull_ChoCH=false,bull_ChoCH_=false,bull_bos=false,bull_bos_=false,bear_ChoCH=false,
bear_ChoCH_=false,bear_bos=false,bear_bos_=false
if ta.crossover(close, internal_y_up) and internal_up_broke and y_up !=
internal_y_up
bool ChoCH = na
ChoCH := int_t_MS < 0
internal_up_broke := false
int_t_MS := 1
bull_ChoCH:=ChoCH?true:false
bull_bos:=ChoCH?false:true
if showms
Show_MS(internal_x_up, internal_y_up, ChoCH ? 'ChoCH' : 'BOS',
internal_bullish_col_ChoCH, true, true, internal_structure_lbl_size)
if ta.crossunder(close, internal_y_dn) and internal_dn_broke and y_dn !=
internal_y_dn
bool ChoCH = false
ChoCH := int_t_MS > 0
internal_dn_broke := false
int_t_MS := -1
bear_ChoCH:=ChoCH?true:false
bear_bos:=ChoCH?false:true
if showms
Show_MS(internal_x_dn, internal_y_dn, ChoCH ? 'ChoCH' : 'BOS',
internal_bearish_col_ChoCH, true, false, internal_structure_lbl_size)
//-----------------------------------------------------------------------------}
//Order Blocks
//-----------------------------------------------------------------------------{
first_nonzero_digit(n) =>
s = str.tostring(n)
int r=int (str.tonumber(s[0]))
for c=0 to str.length(s)-1
if s[c] != '0'
r:=int (str.tonumber(s[c]))
r
type_obs="none"
valid=false
H=high
L=low
O=open
C=close
V=volume
idx=1
volume_=0.0
b_volume=0
s_volume=0
use_max=false
min = 99999999.
max = 0.
ind=0
thold_ = (ta.highest(300) - ta.lowest(300)) * (3/2.) / 100.
volume_:=V
//Search for highest/lowest high within the structure interval and get
range
if use_max
max:=H//[idx]
min_1=L//[idx]//H[1]-math.min(open[1],close[1])>ob_threshold
min:=math.max(min_1,max-thold_)
else
max_1=H//[idx]//math.max(open[idx],close[idx])
min:=L//[idx]
max:=math.min(max_1,min+thold_)
[valid,volume_,b_volume,s_volume,max,min,idx,use_max ? -1 : 1,type_obs]
for i = 0 to size-1
get_box = array.get(boxes, i)
get_line = array.get(lines, i)
max_left=bar_index-750
volume_sum=array.sum(vol)
volume_=array.get(vol, i)>100000000 ? array.get(vol, i)/100000000.:
array.get(vol, i)>1000000 ? array.get(vol, i)/1000000. : array.get(vol, i)/1000.
volume_per=(array.get(vol, i)/volume_sum)*100
unit=array.get(vol, i)>100000000 ?' B': array.get(vol, i)>1000000 ?' M' : '
K'
text_vol=vol_text and perct_text ? tf_text + str.tostring(volume_,'#.##')+
unit + ' ('+ str.tostring(volume_per,'#.##')+'%)' : vol_text and not(perct_text) ?
tf_text + str.tostring(volume_,'#.##')+ unit : not(vol_text) and perct_text ?
tf_text + ' '+ str.tostring(volume_per,'#.##')+'%' : tf_text_2+ ''
if true//max_left<array.get(target_left, i)
box.set_lefttop(get_box, array.get(target_left, i),
array.get(target_top, i))
box.set_rightbottom(get_box,timenow+((timediff)*length_extend_ob) ,
array.get(target_btm, i))
box.set_text(get_box,text_vol)
box.set_text_color(get_box,text_color_ob)
box.set_border_color(get_box,color.gray)
box.set_border_width(get_box,2)
box.set_text_halign(get_box,text.align_right)
box.set_text_valign(get_box,text.align_center)
box.set_text_size(get_box,ob_text_size)
fully_extend=not(vol_text) and not(perct_text) and ob_extend?
extend.right : extend.none
len_ext=not(vol_text) and not(perct_text)?length_extend_ob :
length_extend_ob/2
line.set_extend(get_line,fully_extend)
line.set_style(get_line,line_style_obs)
line.set_xy1(get_line,array.get(target_left, i),array.get(target_top,
i)-(array.get(target_top, i) - array.get(target_btm, i))/2)
line.set_xy2(get_line,time+((timediff)*(len_ext)),array.get(target_top,
i)-(array.get(target_top, i) - array.get(target_btm, i))/2)
if show_line_obs
line.set_color(get_line,color.gray)
if ob_extend
box.set_extend(get_box, extend.right)
color css = na
css := array.get(target_type, i) == 1 ? col_1 : col_2
box.set_border_color(get_box, css)
box.set_bgcolor(get_box, css)
box.set_border_color(get_box, css)
time_diff()=>((time[1]-time[101])/100)
//-----------------------------------------------------------------------------}
//Order Blocks Arrays
//-----------------------------------------------------------------------------{
bar_merge=barmerge.gaps_off
look_bars=barmerge.lookahead_on
[valid_ob,volume_,b_volume,s_volume,top_ob,btm_ob,left_ob,type_ob,_type]=request.se
curity(ticker.standard(syminfo.tickerid), i_tf_ob,
ob_found(x_up,bar_index,show_ob,show_iob), bar_merge,look_bars)
tf1_time=request.security(ticker.standard(syminfo.tickerid),i_tf_ob,time_diff(),
bar_merge,look_bars)
if array.size(ob_top)>4// or array.get(ob_left,array.size(ob_left)-1)>bar_index-400
array.pop(ob_top)
array.pop(ob_btm)
array.pop(ob_left)
array.pop(ob_type)
array.pop(ob_buy_vol)
array.pop(ob_sell_vol)
array.pop(ob_vol)
if array.size(ob_top)>1
for index=0 to array.size(ob_top)-1
src1= low
src2= high
up= array.get(ob_btm, index)
dn= array.get(ob_top, index)
// iob_size = array.size(iob_type)
ob_size = array.size(ob_type)
if barstate.islast
if true
for i = 0 to 4-1
array.push(ob_boxes, box.new(na,na,na,na, xloc = xloc.bar_time))
array.push(ob_boxes_buy, box.new(na,na,na,na, xloc = xloc.bar_time))
array.push(ob_boxes_sell, box.new(na,na,na,na, xloc = xloc.bar_time))
array.push(ob_volume, line.new(na,na,na,na,xloc =
xloc.bar_time,color=color.gray,style=line.style_solid,width = 1))
if ob_size > 1
[deleted_ob,del_index]=remove_ob(ob_top, ob_btm, ob_left, ob_type, 4, false,
ob_size)
if deleted_ob
array.remove(ob_top, del_index)
array.remove(ob_btm, del_index)
array.remove(ob_left, del_index)
array.remove(ob_type, del_index)
array.remove(ob_buy_vol, del_index)
array.remove(ob_sell_vol, del_index)
array.remove(ob_vol, del_index)
// iob_size := array.size(iob_type)
ob_size := array.size(ob_type)