[BigBeluga] & CPR (1)
[BigBeluga] & CPR (1)
// Inputs
string cprgrp = "CPR :: Today/Previous Day HL :: Support/Resistance
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
showCPR = input(true, title='Show Daily CPR', group = cprgrp, inline = 'cpr')
showTodayDayHL = input(true, title = 'Show Today HL', group = cprgrp)
showPrevDayHL = input(true, title='Show Prev Day HL', group = cprgrp)
showSR = input(true, title='Show Support/Resistance', group = cprgrp)
// Pivot calculation
pivot = (high + low + close) / 3.0
bc = (high + low) / 2.0
tc = pivot - bc + pivot
R1 = 2 * pivot - low
S1 = 2 * pivot - high
R2 = pivot + high - low
S2 = pivot - (high - low)
R3 = high + 2 * (pivot - low)
S3 = low - 2 * (high - pivot)
R4 = R3 + R2 - R1
S4 = S3 + S2 - S1
PH = high
PL = low
_
='
------------
–––––––––––––––––––––––––– INPUTS
–––––––––––––––––––––––––––
------------
'//{
windowsis = input.bool(true, "Window ", inline
= "kla", group = "MARKET STRUCTURE")
mswindow = input.int(5000, "", tooltip = "Limit market structure calculation to
improve memory speed time", group = "MARKET STRUCTURE", inline = "kla", minval =
1000)
showSwing = input.bool ( true ,
"Swing ", inline = "scss", group = "MARKET
STRUCTURE")
swingLimit = input.int (100, "", tooltip = "[INPUT] Limit swing structure to
tot bars back", inline = "scss", group = "MARKET STRUCTURE", minval = 10, maxval =
200)
swingcssup = input.color (#089981, "", inline = "scss", group = "MARKET
STRUCTURE")
swingcssdn = input.color (#f23645, "", inline = "scss", group = "MARKET
STRUCTURE")
type alert
bool b = false // If condition has been met or not
string d = na // Bullish or Bearish direction
string n = na // Name of alert
if barstate.isfirst
for i in a
if i
b := true
break
//}
_
='
------------
–––––––––––––––––––––––––– UDT
–––––––––––––––––––––––––––
------------
'//{
type hqlzone
box pbx
box ebx
box lbx
label plb
label elb
label lbl
type Zphl
line top
line bottom
label top_label
label bottom_label
bool stopcross
bool sbottomcross
bool itopcross
bool ibottomcross
string txtup
string txtdn
float topy
float bottomy
float topx
float bottomx
float tup
float tdn
int tupx
int tdnx
float itopy
float itopx
float ibottomy
float ibottomx
float uV
float dV
type entered
bool normal = false
bool breaker = false
type store
line [] ln
label [] lb
box [] bx
linefill[] lf
type structure
int zn
float zz
float bos
float choch
int loc
int temp
int trend
int start
float main
int xloc
bool upsweep
bool dnsweep
string txt = na
type drawms
int x1
int x2
float y
string txt
color css
string style
type ob
bool bull
float top
float btm
float avg
int loc
color css
float vol
int dir
int move
int blPOS
int brPOS
int xlocbl
int xlocbr
bool isbb = false
int bbloc
type FVG
float top = na
float btm = na
int loc = bar_index
bool isbb = false
int bbloc = na
bool israid = false
float raidy = na
int raidloc = na
int raidx2 = na
bool active = false
color raidcs = na
type SFP
float y
int loc
float ancor
type sfpbuildlbl
int x
float y
string style
color css
string txt
type sfpbuildline
int x1
int x2
float y
color css
float ancor
int loc
type equalbuild
int x1
float y1
int x2
float y2
color css
string style
type equalname
int x
float y
string txt
color css
string style
type ehl
float pt
int t
float pb
int b
type sellbuyside
float top
float btm
int loc
color css
string txt
float vol
type timer
bool start = false
int count = 0
//}
_
='
------------
–––––––––––––––––––––––––– SETUP
–––––––––––––––––––––––––––
------------
'//{
var store bin = store.new(
array.new< line >()
, array.new< label >()
, array.new< box >()
, array.new<linefill>()
)
if barstate.islast
for obj in bin.ln
obj.delete()
for obj in bin.lb
obj.delete()
for obj in bin.bx
obj.delete()
for obj in bin.lf
obj.delete()
bin.ln.clear()
bin.lb.clear()
bin.bx.clear()
bin.lf.clear()
invcol = #ffffff00
hl () => [high, low]
min = 99999999.
max = 0.
idx = 0
if use_max
for i = 0 to (bar_index - loc)
max := math.max(high[i], max)
min := max == high[i] ? low[i] : min
idx := max == high[i] ? i : idx
else
for i = 0 to (bar_index - loc)
min := math.min(low[i], min)
max := min == low[i] ? high[i] : max
idx := min == low[i] ? i : idx
idx
indexHighTF = barstate.isrealtime ? 1 : 0
indexCurrTF = barstate.isrealtime ? 0 : 1
method find(structure ms, bool use_max, bool sweep, bool useob) =>
min = 99999999.
max = 0.
idx = 0
if not sweep
if ((bar_index - ms.loc) - 1) > 0
if use_max
for i = 0 to (bar_index - ms.loc) - 1
max := math.max(high[i], max)
min := max == high[i] ? low[i] : min
idx := max == high[i] ? i : idx
if useob
if high[idx + 1] > high[idx]
max := high[idx + 1]
min := low [idx + 1]
idx := idx + 1
else
for i = 0 to (bar_index - ms.loc) - 1
min := math.min(low[i], min)
max := min == low[i] ? high[i] : max
idx := min == low[i] ? i : idx
if useob
if low[idx + 1] < low[idx]
max := high[idx + 1]
min := low [idx + 1]
idx := idx + 1
else
if use_max
for i = 0 to (bar_index - ms.loc)
max := math.max(high[i], max)
min := max == high[i] ? low[i] : min
idx := max == high[i] ? i : idx
if useob
if high[idx + 1] > high[idx]
max := high[idx + 1]
min := low [idx + 1]
idx := idx + 1
else
for i = 0 to (bar_index - ms.loc)
min := math.min(low[i], min)
max := min == low[i] ? high[i] : max
idx := min == low[i] ? i : idx
if useob
if low[idx + 1] < low[idx]
max := high[idx + 1]
min := low [idx + 1]
idx := idx + 1
else
if ((bar_index - ms.xloc) - 1) > 0
if use_max
for i = 0 to (bar_index - ms.xloc) - 1
max := math.max(high[i], max)
min := max == high[i] ? low[i] : min
idx := max == high[i] ? i : idx
if useob
if high[idx + 1] > high[idx]
max := high[idx + 1]
min := low [idx + 1]
idx := idx + 1
else
for i = 0 to (bar_index - ms.xloc) - 1
min := math.min(low[i], min)
max := min == low[i] ? high[i] : max
idx := min == low[i] ? i : idx
if useob
if low[idx + 1] < low[idx]
max := high[idx + 1]
min := low [idx + 1]
idx := idx + 1
else
if use_max
for i = 0 to (bar_index - ms.xloc)
max := math.max(high[i], max)
min := max == high[i] ? low[i] : min
idx := max == high[i] ? i : idx
if useob
if high[idx + 1] > high[idx]
max := high[idx + 1]
min := low [idx + 1]
idx := idx + 1
else
for i = 0 to (bar_index - ms.xloc)
min := math.min(low[i], min)
max := min == low[i] ? high[i] : max
idx := min == low[i] ? i : idx
if useob
if low[idx + 1] < low[idx]
max := high[idx + 1]
min := low [idx + 1]
idx := idx + 1
idx
method fnOB(ob[] block, bool bull, float cords, int idx) =>
switch bull
true =>
blobenter.normal := false
blobenter.breaker := false
block.unshift(
ob.new(
true
, cords
, low [idx]
, math.avg(cords, low[idx])
, time [idx]
, obupcs
, volume[idx]
, close [idx] > open[idx] ? 1 : -1
, 1
, 1
, 1
, time [idx]
)
)
false =>
brobenter.normal := false
brobenter.breaker := false
block.unshift(
ob.new(
false
, high [idx]
, cords
, math.avg(cords, high[idx])
, time [idx]
, obdncs
, volume[idx]
, close [idx] > open[idx] ? 1 : -1
, 1
, 1
, 1
, time [idx]
)
)
false =>
if obmiti == "Close" ? math.max(close, open) > stuff.top :
obmiti == "Wick" ? high > stuff.top : obmiti == "Avg" ? high > stuff.avg : na
bralerts.set(4, alert.new(true, "Bearish", "OB
Mitigated\n"))
stuff.isbb := true
stuff.bbloc := time
if not obshowbb
block.remove(i)
else
switch stuff.bull
true =>
if obmiti == "Close" ? math.max(close, open) > stuff.top :
obmiti == "Wick" ? high > stuff.top : obmiti == "Avg" ? high > stuff.avg : na
block.remove(i)
false =>
if obmiti == "Close" ? math.min(close, open) < stuff.btm :
obmiti == "Wick" ? low < stuff.btm : obmiti == "Avg" ? low < stuff.avg : na
block.remove(i)
if bear.size() > 1
for i = bear.size() - 1 to 1
stuff = bear.get(i)
current = bear.get(0)
v = wichlap == "Recent" ? i : 0
switch
stuff.btm > current.btm and stuff.btm < current.top =>
bear.remove(v)
stuff.top < current.top and stuff.btm > current.btm =>
bear.remove(v)
stuff.top > current.top and stuff.btm < current.btm =>
bear.remove(v)
stuff.top < current.top and stuff.top > current.btm =>
bear.remove(v)
if brFVG.size() > 1
for i = brFVG.size() - 1 to 1
stuff = brFVG.get(i)
current = brFVG.get(0)
switch
stuff.btm > current.btm and stuff.btm < current.top =>
brFVG.remove(i)
stuff.top < current.top and stuff.btm > current.btm =>
brFVG.remove(i)
stuff.top > current.top and stuff.btm < current.btm =>
brFVG.remove(i)
stuff.top < current.top and stuff.top > current.btm =>
brFVG.remove(i)
-1 =>
switch metric.move
1 => metric.brPOS := metric.brPOS + 1, metric.move := 2
2 => metric.brPOS := metric.brPOS + 1, metric.move := 3
3 => metric.blPOS := metric.blPOS + 1, metric.move := 1
if obshowactivity
bin.bx.unshift(box.new (top = id.top, bottom = id.avg, left = id.loc ,
right = id.xlocbl, border_color = na , bgcolor = obactup, xloc =
xloc.bar_time))
bin.bx.unshift(box.new (top = id.avg, bottom = id.btm, left = id.loc ,
right = id.xlocbr, border_color = na , bgcolor = obactdn, xloc =
xloc.bar_time))
if showline
bin.ln.unshift(line.new(
x1 = id.loc
, x2 = time
, y1 = id.avg
, y2 = id.avg
, color = color.new(id.css, 0)
, xloc = xloc.bar_time
, style = line.style_dashed
)
)
if showmetric
if i == math.min(oblast - 1, full.size() - 1)
float tV = 0
float[] dV = array.new<float>()
seq = math.min(oblast - 1, full.size() - 1)
for j = 0 to seq
cV = full.get(j)
tV += cV.vol
if j == seq
for y = 0 to seq
dV.push(
math.floor(
(full.get(y).vol / tV) * 100)
)
ids = full.get(y)
bin.lb.unshift(label.new(
bar_index - 1
, ids.avg
, textcolor = color.new(ids.css, 0)
, style = label.style_label_left
, size = obtxt.txSz()
, color = #ffffff00
, text =
str.tostring(
math.round(full.get(y).vol, 3), format =
format.volume) + " (" + str.tostring(dV.get(y)) + "%)"
)
)
//}
_
='
------------
–––––––––––––––––––––––––– FUNCTION
–––––––––––––––––––––––––––
------------
'//{
mapping() =>
var float up = na
var float dn = na
var float point = na
var int trend = 0
var int idx = na
var int sum = na
var int project = na
var chart.point[] charts = array.new<chart.point>()
if na(up)
up := high
idx := bar_index
if na(dn)
dn := low
idx := bar_index
if high > up
if trend == -1
id = IDMIDX(false, idx)
charts.unshift(
chart.point.from_time(
time[id]
, low [id]
)
)
idx := bar_index
point := low [id]
sum := time[id]
up := high
dn := low
project := time
trend := 1
if low < dn
if trend == 1
id = IDMIDX(true, idx)
charts.unshift(
chart.point.from_time(
time[id]
, high[id]
)
)
idx := bar_index
point := high[id]
sum := time[id]
up := high
dn := low
project := time
trend := -1
if barstate.islast
var line ln = na
var polyline pl = na
ln.delete()
pl.delete()
ln := na
pl := na
ln := line.new(
x1 = sum
, x2 = project
, y1 = point
, y2 = trend == 1 ? up : dn
, xloc = xloc.bar_time
, color = color.red
)
pl := polyline.new(
charts
, line_color = mappingcss
, xloc = xloc.bar_time
, line_style = mappingStyle.lstyle()
)
posLIQ() =>
ph = ta.pivothigh(high, 5, 5)
pl = ta.pivotlow (low , 5, 5)
if ph
lUp.set(0, ph)
if pl
lDn.set(0, pl)
if high > lUp.get(0) and close < lUp.get(0) and upallow and high > high[1]
bralerts.set(10, alert.new(true, "Bearish", "Liquidity Print\n"))
upallow := false
printup := true
if low < lDn.get(0) and close > lDn.get(0) and dnallow and low < low[1]
blalerts.set(10, alert.new(true, "Bullish", "Liquidity Print\n"))
dnallow := false
printdn := true
if ph and upallow == false
upallow := true
[printup, printdn]
structure(color upcss, color dncss, bool draw, bool internal, int limit) =>
var structure ms = structure.new(start = 0)
var ob [] blob = array.new< ob >()
var ob [] brob = array.new< ob >()
var drawms [] bldw = array.new< drawms >()
var drawms [] brdw = array.new< drawms >()
var sellbuyside[] sellside = array.new<sellbuyside>()
var sellbuyside[] buyside = array.new<sellbuyside>()
bool crossup = false
bool crossdn = false
var float up = na
var float dn = na
idbull = ms.find(false, false, true)
idbear = ms.find(true , false, true)
btmP = obmode == "Length" ? (high[idbear] - 1 * atr[idbear]) <
low [idbear] ? low [idbear] : (high[idbear] - 1 * atr[idbear]) : low [idbear]
topP = obmode == "Length" ? (low [idbull] + 1 * atr[idbull]) >
high[idbull] ? high[idbull] : (low [idbull] + 1 * atr[idbull]) : high[idbull]
atr = ta.atr (200)
buy = low + atr
sel = high - atr
ph = ta.pivothigh(high, mslen, mslen)
pl = ta.pivotlow (low , mslen, mslen)
var int [] phn = array.new< int >(1, na)
var int [] pln = array.new< int >(1, na)
var float[] php = array.new<float>(1, na)
var float[] plp = array.new<float>(1, na)
if internal
blob.clear()
brob.clear()
if ph
phn.unshift(bar_index[mslen])
php.unshift(high[mslen])
if pl
pln.unshift(bar_index[mslen])
plp.unshift(low[mslen])
if php.size() > 0
if high > php.get(0)
php.clear()
phn.clear()
if plp.size() > 0
if low < plp.get(0)
plp.clear()
pln.clear()
if na(up)
up := high
if na(dn)
dn := low
if high > up
up := high
dn := low
crossup := true
if low < dn
up := high
dn := low
crossdn := true
if ms.start == 0
ms := structure.new(bar_index, na, high, low , bar_index,
bar_index, 0, 1, na, bar_index)
if draw
bldw.unshift(drawms.new(time, time, high , "CHoCH" , upcss,
line.style_dashed))
brdw.unshift(drawms.new(time, time, low , "CHoCH" , dncss,
line.style_dashed))
ms.upsweep := false
ms.dnsweep := false
if ms.start == 1
switch
low <= ms.choch and close >= ms.choch and buildsweep =>
bralerts.set(2, alert.new(true, "Bearish", "CHoCH Sweep\n"))
ms.dnsweep := true
ms.choch := low
ms.xloc := bar_index
if draw
dw = brdw.get(0)
dw.x2 := time
dw.style := line.style_dotted
dw.txt := "x"
brdw.unshift(
drawms.new(
time
, time
, low
, "CHoCH"
, dncss
, line.style_dashed
)
)
high >= ms.bos and close <= ms.bos and buildsweep =>
blalerts.set(2, alert.new(true, "Bullish", "CHoCH Sweep\n"))
ms.upsweep := true
ms.bos := high
ms.xloc := bar_index
if draw
dw = bldw.get(0)
dw.x2 := time
dw.style := line.style_dotted
dw.txt := "x"
bldw.unshift(
drawms.new(
time
, time
, high
, "CHoCH"
, upcss
, line.style_dashed
)
)
if ms.start == 2
switch ms.trend
-1 =>
if low <= ms.main
ms.main := low
ms.temp := bar_index
if bar_index % mslen * 2 == 0
if not na(ms.bos) and msmode == "Adjusted Points" and
php.size() > 0
if php.get(0) < ms.choch
// ms.xloc := phn.get(0)
ms.choch := php.get(0)
ms.loc := phn.get(0)
ms.xloc := phn.get(0)
ms.temp := phn.get(0)
if draw
choch = bldw.get(0)
choch.x1 := time [bar_index - phn.get(0)]
choch.x2 := time
choch.y := php.get(0)
if na(ms.bos)
if crossup and close > open and close[1] > open[1]
ms.bos := ms.main
ms.loc := ms.temp
ms.xloc := ms.loc
if draw
brdw.unshift(
drawms.new(
time[bar_index - ms.loc]
, time
, low [bar_index - ms.loc]
, "BOS"
, dncss
, line.style_dashed
)
)
if draw
choch = bldw.get(0)
choch.x2 := time
switch
low <= ms.bos and close >= ms.bos and not na(ms.bos) and
buildsweep =>
bralerts.set(3, alert.new(true, "Bearish", "BOS Sweep\n"))
ms.dnsweep := true
ms.bos := low
if draw
dw = brdw.get(0)
dw.x2 := time
dw.style := line.style_dotted
dw.txt := "x"
brdw.unshift(
drawms.new(
time
, time
, low
, "BOS"
, dncss
, line.style_dashed
)
)
if showside
id = ms.find(true, true, true)
btm = (high[id] - atr[id]) > low[id] ? (high[id] -
atr[id]) : low[id]
sellside.unshift(
sellbuyside.new(
high[id]
, btm
, time[id]
, sidesidecss
, "Sell Side"
, volume[id]
)
)
brarea.normal := false
ms.xloc := bar_index
switch
high >= ms.choch and close <= ms.choch and buildsweep =>
blalerts.set(2, alert.new(true, "Bullish", "CHoCH Sweep\
n"))
ms.upsweep := true
ms.choch := high
ms.xloc := bar_index
if draw
dw = bldw.get(0)
dw.x2 := time
dw.style := line.style_dotted
dw.txt := "x"
bldw.unshift(
drawms.new(
time
, time
, high
, "CHoCH"
, upcss
, line.style_dashed
)
)
if showside
id = ms.find(false, true, true)
top = (low[id] + atr[id]) < high[id] ? (low[id] +
atr[id]) : high[id]
buyside.unshift(
sellbuyside.new(
low[id]
, top
, time[id]
, buysidecss
, "Buy Side"
, volume[id]
)
)
ms.xloc := bar_index
blarea.normal := false
1 =>
if high >= ms.main
ms.main := high
ms.temp := bar_index
if na(ms.bos)
if crossdn and close < open and close[1] < open[1]
ms.bos := ms.main
ms.loc := ms.temp
ms.xloc := ms.loc
if draw
bldw.unshift(
drawms.new(
time[bar_index - ms.loc]
, time
, high[bar_index - ms.loc]
, "BOS"
, upcss
, line.style_dashed
)
)
if bar_index % mslen * 2 == 0
if not na(ms.bos) and msmode == "Adjusted Points" and
plp.size() > 0
if plp.get(0) > ms.choch
// ms.xloc := pln.get(0)
ms.choch := plp.get(0)
ms.loc := pln.get(0)
ms.xloc := pln.get(0)
ms.temp := pln.get(0)
// ms.loc := pln.get(0)
if draw
choch = brdw.get(0)
choch.x1 := time [bar_index - pln.get(0)]
choch.x2 := time
choch.y := plp.get(0)
if draw
choch = brdw.get(0)
choch.x2 := time
switch
high >= ms.bos and close <= ms.bos and not na(ms.bos) and
buildsweep =>
blalerts.set(3, alert.new(true, "Bullish", "BOS Sweep\n"))
ms.upsweep := true
ms.bos := high
if draw
dw = bldw.get(0)
dw.x2 := time
dw.style := line.style_dotted
dw.txt := "x"
bldw.unshift(
drawms.new(
time
, time
, high
, "BOS"
, upcss
, line.style_dashed
)
)
if showside
id = ms.find(false, true, true)
top = (low[id] + atr[id]) < high[id] ? (low[id] +
atr[id]) : high[id]
buyside.unshift(
sellbuyside.new(
low[id]
, top
, time[id]
, buysidecss
, "Buy Side"
, volume[id]
)
)
ms.xloc := bar_index
close >= ms.bos and not na(ms.bos) =>
blalerts.set(1, alert.new(true, "Bullish", "BOS\n"))
ms.txt := "bos"
ms.zz := ms.bos
ms.zn := bar_index
lc.start := true
lc.count := 0
blob.fnOB(true, topP, idbull)
id = ms.find(false, false, false)
ms.xloc := bar_index
ms.bos := na
ms.choch := low [id]
ms.loc := bar_index[id]
if draw
dw = bldw.get(0)
dw.x2 := time
dw.style := internal ? line.style_dashed :
line.style_solid
choch = brdw.get(0)
choch.x1 := time [id]
choch.x2 := time
choch.y := low [id]
blalert
switch
low <= ms.choch and close >= ms.choch and buildsweep =>
bralerts.set(2, alert.new(true, "Bearish", "CHoCH Sweep\
n"))
ms.dnsweep := true
ms.choch := low
ms.xloc := bar_index
if draw
dw = brdw.get(0)
dw.x2 := time
dw.style := line.style_dotted
dw.txt := "x"
brdw.unshift(
drawms.new(
time
, time
, low
, "CHoCH"
, dncss
, line.style_dashed
)
)
if showside
id = ms.find(true, true, true)
btm = (high[id] - atr[id]) > low[id] ? (high[id] -
atr[id]) : low[id]
sellside.unshift(
sellbuyside.new(
high[id]
, btm
, time[id]
, sidesidecss
, "Sell Side"
, volume[id]
)
)
ms.xloc := bar_index
if blob.size() > 0
ob = blob.get(0)
if low < ob.top
blalerts.set(5, alert.new(true, "Bullish", "Price Inside OB\n"))
if brob.size() > 0
ob = brob.get(0)
if high > ob.btm
bralerts.set(5, alert.new(true, "Bearish", "Price Inside OB\n"))
if showside
if buyside.size() > 0
side = buyside.get(0)
if low < side.btm
if blarea.normal == false
if sellside.size() > 0
side = sellside.get(0)
if high > side.btm
if brarea.normal == false
if sidemode == "Area"
bin.bx.unshift(
box.new(
top = side.top
, bottom = side.btm
, left = side.loc
, right = time
, border_color = na
, bgcolor = side.css
, xloc = xloc.bar_time
)
)
bin.ln.unshift(
line.new(
x1 = side.loc
, x2 = time
, y1 = side.top
, y2 = side.top
, xloc = xloc.bar_time
, color = color.new(side.css, 0)
, style = line.style_solid
)
)
bin.ln.unshift(
line.new(
x1 = bar_index
, x2 = bar_index + 10
, y1 = side.top
, y2 = side.top
, xloc = xloc.bar_index
, color = color.new(side.css, 0)
, style = line.style_dotted
)
)
bin.lb.unshift(
label.new(
x = bar_index
, y = side.top
, color = #ffffff00
, style = label.style_label_up
, textcolor = color.new(side.css, 0)
, size = mstext.txSz()
, text = "Buyside - " +
str.tostring(math.floor((side.vol / sum) * 100)) + "%"
)
)
if sellside.size() > 0
side = sellside.get(0)
float sum = side.vol
if buyside.size() > 0 and sellside.size() > 0
sum := buyside.get(0).vol + sellside.get(0).vol
if sidemode == "Area"
bin.bx.unshift(
box.new(
top = side.top
, bottom = side.btm
, left = side.loc
, right = time
, border_color = na
, bgcolor = side.css
, xloc = xloc.bar_time
)
)
bin.ln.unshift(
line.new(
x1 = side.loc
, x2 = time
, y1 = side.top
, y2 = side.top
, xloc = xloc.bar_time
, color = color.new(side.css, 0)
, style = line.style_solid
)
)
bin.ln.unshift(
line.new(
x1 = bar_index
, x2 = bar_index + 10
, y1 = side.top
, y2 = side.top
, xloc = xloc.bar_index
, color = color.new(side.css, 0)
, style = line.style_dotted
)
)
bin.lb.unshift(
label.new(
x = bar_index
, y = side.top
, color = #ffffff00
, style = label.style_label_down
, textcolor = color.new(side.css, 0)
, size = mstext.txSz()
, text = "Sellside - "+
str.tostring(math.floor((side.vol / sum) * 100)) + "%"
)
)
if blob.size() > 0
ob = blob.get(0)
if not ob.isbb
if low < ob.top
blalert
if blobenter.normal == false
blobenter.normal := true
else
if high > ob.btm
blalert
if blobenter.breaker == false
blobenter.breaker := true
if brob.size() > 0
ob = brob.get(0)
if not ob.isbb
if high > ob.btm
bralert
if brobenter.normal == false
brobenter.normal := true
else
if low < ob.top
bralert
if brobenter.breaker == false
brobenter.breaker := true
if blob.size() > 0
for [i, metric] in blob
metric.umt()
if brob.size() > 0
for [i, metric] in brob
metric.umt()
if barstate.islast
if blob.size() > 0
for i = 0 to math.min(oblast - 1, blob.size() - 1)
obs = blob.get(i)
display(obs, blob, i)
if brob.size() > 0
for i = 0 to math.min(oblast - 1, brob.size() - 1)
obs = brob.get(i)
display(obs, brob, i)
if msbubble
bin.lb.unshift(
label.new(
x = obj.x1
, y = obj.y
, xloc = xloc.bar_time
, color = color.new(obj.css, 80)
, style = label.style_circle
, size = size.tiny
)
)
for i = 0 to brdw.size() - 1
obj = brdw.get(i)
if i <= limit
bin.ln.unshift(
line.new(
x1 = obj.x1
, x2 = obj.x2
, y1 = obj.y
, y2 = obj.y
, color = obj.css
, style = obj.style
, xloc = xloc.bar_time
)
)
bin.lb.unshift(
label.new(
x = int(math.avg(bin.ln.get(0).get_x1(),
bin.ln.get(0).get_x2()))
, y = obj.y
, xloc = xloc.bar_time
, color = #ffffff00
, style = label.style_label_up
, textcolor = obj.css
, size = mstext.txSz()
, text = obj.txt
)
)
if msbubble
bin.lb.unshift(
label.new(
x = obj.x1
, y = obj.y
, xloc = xloc.bar_time
, color = color.new(obj.css, 80)
, style = label.style_circle
, size = size.tiny
)
)
ms
//}
_
='
------------
–––––––––––––––––––––––––– EXECUTION
–––––––––––––––––––––––––––
------------
'//{
structure ms = na
if windowsis
if (bar_index > last_bar_index - mswindow)
ms := structure(swingcssup , swingcssdn , showSwing , false, swingLimit)
if windowsis == false
ms := structure(swingcssup , swingcssdn , showSwing , false, swingLimit)
color css = na
switch ms.trend
-1 =>
if lc.count <= zonethresh
if high > ms.zz and close < ms.zz
lc.count := 0
if close > ms.zz
blalerts.set(11, alert.new(true, "Bullish", "Sweep Area\n"))
lc.start := false
lc.count := 0
float[] pp = array.new<float>()
for i = 0 to bar_index - ms.zn
pp.unshift(low[i])
1 =>
if lc.count <= zonethresh
if low < ms.zz and close > ms.zz
lc.count := 0
if close < ms.zz
bralerts.set(11, alert.new(true, "Bearish", "Sweep Area\n"))
lc.start := false
lc.count := 0
float[] pp = array.new<float>()
for i = 0 to bar_index - ms.zn
pp.unshift(high[i])
lc.count += 1
if showMapping
mapping()
if lvl_daily
mtfphl(pdh, pdl, 'D', css_d, s_d)
if lvl_weekly
mtfphl(pwh, pwl, 'W', css_w, s_w)
if lvl_monthly
mtfphl(pmh, pml, 'M', css_m, s_m)
if lvl_quartely
mtfphl(pqh, pql, 'Q', css_q, s_q)
if lvl_yearly
mtfphl(pyh, pyl, 'Y', css_y, s_y)
zhl(len)=>
upper = ta.highest(len)
lower = ta.lowest(len)
[top, btm]
// upphl(trend) =>
// if top
// phl.stopcross := true
// phl.txtup := top > phl.topy ? "HH" : "HL"
// phl.uV := volume[zonelen]
// if showhl
// line.delete(phl.top[1])
// phl.top := line.new(
// bar_index- zonelen
// , top
// , bar_index
// , top
// , color = swingcssdn)
// phl.topy := top
// phl.topx := bar_index - zonelen
// phl.tup := top
// phl.tupx := bar_index - zonelen
// line.set_xy1(
// phl.top
// , phl.tupx
// , phl.tup
// )
// line.set_xy2(
// phl.top
// , bar_index+ 20
// , phl.tup
// )
// label.set_x(
// lbl
// , bar_index+ 20
// )
// label.set_y(
// lbl
// , phl.tup
// )
// dnphl(trend) =>
// if btm
// phl.sbottomcross := true
// phl.txtdn := btm > phl.bottomy ? "LH" : "LL"
// phl.dV := volume[zonelen]
// if showhl
// line.delete(phl.bottom[1])
// phl.bottom := line.new(
// bar_index- 50
// , btm
// , bar_index
// , btm
// , color = swingcssup
// )
// phl.bottomy := btm
// phl.bottomx := bar_index- zonelen
// phl.tdn := btm
// phl.tdnx := bar_index- zonelen
// line.set_xy1(
// phl.bottom
// , phl.tdnx
// , phl.tdn
// )
// line.set_xy2(
// phl.bottom
// , bar_index+ 20
// , phl.tdn
// )
// label.set_x(
// lbl
// , bar_index+ 20
// )
// label.set_y(
// lbl
// , phl.tdn
// )
// midphl() =>
// if showpdzone
// avg = math.avg(phl.tdn, phl.tup)
// hqlzone() =>
// dZone.pbx.set_lefttop(int(math.max(phl.topx, phl.bottomx))
, phl.tup)
// dZone.pbx.set_rightbottom(bar_index+ 20 , 0.95 *
phl.tup + 0.05 * phl.tdn)
//}
// // _
='
// // ------------
// // –––––––––––––––––––––––––– ANYALERT
–––––––––––––––––––––––––––
// // ------------
'//{
// This source code is subject to the terms of the Mozilla Public License 2.0 at
https://mozilla.org/MPL/2.0/
// © LudoGH68
//@version=5
//// indicator("SMC Structures and FVG", overlay = true)
import LudoGH68/Drawings_public/1 as d
getLineStyle(lineOption) =>
lineOption == "┈" ? line.style_dotted : lineOption == "╌" ? line.style_dashed :
line.style_solid
get_structure_highest_bar(lookback) =>
for i = 0 to lookback - 1 by 1
if high[i+1] > high[i+2] and high[i] <= high[i+1] and ((i+1) * -1) >=
maxBar
idx := (i+1) * -1
//break
get_structure_lowest_bar(lookback) =>
var int idx = 0
minBar = bar_index > lookback ? ta.lowestbars(low, lookback) :
ta.lowestbars(low, bar_index + 1)
for i = 0 to lookback - 1 by 1
if low[i+1] < low[i+2] and low[i] >= low[i+1] and ((i+1) * -1) >=
minBar
idx := (i+1) * -1
//break
is_structure_high_broken(_highStructBreakPrice, _structureHigh,
_structureHighStartIndex, _structureDirection) =>
var bool res = false
res
box.set_right(value, bar_index)
box.set_right(value, bar_index)
// Arrays variable
var array<line> structureLines = array.new_line(0)
var array<label> structureLabels = array.new_label(0)
var array<box> fvgBoxes = array.new_box(0)
var array<bool> fvgTypes = array.new_bool(0)
var array<bool> isFvgMitigated = array.new_bool(0)
//
===================================================================================
=======
// FAIR VALUE GAP FINDER PROCESSING
//
===================================================================================
=======
//
//
// Define FVG type
isBullishFVG = high[3] < low[1]
isBearishFVG = low[3] > high[1]
// Draw FVG
FVGDraw(fvgBoxes, fvgTypes, isFvgMitigated)
//
//
//
===================================================================================
=======