Professional Documents
Culture Documents
bslssl
bslssl
//-----------------------------------------------------------------------------}
//General Calculations
//-----------------------------------------------------------------------------{
maxSize = 50
atr = ta.atr(10)
atr200 = ta.atr(200)
per type = mode == 'Present' ? last_bar_index - bar_index <= 500 : true
//-----------------------------------------------------------------------------}
//User Defined Types
//-----------------------------------------------------------------------------{
//-----------------------------------------------------------------------------{
// @type used to store pivot high/low data
//
// @field d (array<int>) The array where the trend direction is to be
maintained
// @field x (array<int>) The array where the bar index value of pivot high/low
is to be maintained
// @field y (array<float>) The array where the price value of pivot high/low is
to be maintained
type ZZ77
int [] d
int [] x
float [] y
type bar
float o = open
float h = high
float l = low
float c = close
int i = bar_index
type liq
box bx
box bxz
box bxt
bool brZ
bool brL
line ln
line lne
//-----------------------------------------------------------------------------}
//Variables
//-----------------------------------------------------------------------------{
var ZZ77 aZZ77 = ZZ77.new(
array.new <int> (maxSize, 0),
array.new <int> (maxSize, 0),
array.new <float>(maxSize, na)
)
var int dir = na, var int x177 = na, var float y177 = na, var int x277 = na, var
float y277 = na
//-----------------------------------------------------------------------------}
//Functions/methods
//-----------------------------------------------------------------------------{
// @function maintains arrays
// it prepends a `value` to the arrays and removes their oldest
element at last position
// @param aZZ77 (UDT<array<int>, array<int>, array<float>>) The UDT obejct of
arrays
// @param _d77 (array<int>) The array where the trend direction is
maintained
// @param _x77 (array<int>) The array where the bar index value of pivot
high/low is maintained
// @param _y77 (array<float>) The array where the price value of pivot
high/low is maintained
//
// @returns none
method in_out(ZZ77 aZZ77, int _d77, int _x77, float _y77) =>
aZZ77.d77.unshift(_d77), aZZ77.x77.unshift(_x77), aZZ77.y77.unshift(_y77),
aZZ77.d77.pop(), aZZ77.x77.pop(), aZZ77.y77.pop()
max_bars_back(time, 1000)
//-----------------------------------------------------------------------------}
//Calculations
//-----------------------------------------------------------------------------{
x277 := b77.i - 1
ph77 = ta.pivothigh(liqLen, 1)
pl77 = ta.pivotlow (liqLen, 1)
if ph77
dir := aZZ77.d77.get(0)
x177 := aZZ77.x77.get(0)
y177 := aZZ77.y77.get(0)
y277 := nz(b77.h[1])
if dir < 1
aZZ77.in_out(1, x277, y277)
else
if dir == 1 and ph77 > y177
aZZ77.x77.set(0, x277), aZZ77.y77.set(0, y277)
if per
count = 0
st_P = 0.
st_B = 0
minP = 0.
maxP = 10e6
for i = 0 to maxSize - 1
if aZZ77.d77.get(i) == 1
if aZZ77.y77.get(i) > ph77 + (atr / liqMar)
break
else
if aZZ77.y77.get(i) > ph77 - (atr / liqMar) and
aZZ77.y77.get(i) < ph77 + (atr / liqMar)
count += 1
st_B := aZZ77.x77.get(i)
st_P := aZZ77.y77.get(i)
if aZZ77.y77.get(i) > minP
minP := aZZ77.y77.get(i)
if aZZ77.y77.get(i) < maxP
maxP := aZZ77.y77.get(i)
if count > 2
getB = b_liq_B.get(0)
if st_B == getB.bx.get_left()
getB.bx.set_top(math.avg(minP, maxP) + (atr / liqMar))
getB.bx.set_rightbottom(b.i + 10, math.avg(minP, maxP) - (atr /
liqMar))
else
b_liq_B.unshift(
liq.new(
box.new(st_B, math.avg(minP, maxP) + (atr / liqMar), b77.i + 10,
math.avg(minP, maxP) - (atr / liqMar), bgcolor=color(na), border_color=color(na)),
box.new(na, na, na, na, bgcolor = color(na), border_color =
color(na)),
box.new(st_B, st_P, b77.i + 10, st_P, text = 'Buyside
liquidity', text_size = size.tiny, text_halign = text.align_left, text_valign
= .align_bottom, text_color = color.new(cLIQ_B, 25), bgcolor = color(na),
border_color = color(na)),
false,
false,
line.new(st_B , st_P, b77.i - 1, st_P, color =
color.new(cLIQ_B, 0)),
line.new(b77.i - 1, st_P, na , st_P, color =
color.new(cLIQ_B, 0), style = line.style_dotted))
)
if pl77
dir := aZZ77.d.get (0)
x177 := aZZ77.x77.get (0)
y177 := aZZ.y77.get (0)
y277 := nz(b.l[1])
if dir > -1
aZZ77.in_out(-1, x277, y277)
else
if dir == -1 and pl77 < y177
aZZ77.x77.set(0, x277), aZZ77.y77.set(0, y277)
if per
count = 0
st_P = 0.
st_B = 0
minP = 0.
maxP = 10e6
for i = 0 to maxSize - 1
if aZZ77.d.get(i) == -1
if aZZ77.y77.get(i) < pl77 - (atr / liqMar)
break
else
if aZZ77.y77.get(i) > pl77 - (atr / liqMar) and
aZZ77.y77.get(i) < pl77 + (atr / liqMar)
count += 1
st_B := aZZ77.x77.get(i)
st_P := aZZ77.y77.get(i)
if aZZ77.y77.get(i) > minP
minP := aZZ77.y77.get(i)
if aZZ77.y77.get(i) < maxP
maxP := aZZ77.y77.get(i)
if count > 2
getB = b_liq_S.get(0)
if st_B == getB.bx.get_left()
getB.bx.set_top(math.avg(minP, maxP) + (atr / liqMar))
getB.bx.set_rightbottom(b.i + 10, math.avg(minP, maxP) - (atr /
liqMar))
else
b_liq_S.unshift(
liq.new(
box.new(st_B, math.avg(minP, maxP) + (atr / liqMar), b77.i + 10,
math.avg(minP, maxP) - (atr / liqMar), bgcolor=color(na), border_color=color(na)),
box.new(na, na, na, na, bgcolor=color(na),
border_color=color(na)),
box.new(st_B, st_P, b77.i + 10, st_P, text = 'Sellside
liquidity', text_size = size.tiny, text_halign = text.align_left, text_valign =
text.align_top, text_color = color.new(cLIQ_S, 25), bgcolor=color(na),
border_color=color(na)),
false,
false,
line.new(st_B , st_P, b77.i - 1, st_P, color =
color.new(cLIQ_S, 0)),
line.new(b77.i - 1, st_P, na , st_P, color =
color.new(cLIQ_S, 0), style = line.style_dotted))
)
for i = 0 to b_liq_B.size() - 1
x77 = b_liq_B.get(i)
if not x77.brL
x77.lne.set_x277(b77.i)
else if x77.brZ
if b77.l > x77.ln.get_y177() - marBuy * (atr) and b77.h <
x77.ln.get_y177() + marBuy * (atr)
x77.bxz.set_right(b77.i + 1)
x77.bxz.set_top(math.max(b77.h, x77.bxz.get_top()))
if liqBuy
x77.lne.set_x277(b77.i + 1)
else
x77.brZ := false
for i = 0 to b_liq_S.size() - 1
x77 = b_liq_S.get(i)
if not x77.brL
x77.lne.set_x277(b77.i)
x77.bxz.set_lefttop(b77.i - 1, x77.ln.get_y177())
x77.bxz.set_rightbottom(b77.i + 1, math.max(x77.ln.get_y177() - marSel
* (atr), b77.l))
x77.bxz.set_bgcolor(color.new(cLIQ_S, liqSel ? 73 : 100))
else if x77.brZ
if b77.l > x77.ln.get_y177() - marSel * (atr) and b77.h <
x77.ln.get_y177() + marSel * (atr)
x77.bxz.set_rightbottom(b77.i + 1, math.min(b77.l,
x77.bxz.get_bottom()))
if liqSel
x77.lne.set_x277(b77.i + 1)
else
x77.brZ := false
if bull
l = 13
if bull[1]
st = math.abs(b77.l - b77.l[1]) / l
for i = 0 to l - 1
array.push(b_liq_V, box.new(b77.i - 2, b77.l[1] + i * st, b77.i,
b77.l[1] + (i + 1) * st, border_color = na, bgcolor = color.new(cLQV_B, 90) ))
else
st = math.abs(b.l - b.h[2]) / l
for i = 0 to l - 1
if lqText and i == 0
array.push(b_liq_V, box.new(b77.i - 2, b77.h[2] + i * st,
b77.i, b77.h[2] + (i + 1) * st, text = 'Liquidity Void ', text_size = size.tiny,
text_halign = text.align_right, text_valign = text.align_bottom, text_color = na,
border_color = na, bgcolor = color.new(cLQV_B, 90) ))
else
array.push(b_liq_V, box.new(b77.i - 2, b77.h[2] + i * st,
b77.i, b77.h[2] + (i + 1) * st, border_color = na, bgcolor = color.new(cLQV_B,
90) ))
if bear
l = 13
if bear[1]
st = math.abs(b77.h[1] - b77.h) / l
for i = 0 to l - 1
array.push(b_liq_V, box.new(b77.i - 2, b77.h + i * st, b77.i, b77.h
+ (i + 1) * st, border_color = na, bgcolor = color.new(cLQV_S, 90) ))
else
st = math.abs(b77.l[2] - b77.h) / l
for i = 0 to l - 1
if lqText and i == l - 1
array.push(b_liq_V, box.new(b77.i - 2, b77.h + i * st, b77.i,
b77.h + (i + 1) * st, text = 'Liquidity Void ', text_size = size.tiny,
text_halign = text.align_right, text_valign = text.align_top, text_color = na,
border_color = na, bgcolor = color.new(cLQV_S, 90) ))
else
array.push(b_liq_V, box.new(b77.i - 2, b77.h + i * st, b77.i,
b77.h + (i + 1) * st, border_color = na, bgcolor = color.new(cLQV_S, 90) ))
if b_liq_V.size() > 0
qt = b_liq_V.size()
for bn = qt - 1 to 0
if bn < b_liq_V.size()
cb = b_liq_V.get(bn)
ba = math.avg(cb.get_bottom(), cb.get_top())
//-----------------------------------------------------------------------------}