Professional Documents
Culture Documents
0 at
https://mozilla.org/MPL/2.0/
// © EzAlgo
//@version=5
indicator("EzSMC",overlay = true, max_bars_back = 5000, max_lines_count = 500,
max_boxes_count = 500, max_labels_count = 500)
//---------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------
//--------------------------------------------------------------- Input
Settings
//---------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------
//----------------------------------------}
//Order Blocks
//----------------------------------------{
v_buy = #00dbff4d
v_sell = #e91e634d
tf_s1=i_tf_ob_mtf==''?timeframe.period:i_tf_ob_mtf
timeframe_st=not(str.contains(tf_s1,'S')) and not(str.contains(tf_s1,'D')) and
not(str.contains(tf_s1,'W')) and not(str.contains(tf_s1,'M')) ?
str.tonumber(tf_s1)>=60? str.tostring(str.tonumber(tf_s1)/60) +"H": tf_s1 +"M" :
tf_s1
style = 'Colored'
v_lookback= 10
ob_loockback=10
timediff=(time[1]-time[101])/100
//----------------------------------------}
//BOS and MSS
//----------------------------------------{
// Constants
color CLEAR = color.rgb(0,0,0,100)
// Inputs
showms=input(true,title="Market Structure ",inline="0",group = "Market Structure")
bosColor1 = input.color(#787b86 , '', group="Market Structure",inline="0")
bosColor2 = input.color(#787b86 , '', group="Market Structure",inline="0")
ms_type =input.string("All", options=["All", "External","Internal"], title="",
group="Market Structure",inline="0")
show_equal_highlow = input(false, 'Equal Highs & Lows', group = 'Market
Structure',inline = 'equilibrium_zone')
eq_bear_color = input.color(#787b86 , '', group="Market
Structure",inline="equilibrium_zone")
eq_bull_color = input.color(#787b86 , '', group="Market
Structure",inline="equilibrium_zone")
eq_threshold = input.float(0.3, '', minval = 0, maxval = 0.5, step = 0.1, group =
'Market Structure',inline = 'equilibrium_zone')
showSwing = input.bool(false, 'Swing Points', group="Market Structure",inline="3")
swingSize_swing = input.int(10, "Swing Point Period",inline="4", group="Market
Structure")
label_sizes_s =input.string("Medium", options=["Small", "Medium","Large"],
title="Label Size",inline="4", group="Market Structure")
label_size_buysell_s = label_sizes_s == "Small" ? size.tiny : label_sizes_s ==
"Medium" ? size.small : label_sizes_s == "Large" ? size.normal : label_sizes_s ==
"Medium2" ? size.normal : label_sizes_s == "Large2" ? size.large : size.huge
label_size_buysell = label_sizes_s == "Small" ? size.tiny : label_sizes_s ==
"Medium" ? size.small : label_sizes_s == "Large" ? size.normal : label_sizes_s ==
"Medium2" ? size.normal : label_sizes_s == "Large2" ? size.large : size.huge
swingColor = input.color(#787b86 , '', group="Market Structure",inline="3")
swingSize = 3
length_eqh = 3
//----------------------------------------}
//Fair Value Gaps (FVG
//----------------------------------------{
show_fvg = input(true, 'Fair Value Gaps (FVG)', group = 'Fair Value Gaps', inline =
'fvg_css')
i_tf = input.timeframe("", "Timeframe", group = 'Fair Value Gaps',inline = 'tf')
max_width_fvg = input.float(1.5, 'Max Width', minval = 0, maxval = 5.0, step = 0.1,
group = 'Fair Value Gaps',inline = 'width')
remove_small = input.bool(true,"Filter FVG",group = 'Fair Value Gaps', inline =
"width")
mittigation_filt_fvg= input.string('Touch', 'Mitigation Method',options =
['Touch','Wicks','Close','Average'], group = 'Fair Value Gaps', inline = "mt")
fvg_color_fill = input.bool(true,"Fill",group = 'Fair Value Gaps', inline = "mt")
fvg_shade_fill = input.bool(false,"Shade",group = 'Fair Value Gaps', inline = "mt")
max_fvg = input.int(defval = 4,title = "Max FVG", minval = 0, maxval = 50 ,group =
'Fair Value Gaps', inline = "OS")
length_extend = input.int(defval = 20,title = "Length", minval = 0, maxval =
100 ,group = 'Fair Value Gaps', inline = "OS")
fvg_extend = input.bool(false,"Extend",group = 'Fair Value Gaps', inline = "OS")
i_mtfbearishfvgcolor = input.color(#2962ff , "", group = 'Fair Value Gaps', inline
= "fvg_css")
i_mtfbullishfvgcolor = input.color(#c2185b, "", group = 'Fair Value Gaps', inline =
"fvg_css")
mid_style = input.string('Solid', ' Style', ['Solid', 'Dashed', 'Dotted'],
group="Fair Value Gaps",inline="mid")
i_midPointColor = input.color(#787b86, "", group = 'Fair Value Gaps',inline="mid")
fvg_extend_B = input.bool(true,"Extend (Current)",group = 'Fair Value Gaps', inline
= "mid")
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
//----------------------------------------}
//Liquidity Levels
//----------------------------------------{
//----------------------------------------}
//Key Levels
//----------------------------------------{
var Show_4H_Levels = input.bool(defval=false, title='4H', group='Key Levels',
inline='4H')
Color_4H_Levels = input.color(title='', defval=color.orange, group='Key Levels',
inline='4H')
Style_4H_Levels = input.string('Dotted', ' Style', ['Solid', 'Dashed', 'Dotted'],
group="Key Levels",inline="4H")
Text_4H_Levels = input.bool(defval=false, title='Shorten', group='Key Levels',
inline='4H')
displayStyle = 'Standard'
distanceright = 25
radistance = 250
linesize = 'Small'
linestyle = 'Solid'
var untested_monday = false
//----------------------------------------}
//Session Levels
//----------------------------------------{
var is_londonrange_enabled = input.bool(defval=false, title='London',
group='Session Levels', inline='london')
var london_OC = input.bool(defval=true, title='O/C', group='Session Levels',
inline='london')
var london_HL = input.bool(defval=true, title='H/L', group='Session Levels',
inline='london')
var is_usrange_enabled = input.bool(defval=false, title='New York', group='Session
Levels', inline='US')
var us_OC = input.bool(defval=true, title='O/C', group='Session Levels',
inline='US')
var us_HL = input.bool(defval=true, title='H/L', group='Session Levels',
inline='US')
var is_tokyorange_enabled = input.bool(defval=false, title='Tokyo', group='Session
Levels', inline='asia')
var asia_OC = input.bool(defval=true, title='O/C', group='Session Levels',
inline='asia')
var asia_HL = input.bool(defval=true, title='H/L', group='Session Levels',
inline='asia')
SessionTextType = false//input.bool(defval=false, title='ShortHand',
group='Sessions', inline='FXColor')
Londont = "0800-1600"
USt = "1400-2100"
Asiat = "0000-0900"
//-----------------------------------------------------------------------------}
//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]
//---------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------
//--------------------------------------------------------------- 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, swingSize_swing, swingSize_swing)
pivot_low_found = ta.pivotlow(low, swingSize_swing, swingSize_swing)
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 - swingSize_swing
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 - swingSize_swing
//---------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------
//--------------------------------------------------------------- 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)*length_extend,_lowerlimit,border_color=fvg_color_fill? bg_color :
na,bgcolor = fvg_color_fill? bg_color : na, extend = fvg_extend ?
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)*length_extend,_lowerlimit,border_color=fvg_color_fill? bg_color :
na ,bgcolor = fvg_color_fill? bg_color : na, extend = fvg_extend ?
extend.right:extend.none,xloc = xloc.bar_time))
array.push(_midholder,line.new(_bar,(_lowerlimit+_upperlimit)/2.0,_bar+
(timediff)*length_extend,_midlimit,color = i_midPointColor, extend = fvg_extend ?
extend.right:extend.none,style=lineStyle(mid_style),width=1,xloc = xloc.bar_time))
array.push(_lowholder,line.new(_bar,_lowerlimit,_bar+
(timediff)*length_extend,_lowerlimit,color = i_fillByMid?boxbgcolor:na, extend =
fvg_extend ? extend.right:extend.none,width=1,xloc = xloc.bar_time))
array.push(_highholder,line.new(_bar,_upperlimit,_bar+
(timediff)*length_extend,_upperlimit,color = i_fillByMid?boxbgcolor:na, extend =
fvg_extend ? 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(max_width_fvg, 0.1) / 100.
if _open > _close // red
if _lowp2>_high
if not(remove_small) 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(remove_small) 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
if fvg_extend_B
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)*length_extend)
line.set_x2(chigh,timenow+(timediff)*length_extend)
line.set_x2(clow,timenow+(timediff)*length_extend)
box.set_right(currentgap_fill,timenow+(timediff)*length_extend)
box.set_right(currentgap,timenow+(timediff)*length_extend)
if mittigation_filt_fvg=='Touch'
currentgap_fill = array.get(bullishgapholder_fill,i)
currentgap = array.get(bullishgapholder,i)
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 mittigation_filt_fvg=='Wicks'
currentgap_fill = array.get(bullishgapholder_fill,i)
currentgap = array.get(bullishgapholder,i)
currentmid = array.get(bullishmidholder,i)
currenthigh = array.get(bullish_high_holder,i)
currentlow = array.get(bullish_low_holder,i)
currenttop = box.get_bottom(currentgap)
currentbottom = box.get_top(currentgap_fill)
delete_fvg_func(currentgap,currentgap_fill,i,bullishgapholder,bullishgapholder_fill
,bullishmidholder,bullish_high_holder,bullish_low_holder,bullishlabelholder)
if mittigation_filt_fvg=='Close'
currentgap_fill = array.get(bullishgapholder_fill,i)
currentgap = array.get(bullishgapholder,i)
currentmid = array.get(bullishmidholder,i)
currenthigh = array.get(bullish_high_holder,i)
currentlow = array.get(bullish_low_holder,i)
currenttop = box.get_bottom(currentgap)
currentbottom = box.get_top(currentgap_fill)
delete_fvg_func(currentgap,currentgap_fill,i,bullishgapholder,bullishgapholder_fill
,bullishmidholder,bullish_high_holder,bullish_low_holder,bullishlabelholder)
if mittigation_filt_fvg=='Average'
currentgap_fill = array.get(bullishgapholder_fill,i)
currentgap = array.get(bullishgapholder,i)
currentmid = array.get(bullishmidholder,i)
currenthigh = array.get(bullish_high_holder,i)
currentlow = array.get(bullish_low_holder,i)
currenttop = line.get_y1(currentmid)
currentbottom = box.get_top(currentgap_fill)
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
if fvg_extend_B
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)*length_extend)
line.set_x2(chigh,timenow+(timediff)*length_extend)
line.set_x2(clow,timenow+(timediff)*length_extend)
box.set_right(currentgap_fill,timenow+(timediff)*length_extend)
box.set_right(currentgap,timenow+(timediff)*length_extend)
if mittigation_filt_fvg=='Touch'
currentgap_fill = array.get(bearishgapholder_fill,i)
currentgap = array.get(bearishgapholder,i)
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)
if mittigation_filt_fvg=='Wicks'
currentgap_fill = array.get(bearishgapholder_fill,i)
currentgap = array.get(bearishgapholder,i)
currenttop = box.get_bottom(currentgap)
currentmid = array.get(bearishmidholder,i)
currenthigh = array.get(bearish_high_holder,i)
currentlow = array.get(bearish_low_holder,i)
currentbottom = box.get_top(currentgap_fill)
delete_fvg_func(currentgap,currentgap_fill,i,bearishgapholder,bearishgapholder_fill
,bearishmidholder,bearish_high_holder,bearish_low_holder,bearishlabelholder)
if mittigation_filt_fvg=='Close'
currentgap_fill = array.get(bearishgapholder_fill,i)
currentgap = array.get(bearishgapholder,i)
currenttop = box.get_bottom(currentgap)
currentmid = array.get(bearishmidholder,i)
currenthigh = array.get(bearish_high_holder,i)
currentlow = array.get(bearish_low_holder,i)
currentbottom = box.get_top(currentgap_fill)
delete_fvg_func(currentgap,currentgap_fill,i,bearishgapholder,bearishgapholder_fill
,bearishmidholder,bearish_high_holder,bearish_low_holder,bearishlabelholder)
if mittigation_filt_fvg=='Average'
currentgap_fill = array.get(bearishgapholder_fill,i)
currentgap = array.get(bearishgapholder,i)
currentmid = array.get(bearishmidholder,i)
currenttop = line.get_y1(currentmid)
currenthigh = array.get(bearish_high_holder,i)
currentlow = array.get(bearish_low_holder,i)
currentbottom = box.get_top(currentgap_fill)
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)
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) > displayLimit/2
a = array.shift(_array)
line.delete(a)
display_limit_box(_array) =>
if array.size(_array) > displayLimit/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)*length_extend_liq)
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)*length_extend_liq)
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, leftBars*tf_multi(htfTF),
leftBars+tf_multi(htfTF))
pivotLowHTF = ta.pivotlow(_low, leftBars*tf_multi(htfTF), leftBars+tf_multi(htfTF))
if currentTF
timeExt = time+((time[1]-time[2])*10)
dis = leftBars+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, extend=extentionMax?
extend.right:extend.none, 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, extend=extentionMax?extend.right:extend.none, border_width =
lineWidthHTF,text="BUY SIDE $$$",text_halign = text.align_center,text_color =
liquidity_text_color,text_size = size.small))
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, extend=extentionMax?
extend.right:extend.none, 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, extend=extentionMax?extend.right:extend.none, border_width =
lineWidthHTF,text="SELL SIDE $$$",text_halign = text.align_center,text_color =
liquidity_text_color,text_size = size.small))
// ----------------------------------------------------
// 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")
//---------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------
//--------------------------------------------------------------- Key Levels
//---------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------
var monday_time = time
var monday_high = high
var monday_low = low
cdailyh_open = request.security(syminfo.tickerid, 'D', high,
lookahead=barmerge.lookahead_on)
cdailyl_open = request.security(syminfo.tickerid, 'D', low,
lookahead=barmerge.lookahead_on)
[daily_time, daily_open] = request.security(syminfo.tickerid, 'D', [time, open],
lookahead=barmerge.lookahead_on)
[dailyh_time, dailyh_open] = request.security(syminfo.tickerid, 'D', [time[1],
high[1]], lookahead=barmerge.lookahead_on)
[dailyl_time, dailyl_open] = request.security(syminfo.tickerid, 'D', [time[1],
low[1]], lookahead=barmerge.lookahead_on)
[weekly_time, weekly_open] = request.security(syminfo.tickerid, 'W', [time, open],
lookahead=barmerge.lookahead_on)
[weeklyh_time, weeklyh_open] = request.security(syminfo.tickerid, 'W', [time[1],
high[1]], lookahead=barmerge.lookahead_on)
[weeklyl_time, weeklyl_open] = request.security(syminfo.tickerid, 'W', [time[1],
low[1]], lookahead=barmerge.lookahead_on)
[monthly_time, monthly_open] = request.security(syminfo.tickerid, 'M', [time,
open], lookahead=barmerge.lookahead_on)
[monthlyh_time, monthlyh_open] = request.security(syminfo.tickerid, 'M', [time[1],
high[1]], lookahead=barmerge.lookahead_on)
[monthlyl_time, monthlyl_open] = request.security(syminfo.tickerid, 'M', [time[1],
low[1]], lookahead=barmerge.lookahead_on)
[intra_time, intra_open] = request.security(syminfo.tickerid, '240', [time, open],
lookahead=barmerge.lookahead_on)
[intrah_time, intrah_open] = request.security(syminfo.tickerid, '240', [time[1],
high[1]], lookahead=barmerge.lookahead_on)
[intral_time, intral_open] = request.security(syminfo.tickerid, '240', [time[1],
low[1]], lookahead=barmerge.lookahead_on)
[quarterly_time, quarterly_open] = request.security(syminfo.tickerid, '3M', [time,
open], lookahead=barmerge.lookahead_on)
[quarterlyh_time, quarterlyh_open] = request.security(syminfo.tickerid, '3M',
[time[1], high[1]], lookahead=barmerge.lookahead_on)
[quarterlyl_time, quarterlyl_open] = request.security(syminfo.tickerid, '3M',
[time[1], low[1]], lookahead=barmerge.lookahead_on)
[yearly_time, yearly_open] = request.security(syminfo.tickerid, '12M', [time,
open], lookahead=barmerge.lookahead_on)
[yearlyh_time, yearlyh_open] = request.security(syminfo.tickerid, '12M', [time,
high], lookahead=barmerge.lookahead_on)
[yearlyl_time, yearlyl_open] = request.security(syminfo.tickerid, '12M', [time,
low], lookahead=barmerge.lookahead_on)
if weekly_time != weekly_time[1]
untested_monday := false
untested_monday
if Show_Monday_Levels == true and untested_monday == false
untested_monday := true
monday_time := daily_time
monday_high := cdailyh_open
monday_low := cdailyl_open
monday_low
linewidthint = 1
if linesize == 'Small'
linewidthint := 1
linewidthint
if linesize == 'Medium'
linewidthint := 2
linewidthint
if linesize == 'Large'
linewidthint := 3
linewidthint
var linewidth_def = linewidthint
fontsize = size.small
if labelsize == 'Small'
fontsize := size.small
fontsize
if labelsize == 'Medium'
fontsize := size.normal
fontsize
if labelsize == 'Large'
fontsize := size.large
fontsize
linestyles = line.style_solid
if linestyle == 'Dashed'
linestyles := line.style_dashed
linestyles
if linestyle == 'Dotted'
linestyles := line.style_dotted
linestyles
var DEFAULT_LABEL_SIZE = fontsize
var DEFAULT_LABEL_STYLE = label.style_none
var Rigth_Def = distanceright
var arr_price = array.new_float(0)
var arr_label = array.new_label(0)
Combine_Levels(arr_price, arr_label, currentprice, currentlabel, currentcolor) =>
if array.includes(arr_price, currentprice)
whichindex = array.indexof(arr_price, currentprice)
labelhold = array.get(arr_label, whichindex)
whichtext = label.get_text(labelhold)
label.set_text(labelhold, label.get_text(currentlabel) + ' / ' + whichtext)
label.set_text(currentlabel, '')
label.set_textcolor(labelhold, currentcolor)
else
array.push(arr_price, currentprice)
array.push(arr_label, currentlabel)
extend_to_current(bars) =>
timenow + (time - time[1]) * bars
if barstate.islast
arr_price := array.new_float(0)
arr_label := array.new_label(0)
if Show_4H_Levels
limit_4H_right = extend_to_current(Rigth_Def)
intrah_limit_right = extend_to_current(Rigth_Def)
intral_limit_right = extend_to_current(Rigth_Def)
var line_4H = line.new(x1=intra_time, x2=limit_4H_right, y1=intra_open,
y2=intra_open, color=Color_4H_Levels, width=linewidth_def, xloc=xloc.bar_time,
style=lineStyle(Style_4H_Levels))
var label_4H = label.new(x=limit_4H_right, y=intra_open, text=iotext,
style=DEFAULT_LABEL_STYLE, textcolor=Color_4H_Levels, size=DEFAULT_LABEL_SIZE,
xloc=xloc.bar_time)
var intrah_line = line.new(x1=intrah_time, x2=intrah_limit_right,
y1=intrah_open, y2=intrah_open, color=Color_4H_Levels, width=linewidth_def,
xloc=xloc.bar_time, style=lineStyle(Style_4H_Levels))
var intrah_label = label.new(x=intrah_limit_right, y=intrah_open,
text=pihtext, style=DEFAULT_LABEL_STYLE, textcolor=Color_4H_Levels,
size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
var intral_line = line.new(x1=intral_time, x2=intral_limit_right,
y1=intral_open, y2=intral_open, color=Color_4H_Levels, width=linewidth_def,
xloc=xloc.bar_time, style=lineStyle(Style_4H_Levels))
var intral_label = label.new(x=intral_limit_right, y=intral_open,
text=piltext, style=DEFAULT_LABEL_STYLE, textcolor=Color_4H_Levels,
size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
label.set_text(label_4H, iotext)
line.set_xy1(line_4H,intra_time,intra_open)
line.set_xy2(line_4H,limit_4H_right,intra_open)
label.set_xy(label_4H,limit_4H_right,intra_open)
line.set_xy1(intrah_line,intrah_time,intrah_open)
line.set_xy2(intrah_line,intrah_limit_right,intrah_open)
label.set_xy(intrah_label,intrah_limit_right,intrah_open)
label.set_text(intrah_label, pihtext)
line.set_x1(intral_line, intral_time)
line.set_x2(intral_line, intral_limit_right)
line.set_y1(intral_line, intral_open)
line.set_y2(intral_line, intral_open)
label.set_x(intral_label, intral_limit_right)
label.set_y(intral_label, intral_open)
label.set_text(intral_label, piltext)
Combine_Levels(arr_price, arr_label, intra_open, label_4H, Color_4H_Levels)
Combine_Levels(arr_price, arr_label, intrah_open, intrah_label,
Color_4H_Levels)
Combine_Levels(arr_price, arr_label, intral_open, intral_label,
Color_4H_Levels)
if Show_Monday_Levels
monday_limit_right = extend_to_current(Rigth_Def)
mondaym_limit_right = extend_to_current(Rigth_Def)
mondaym_open = (monday_high + monday_low) / 2
var monday_line = line.new(x1=monday_time, x2=monday_limit_right,
y1=monday_high, y2=monday_high, color=Color_Monday_Levels, width=linewidth_def,
xloc=xloc.bar_time, style=lineStyle(Style_Monday_Levels))
var monday_label = label.new(x=monday_limit_right, y=monday_high,
text=pmonhtext, style=DEFAULT_LABEL_STYLE, textcolor=Color_Monday_Levels,
size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
var mondaym_line = line.new(x1=monday_time, x2=mondaym_limit_right,
y1=mondaym_open, y2=mondaym_open, color=Color_Monday_Levels, width=linewidth_def,
xloc=xloc.bar_time, style=lineStyle(Style_Monday_Levels))
var mondaym_label = label.new(x=mondaym_limit_right, y=mondaym_open,
text=pmonmtext, style=DEFAULT_LABEL_STYLE, textcolor=Color_Monday_Levels,
size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
var monday_low_line = line.new(x1=monday_time, x2=monday_limit_right,
y1=monday_low, y2=monday_low, color=Color_Monday_Levels, width=linewidth_def,
xloc=xloc.bar_time, style=lineStyle(Style_Monday_Levels))
var monday_low_label = label.new(x=monday_limit_right, y=monday_low,
text=pmonltext, style=DEFAULT_LABEL_STYLE, textcolor=Color_Monday_Levels,
size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
line.set_x1(monday_line, monday_time)
line.set_x2(monday_line, monday_limit_right)
line.set_y1(monday_line, monday_high)
line.set_y2(monday_line, monday_high)
label.set_x(monday_label, monday_limit_right)
label.set_y(monday_label, monday_high)
label.set_text(monday_label, pmonhtext)
line.set_x1(monday_low_line, monday_time)
line.set_x2(monday_low_line, monday_limit_right)
line.set_y1(monday_low_line, monday_low)
line.set_y2(monday_low_line, monday_low)
label.set_x(monday_low_label, monday_limit_right)
label.set_y(monday_low_label, monday_low)
label.set_text(monday_low_label, pmonltext)
line.set_x1(mondaym_line, monday_time)
line.set_x2(mondaym_line, mondaym_limit_right)
line.set_y1(mondaym_line, mondaym_open)
line.set_y2(mondaym_line, mondaym_open)
label.set_x(mondaym_label, mondaym_limit_right)
label.set_y(mondaym_label, mondaym_open)
label.set_text(mondaym_label, pmonmtext)
Combine_Levels(arr_price, arr_label, monday_high, monday_label,
Color_Monday_Levels)
Combine_Levels(arr_price, arr_label, monday_low, monday_low_label,
Color_Monday_Levels)
Combine_Levels(arr_price, arr_label, mondaym_open, mondaym_label,
Color_Monday_Levels)
if Show_Daily_Levels
daily_limit_right = extend_to_current(Rigth_Def)
dailyh_limit_right = extend_to_current(Rigth_Def)
dailyl_limit_right = extend_to_current(Rigth_Def)
var daily_line = line.new(x1=daily_time, x2=daily_limit_right,
y1=daily_open, y2=daily_open, color=Color_Daily_Levels, width=linewidth_def,
xloc=xloc.bar_time, style=lineStyle(Style_Daily_Levels))
var daily_label = label.new(x=daily_limit_right, y=daily_open, text=dotext,
style=DEFAULT_LABEL_STYLE, textcolor=Color_Daily_Levels, size=DEFAULT_LABEL_SIZE,
xloc=xloc.bar_time)
var dailyh_line = line.new(x1=dailyh_time, x2=dailyh_limit_right,
y1=dailyh_open, y2=dailyh_open, color=Color_Daily_Levels, width=linewidth_def,
xloc=xloc.bar_time, style=lineStyle(Style_Daily_Levels))
var dailyh_label = label.new(x=dailyh_limit_right, y=dailyh_open,
text=pdhtext, style=DEFAULT_LABEL_STYLE, textcolor=Color_Daily_Levels,
size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
var dailyl_line = line.new(x1=dailyl_time, x2=dailyl_limit_right,
y1=dailyl_open, y2=dailyl_open, color=Color_Daily_Levels, width=linewidth_def,
xloc=xloc.bar_time, style=lineStyle(Style_Daily_Levels))
var dailyl_label = label.new(x=dailyl_limit_right, y=dailyl_open,
text=pdltext, style=DEFAULT_LABEL_STYLE, textcolor=Color_Daily_Levels,
size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
line.set_x1(daily_line, daily_time)
line.set_x2(daily_line, daily_limit_right)
line.set_y1(daily_line, daily_open)
line.set_y2(daily_line, daily_open)
label.set_x(daily_label, daily_limit_right)
label.set_y(daily_label, daily_open)
label.set_text(daily_label, dotext)
line.set_x1(dailyh_line, dailyh_time)
line.set_x2(dailyh_line, dailyh_limit_right)
line.set_y1(dailyh_line, dailyh_open)
line.set_y2(dailyh_line, dailyh_open)
label.set_x(dailyh_label, dailyh_limit_right)
label.set_y(dailyh_label, dailyh_open)
label.set_text(dailyh_label, pdhtext)
line.set_x1(dailyl_line, dailyl_time)
line.set_x2(dailyl_line, dailyl_limit_right)
line.set_y1(dailyl_line, dailyl_open)
line.set_y2(dailyl_line, dailyl_open)
label.set_x(dailyl_label, dailyl_limit_right)
label.set_y(dailyl_label, dailyl_open)
label.set_text(dailyl_label, pdltext)
Combine_Levels(arr_price, arr_label, daily_open, daily_label,
Color_Daily_Levels)
Combine_Levels(arr_price, arr_label, dailyh_open, dailyh_label,
Color_Daily_Levels)
Combine_Levels(arr_price, arr_label, dailyl_open, dailyl_label,
Color_Daily_Levels)
if Show_Weekly_Levels
weekly_limit_right = extend_to_current(Rigth_Def)
weeklyh_limit_right = extend_to_current(Rigth_Def)
weeklyl_limit_right = extend_to_current(Rigth_Def)
cweekly_time = weekly_time
var weekly_line = line.new(x1=cweekly_time, x2=weekly_limit_right,
y1=weekly_open, y2=weekly_open, color=WeeklyColor, width=linewidth_def,
xloc=xloc.bar_time, style=lineStyle(Weekly_style))
var weekly_label = label.new(x=weekly_limit_right, y=weekly_open,
text=wotext, style=DEFAULT_LABEL_STYLE, textcolor=WeeklyColor,
size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
var weeklyh_line = line.new(x1=weeklyh_time, x2=weeklyh_limit_right,
y1=weeklyh_open, y2=weeklyh_open, color=WeeklyColor, width=linewidth_def,
xloc=xloc.bar_time, style=lineStyle(Weekly_style))
var weeklyh_label = label.new(x=weeklyh_limit_right, y=weeklyh_open,
text=pwhtext, style=DEFAULT_LABEL_STYLE, textcolor=WeeklyColor,
size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
var weeklyl_line = line.new(x1=weeklyl_time, x2=weeklyl_limit_right,
y1=weekly_open, y2=weekly_open, color=WeeklyColor, width=linewidth_def,
xloc=xloc.bar_time, style=lineStyle(Weekly_style))
var weeklyl_label = label.new(x=weeklyl_limit_right, y=weeklyl_open,
text=pwltext, style=DEFAULT_LABEL_STYLE, textcolor=WeeklyColor,
size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
line.set_x1(weekly_line, cweekly_time)
line.set_x2(weekly_line, weekly_limit_right)
line.set_y1(weekly_line, weekly_open)
line.set_y2(weekly_line, weekly_open)
label.set_x(weekly_label, weekly_limit_right)
label.set_y(weekly_label, weekly_open)
label.set_text(weekly_label, wotext)
line.set_x1(weeklyh_line, weeklyh_time)
line.set_x2(weeklyh_line, weeklyh_limit_right)
line.set_y1(weeklyh_line, weeklyh_open)
line.set_y2(weeklyh_line, weeklyh_open)
label.set_x(weeklyh_label, weeklyh_limit_right)
label.set_y(weeklyh_label, weeklyh_open)
label.set_text(weeklyh_label, pwhtext)
line.set_x1(weeklyl_line, weeklyl_time)
line.set_x2(weeklyl_line, weeklyl_limit_right)
line.set_y1(weeklyl_line, weeklyl_open)
line.set_y2(weeklyl_line, weeklyl_open)
label.set_x(weeklyl_label, weeklyl_limit_right)
label.set_y(weeklyl_label, weeklyl_open)
label.set_text(weeklyl_label, pwltext)
Combine_Levels(arr_price, arr_label, weekly_open, weekly_label,
WeeklyColor)
Combine_Levels(arr_price, arr_label, weeklyh_open, weeklyh_label,
WeeklyColor)
Combine_Levels(arr_price, arr_label, weeklyl_open, weeklyl_label,
WeeklyColor)
if Show_Yearly_Levels
yearlyl_limit_right = extend_to_current(Rigth_Def)
yearlyh_limit_right = extend_to_current(Rigth_Def)
yearly_limit_right = extend_to_current(Rigth_Def)
var yearlyl_line = line.new(x1=yearlyl_time, x2=yearlyl_limit_right,
y1=yearlyl_open, y2=yearlyl_open, color=YearlyColor, width=linewidth_def,
xloc=xloc.bar_time, style=lineStyle(Yearly_style))
var yearlyl_label = label.new(x=yearlyl_limit_right, y=yearlyl_open,
text=cyltext, style=DEFAULT_LABEL_STYLE, textcolor=YearlyColor,
size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
var yearlyh_line = line.new(x1=yearlyh_time, x2=yearlyh_limit_right,
y1=yearlyh_open, y2=yearlyh_open, color=YearlyColor, width=linewidth_def,
xloc=xloc.bar_time, style=lineStyle(Yearly_style))
var yearlyh_label = label.new(x=yearlyh_limit_right, y=yearlyh_open,
text=cyhtext, style=DEFAULT_LABEL_STYLE, textcolor=YearlyColor,
size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
var yearly_line = line.new(x1=yearly_time, x2=yearly_limit_right,
y1=yearly_open, y2=yearly_open, color=YearlyColor, width=linewidth_def,
xloc=xloc.bar_time, style=lineStyle(Yearly_style))
var yearly_label = label.new(x=yearly_limit_right, y=yearly_open,
text=yotext, style=DEFAULT_LABEL_STYLE, textcolor=YearlyColor,
size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
line.set_x1(yearlyl_line, yearlyl_time)
line.set_x2(yearlyl_line, yearlyl_limit_right)
line.set_y1(yearlyl_line, yearlyl_open)
line.set_y2(yearlyl_line, yearlyl_open)
label.set_x(yearlyl_label, yearlyl_limit_right)
label.set_y(yearlyl_label, yearlyl_open)
label.set_text(yearlyl_label, cyltext)
line.set_x1(yearlyh_line, yearlyh_time)
line.set_x2(yearlyh_line, yearlyh_limit_right)
line.set_y1(yearlyh_line, yearlyh_open)
line.set_y2(yearlyh_line, yearlyh_open)
label.set_x(yearlyh_label, yearlyh_limit_right)
label.set_y(yearlyh_label, yearlyh_open)
label.set_text(yearlyh_label, cyhtext)
line.set_x1(yearly_line, yearly_time)
line.set_x2(yearly_line, yearly_limit_right)
line.set_y1(yearly_line, yearly_open)
line.set_y2(yearly_line, yearly_open)
label.set_x(yearly_label, yearly_limit_right)
label.set_y(yearly_label, yearly_open)
label.set_text(yearly_label, yotext)
Combine_Levels(arr_price, arr_label, yearlyh_open, yearlyh_label,
YearlyColor)
Combine_Levels(arr_price, arr_label, yearlyl_open, yearlyl_label,
YearlyColor)
Combine_Levels(arr_price, arr_label, yearly_open, yearly_label,
YearlyColor)
if Show_Quaterly_Levels
quarterly_limit_right = extend_to_current(Rigth_Def)
quarterlyh_limit_right = extend_to_current(Rigth_Def)
quarterlyl_limit_right = extend_to_current(Rigth_Def)
var quarterly_line = line.new(x1=quarterly_time, x2=quarterly_limit_right,
y1=quarterly_open, y2=quarterly_open, color=quarterlyColor, width=linewidth_def,
xloc=xloc.bar_time, style=lineStyle(Quaterly_style))
var quarterly_label = label.new(x=quarterly_limit_right, y=quarterly_open,
text=qotext, style=DEFAULT_LABEL_STYLE, textcolor=quarterlyColor,
size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
var quarterlyh_line = line.new(x1=quarterlyh_time,
x2=quarterlyh_limit_right, y1=quarterlyh_open, y2=quarterlyh_open,
color=quarterlyColor, width=linewidth_def, xloc=xloc.bar_time,
style=lineStyle(Quaterly_style))
var quarterlyh_label = label.new(x=quarterlyh_limit_right,
y=quarterlyh_open, text=pqhtext, style=DEFAULT_LABEL_STYLE,
textcolor=quarterlyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
var quarterlyl_line = line.new(x1=quarterlyl_time,
x2=quarterlyl_limit_right, y1=quarterlyl_open, y2=quarterlyl_open,
color=quarterlyColor, width=linewidth_def, xloc=xloc.bar_time,
style=lineStyle(Quaterly_style))
var quarterlyl_label = label.new(x=quarterlyl_limit_right,
y=quarterlyl_open, text=pqltext, style=DEFAULT_LABEL_STYLE,
textcolor=quarterlyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
line.set_x1(quarterly_line, quarterly_time)
line.set_x2(quarterly_line, quarterly_limit_right)
line.set_y1(quarterly_line, quarterly_open)
line.set_y2(quarterly_line, quarterly_open)
label.set_x(quarterly_label, quarterly_limit_right)
label.set_y(quarterly_label, quarterly_open)
label.set_text(quarterly_label, qotext)
line.set_x1(quarterlyh_line, quarterlyh_time)
line.set_x2(quarterlyh_line, quarterlyh_limit_right)
line.set_y1(quarterlyh_line, quarterlyh_open)
line.set_y2(quarterlyh_line, quarterlyh_open)
label.set_x(quarterlyh_label, quarterlyh_limit_right)
label.set_y(quarterlyh_label, quarterlyh_open)
label.set_text(quarterlyh_label, pqhtext)
line.set_x1(quarterlyl_line, quarterlyl_time)
line.set_x2(quarterlyl_line, quarterlyl_limit_right)
line.set_y1(quarterlyl_line, quarterlyl_open)
line.set_y2(quarterlyl_line, quarterlyl_open)
label.set_x(quarterlyl_label, quarterlyl_limit_right)
label.set_y(quarterlyl_label, quarterlyl_open)
label.set_text(quarterlyl_label, pqltext)
Combine_Levels(arr_price, arr_label, quarterlyl_open, quarterlyl_label,
quarterlyColor)
Combine_Levels(arr_price, arr_label, quarterly_open, quarterly_label,
quarterlyColor)
Combine_Levels(arr_price, arr_label, quarterlyh_open, quarterlyh_label,
quarterlyColor)
if Show_Monthly_Levels
monthly_limit_right = extend_to_current(Rigth_Def)
var monthlyLine = line.new(x1=monthly_time, x2=monthly_limit_right,
y1=monthly_open, y2=monthly_open, color=MonthlyColor, width=linewidth_def,
xloc=xloc.bar_time, style=lineStyle(Monthly_style))
var monthlyLabel = label.new(x=monthly_limit_right, y=monthly_open,
text=motext, style=DEFAULT_LABEL_STYLE, textcolor=MonthlyColor,
size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
line.set_x1(monthlyLine, monthly_time)
line.set_x2(monthlyLine, monthly_limit_right)
line.set_y1(monthlyLine, monthly_open)
line.set_y2(monthlyLine, monthly_open)
label.set_x(monthlyLabel, monthly_limit_right)
label.set_y(monthlyLabel, monthly_open)
label.set_text(monthlyLabel, motext)
Combine_Levels(arr_price, arr_label, monthly_open, monthlyLabel,
MonthlyColor)
//---------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------
//--------------------------------------------------------------- Sessions
//---------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------
atr = ta.atr(200)
cmean_range = ta.cum(high - low) / n
clondonhigh := 0.0
clondonlow := close
clondonlow
//////////////////////////////////
var cushigh = 0.0
var cuslow = close
var ustime = time
var fushigh = 0.0
var fuslow = 0.0
var fusopen = 0.0
cushigh := 0.0
cuslow := close
cuslow
//////////////////////////////////
var casiahigh = 0.0
var casialow = close
var asiatime = time
var fasiahigh = 0.0
var fasialow = 0.0
var fasiaopen = 0.0
casiahigh := 0.0
casialow := close
casialow
if show_equal_highlow
high_eqh = ta.pivothigh(length_eqh, length_eqh)
low_eqh = ta.pivotlow(length_eqh, length_eqh)
if low_eqh
if math.min(low_eqh, low_eqh_pre) > math.max(low_eqh, low_eqh_pre) - atr *
eq_threshold
eql_line = line.new(eq_btm_x, low_eqh_pre, n-length_eqh, low_eqh, color
= eq_bull_color, style = line.style_dotted)
eql_lbl = label.new(int(math.avg(n-length_eqh, eq_btm_x)), low_eqh,
'EQL', color = #00000000, textcolor = eq_bull_color, style = label.style_label_up,
size = label_size_buysell)
low_eqh_pre := low_eqh
eq_btm_x := n-length_eqh
if high_eqh
if math.max(high_eqh, high_eqh_pre) < math.min(high_eqh, high_eqh_pre) +
atr * eq_threshold
eqh_line = line.new(eq_top_x, high_eqh_pre, n-length_eqh, high_eqh,
color = eq_bear_color, style = line.style_dotted)
eqh_lbl = label.new(int(math.avg(n-length_eqh, eq_top_x)), high_eqh,
'EQH', color = #00000000, textcolor = eq_bear_color, style =
label.style_label_down, size = label_size_buysell)
high_eqh_pre := high_eqh
eq_top_x := n-length_eqh
swing_bull_css = bosColor1
swing_bear_css = bosColor2
var bullish_col_MSS = swing_bull_css
var bearish_col_MSS = swing_bear_css
var internal_bullish_col_MSS = bosColor1
var internal_bearish_col_MSS = 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=label_size_buysell
[int_high_ms, int_low_ms] = calculate_swing_points(swingSize)
swing_structure_lbl_size=label_size_buysell
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_mss=false,bull_mss_=false,bull_bos=false,bull_bos_=false,bear_mss=false,bear_m
ss_=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 MSS = na
MSS := int_t_MS < 0
internal_up_broke := false
int_t_MS := 1
bull_mss:=MSS?true:false
bull_bos:=MSS?false:true
if showms and (ms_type=='All' or ms_type=='Internal')
Show_MS(internal_x_up, internal_y_up, MSS ? 'MSS' : 'BOS',
internal_bullish_col_MSS, true, true, internal_structure_lbl_size)
if ta.crossunder(close, internal_y_dn) and internal_dn_broke and y_dn !=
internal_y_dn
bool MSS = false
MSS := int_t_MS > 0
internal_dn_broke := false
int_t_MS := -1
bear_mss:=MSS?true:false
bear_bos:=MSS?false:true
if showms and (ms_type=='All' or ms_type=='Internal')
Show_MS(internal_x_dn, internal_y_dn, MSS ? 'MSS' : 'BOS',
internal_bearish_col_MSS, true, false, internal_structure_lbl_size)
//-----------------------------------------------------------------------------}
//Order Blocks
//-----------------------------------------------------------------------------{
first_nonzero_digit(n) =>
s = str.tostring(n)
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.
if valid
ind=0
thold_ = (ta.highest(300) - ta.lowest(300)) * (max_width_ob/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)
// if ta.pivothigh(high,3,1)
// array.unshift(iob_h_top,high[1])
// array.unshift(iob_h_left,time)
// if ta.pivotlow(low,3,1)
// array.unshift(iob_l_btm,low[1])
// array.unshift(iob_l_left,time)
// if array.size(iob_h_top)>3
// array.shift(iob_h_top)
// array.shift(iob_h_left)
// if array.size(iob_l_btm)>3
// array.shift(iob_l_btm)
// array.shift(iob_l_left)
// if array.size(iob_h_top)>0
// for i=0 to array.size(iob_h_top)-1
// x=array.get(iob_h_left,i)
// y=array.get(iob_h_top,i)
// if close>y
// label.new(int(math.avg(x, time)), y, 'BOS', color = color.gray,
textcolor = color.white,style= label.style_label_down, size = size.small,xloc
=xloc.bar_time )
// line.new(x, y, time, y, color = color.gray, style
=line.style_dashed,xloc = xloc.bar_time )
// array.remove(iob_h_top,i)
// array.remove(iob_h_left,i)
// break
//-----------------------------------------------------------------------------}
//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)
[valid_ob_mtf,volume__mtf,b_volume_mtf,s_volume_mtf,top_ob_mtf,btm_ob_mtf,left_ob_m
tf,type_ob_mtf,_type_mtf]=request.security(ticker.standard(syminfo.tickerid),
i_tf_ob_mtf, ob_found(x_up,bar_index,show_ob_mtf,show_iob_mtf),
bar_merge,look_bars)
tf1_time=request.security(ticker.standard(syminfo.tickerid),i_tf_ob,time_diff(),
bar_merge,look_bars)
tf2_time=request.security(ticker.standard(syminfo.tickerid),i_tf_ob_mtf,time_diff()
, bar_merge,look_bars)
if valid_ob and not(valid_ob[1]) and barstate.isconfirmed
array.unshift(ob_vol, volume_)
array.unshift(ob_buy_vol, b_volume)
array.unshift(ob_sell_vol, s_volume)
array.unshift(ob_top, top_ob)
array.unshift(ob_btm, btm_ob)
array.unshift(ob_left, left_ob)
array.unshift(ob_type, type_ob)
// if barstate.islast
// label.new(bar_index,high,str.tostring(array.size(ob_top)))
if array.size(ob_top_mtf)>max_obs_mtf// or
array.get(ob_left_mtf,array.size(ob_left_mtf)-1)>bar_index-400
array.pop(ob_top_mtf)
array.pop(ob_btm_mtf)
array.pop(ob_left_mtf)
array.pop(ob_type_mtf)
array.pop(ob_buy_vol_mtf)
array.pop(ob_sell_vol_mtf)
array.pop(ob_vol_mtf)
// if array.get(ob_left_mtf,array.size(ob_left_mtf)-1)>bar_index-400
// array.pop(ob_top_mtf)
// array.pop(ob_btm_mtf)
// array.pop(ob_left_mtf)
// array.pop(ob_type_mtf)
// array.pop(ob_buy_vol_mtf)
// array.pop(ob_sell_vol_mtf)
// array.pop(ob_vol_mtf)
if array.size(ob_top)>max_obs// 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=mittigation_filt=='Wicks' or mittigation_filt=='Touch'? low :
mittigation_filt=='Close'? close : low
src2=mittigation_filt=='Wicks' or mittigation_filt=='Touch'? high :
mittigation_filt=='Close'? close : high
up= mittigation_filt=='Touch' ? array.get(ob_top, index) :
mittigation_filt=='Average'? array.get(ob_top, index)-(array.get(ob_top, index) -
array.get(ob_btm, index))/2 : array.get(ob_btm, index)
dn= mittigation_filt=='Touch' ? array.get(ob_btm, index) :
mittigation_filt=='Average'? array.get(ob_top, index)-(array.get(ob_top, index) -
array.get(ob_btm, index))/2 : array.get(ob_top, index)
ob_size_mtf = array.size(ob_type_mtf)
// iob_size = array.size(iob_type)
ob_size = array.size(ob_type)
if barstate.islast
if true
for i = 0 to max_obs-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 true
for i = 0 to max_obs_mtf-1
array.push(ob_boxes_mtf, box.new(na,na,na,na, xloc = xloc.bar_time))
array.push(ob_boxes_buy_mtf, box.new(na,na,na,na, xloc =
xloc.bar_time))
array.push(ob_boxes_sell_mtf, box.new(na,na,na,na, xloc =
xloc.bar_time))
array.push(ob_volume_mtf, line.new(na,na,na,na,xloc =
xloc.bar_time,color=color.gray,style=line.style_solid,width = 1))
// array.push(ob_volume, line.new(na,na,na,na,xloc =
xloc.bar_index,color=color.yellow,style=line.style_dashed,width = 3))
// array.push(ob_volume_labels, label.new(na,na,xloc
=xloc.bar_index,color=color.yellow,size=size.small ))
ob_size_mtf := array.size(ob_type_mtf)
// iob_size := array.size(iob_type)
ob_size := array.size(ob_type)
//-----------------------------------------------------------------------------}