SMC
SMC
0
at [Link]
// � BigBeluga
//
//@version=5
indicator("BigBeluga - Smart Money Concepts", "BigBeluga - Smart Money Concepts
[1.0.0]",
overlay = true,
max_bars_back = 5000,
max_boxes_count = 500,
max_labels_count = 500,
max_lines_count = 500,
max_polylines_count = 100)
plot(na)
//
MSG = "MARKET STRUCTURE"
VBG = "VOLUMETRIC ORDER BLOCKS"
MST = "Limit market structure calculation to improve memory speed time"
SLT = "[INPUT] Limit swing structure to tot bars back"
IDT = "[INPUT] Start date of the internal structure"
CST = "Color candle based on trend detection system"
OBT = "Display internal buy and sell activity"
OBD = "Show Last number of orderblock"
OBMT = "[Length] Use Length to adjust cordinate of the orderblocks\n[Full] Use
whole candle body"
_
='
------------
��������������������������� INPUTS
����������������������������
------------
'//{
bool windowsis = [Link](true, "Window", inline="kla", group=MSG)
int mswindow = [Link](5000, "", tooltip=MST,group=MSG, inline="kla",
minval=1000)
//}
_
='
------------
��������������������������� 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
����������������������������
------------
'//{
if [Link]
for obj in [Link]
[Link]()
for obj in [Link]
[Link]()
for obj in [Link]
[Link]()
for obj in [Link]
[Link]()
[Link]()
[Link]()
[Link]()
[Link]()
invcol = #ffffff00
//}
_
='
------------
��������������������������� UTILITY
����������������������������
------------
'//{
ghl() => [high[2], low[2], close[1], open[1], close, open, high, low, high[1],
low[1], [Link](200)]
min = 99999999.
max = 0.
idx = 0
if use_max
for i = 0 to (bar_index - loc)
max := [Link](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 := [Link](low[i], min)
max := min == low[i] ? high[i] : max
idx := min == low[i] ? i : idx
idx
SFPData() => [high, high[1] , high[2] , low, low[1] , low[2] , close, volume, time,
bar_index , time[1]]
SFPcords() =>
RealTF = [Link] ? 0 : 1
[h, h1, h2, l, l1, l2, c, v, t, n, t1] = SFPData()
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 - [Link]) - 1
min := [Link](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 - [Link])
max := [Link](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 - [Link])
min := [Link](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 - [Link]) - 1) > 0
if use_max
for i = 0 to (bar_index - [Link]) - 1
max := [Link](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 - [Link]) - 1
min := [Link](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 - [Link])
max := [Link](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 - [Link])
min := [Link](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 =>
[Link] := false
[Link] := false
[Link](
[Link](
true
, cords
, low [idx]
, [Link](cords, low[idx])
, time [idx]
, obupcs
, volume[idx]
, close [idx] > open[idx] ? 1 : -1
, 1
, 1
, 1
, time [idx]
)
)
false =>
[Link] := false
[Link] := false
[Link](
[Link](
false
, high [idx]
, cords
, [Link](cords, high[idx])
, time [idx]
, obdncs
, volume[idx]
, close [idx] > open[idx] ? 1 : -1
, 1
, 1
, 1
, time [idx]
)
)
false =>
if obmiti == "Close" ? [Link](close, open) > [Link] :
obmiti == "Wick" ? high > [Link] : obmiti == "Avg" ? high > [Link] : na
[Link] := true
[Link] := time
if not obshowbb
[Link](i)
else
switch [Link]
true =>
if obmiti == "Close" ? [Link](close, open) > [Link] :
obmiti == "Wick" ? high > [Link] : obmiti == "Avg" ? high > [Link] : na
[Link](i)
false =>
if obmiti == "Close" ? [Link](close, open) < [Link] :
obmiti == "Wick" ? low < [Link] : obmiti == "Avg" ? low < [Link] : na
[Link](i)
if [Link]() > 1
for i = [Link]() - 1 to 1
stuff = [Link](i)
current = [Link](0)
v = wichlap == "Recent" ? i : 0
switch
[Link] > [Link] and [Link] < [Link] =>
[Link](v)
[Link] < [Link] and [Link] > [Link] =>
[Link](v)
[Link] > [Link] and [Link] < [Link] =>
[Link](v)
[Link] < [Link] and [Link] > [Link] =>
[Link](v)
if [Link]() > 1
for i = [Link]() - 1 to 1
stuff = [Link](i)
current = [Link](0)
switch
[Link] > [Link] and [Link] < [Link] =>
[Link](i)
[Link] < [Link] and [Link] > [Link] =>
[Link](i)
[Link] > [Link] and [Link] < [Link] =>
[Link](i)
[Link] < [Link] and [Link] > [Link] =>
[Link](i)
-1 =>
switch [Link]
1 => [Link] := [Link] + 1, [Link] := 2
2 => [Link] := [Link] + 1, [Link] := 3
3 => [Link] := [Link] + 1, [Link] := 1
else
[Link]([Link] (top = [Link], bottom = [Link], left = [Link] ,
right = [Link] , border_color = na , bgcolor = [Link] , xloc =
xloc.bar_time))
[Link]([Link] (top = [Link], bottom = [Link], left = [Link] ,
right = time , border_color = [Link] , bgcolor = [Link] ? bbup : bbdn , xloc =
xloc.bar_time, border_width = 2))
[Link]([Link] (top = [Link], bottom = [Link], left = time ,
right = time + 1 , border_color = [Link] , bgcolor = [Link] ? bbup : bbdn , xloc =
xloc.bar_time, extend = [Link]))
if obshowactivity
[Link]([Link] (top = [Link], bottom = [Link], left = [Link] ,
right = [Link], border_color = na , bgcolor = obactup, xloc =
xloc.bar_time))
[Link]([Link] (top = [Link], bottom = [Link], left = [Link] ,
right = [Link], border_color = na , bgcolor = obactdn, xloc =
xloc.bar_time))
if showline
[Link]([Link](
x1 = [Link]
, x2 = time
, y1 = [Link]
, y2 = [Link]
, color = [Link]([Link], 0)
, xloc = xloc.bar_time
, style = line.style_dashed
)
)
if showmetric
if i == [Link](oblast - 1, [Link]() - 1)
float tV = 0
float[] dV = [Link]<float>()
seq = [Link](oblast - 1, [Link]() - 1)
for j = 0 to seq
cV = [Link](j)
tV += [Link]
if j == seq
for y = 0 to seq
[Link](
[Link](
([Link](y).vol / tV) * 100)
)
ids = [Link](y)
[Link]([Link](
bar_index - 1
, [Link]
, textcolor = [Link]([Link], 0)
, style = label.style_label_left
, size = [Link]()
, color = #ffffff00
, text =
[Link](
[Link]([Link](y).vol, 3), format =
[Link]) + " (" + [Link]([Link](y)) + "%)"
)
)
else
[Link](box .new(top = [Link] , bottom = [Link], left = [Link]
, right = [Link] , border_color = na
, bgcolor = bull ? fvg_upcss : fvg_dncss, xloc = xloc.bar_time))
[Link](box .new(top = [Link] , bottom = [Link], left = [Link]
, right = time , border_color = bull ? fvg_dncss : fvg_upcss
, bgcolor = bull ? fvg_dncss : fvg_upcss, xloc = xloc.bar_time, extend = ext))
if fvgline
[Link]([Link](x1 = [Link] , x2 = [Link] , y1 =
[Link]([Link], [Link]), y2 = [Link]([Link], [Link]), color = [Link](bull
? fvg_upcss : fvg_dncss, 0) , xloc =
xloc.bar_time))
[Link]([Link](x1 = [Link], x2 = time , y1 =
[Link]([Link], [Link]), y2 = [Link]([Link], [Link]), color = [Link](bull
? fvg_dncss : fvg_upcss, 0) , xloc =
xloc.bar_time, extend = ext, style = line.style_dashed))
//}
_
='
------------
��������������������������� 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 [Link][] charts = [Link]<[Link]>()
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)
[Link](
[Link].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)
[Link](
[Link].from_time(
time[id]
, high[id]
)
)
idx := bar_index
point := high[id]
sum := time[id]
up := high
dn := low
project := time
trend := -1
if [Link]
var line ln = na
var polyline pl = na
[Link]()
[Link]()
ln := na
pl := na
ln := [Link](
x1 = sum
, x2 = project
, y1 = point
, y2 = trend == 1 ? up : dn
, xloc = xloc.bar_time
, color = [Link]
)
pl := [Link](
charts
, line_color = mappingcss
, xloc = xloc.bar_time
, line_style = [Link]()
)
posLIQ() =>
ph = [Link](high, 5, 5)
pl = [Link] (low , 5, 5)
if pl
[Link](0, pl)
if high > [Link](0) and close < [Link](0) and upallow and high > high[1]
upallow := false
printup := true
if low < [Link](0) and close > [Link](0) and dnallow and low < low[1]
dnallow := false
printdn := true
[printup, printdn]
dEHL() =>
var equalbuild[] bleqal = [Link]<equalbuild>()
var equalbuild[] breqal = [Link]<equalbuild>()
var equalname [] blname = [Link]<equalname >()
var equalname [] brname = [Link]<equalname >()
int pos = 2
float thresh = 0.1
switch ehlmode
"Short-Term" => pos := 2, thresh := 0.1
"Mid-Term" => pos := 6, thresh := 0.25
"Long-Term" => pos := 10, thresh := 0.5
switch
top =>
mx = [Link](top, [Link])
mn = [Link](top, [Link])
switch
mx < mn + atr * thresh =>
[Link](
[Link](
w.t
, [Link]
, bar_index - pos
, top
, ehlupcs
, line.style_dotted
)
)
[Link](
[Link](
int([Link](bar_index - pos, w.t))
, top
, "EQH"
, ehlupcs
, label.style_label_down
)
)
[Link] := top
w.t := bar_index - pos
btm =>
mx = [Link](btm, [Link])
mn = [Link](btm, [Link])
switch
mn > mx - atr * thresh =>
[Link](
[Link](
w.b
, [Link]
, bar_index - pos
, btm
, ehldowncs, line.style_dotted
)
)
[Link](
[Link](
int([Link](bar_index - pos, w.b))
, btm
, "EQL"
, ehldowncs
, label.style_label_up
)
)
[Link] := btm
w.b := bar_index - pos
if [Link]
if [Link]() > 0
for i = 0 to [Link]() - 1
draw = [Link](i)
labe = [Link](i)
if i < 10
[Link](
[Link](
draw.x1
, draw.y1
, draw.x2
, draw.y2
, color = [Link]
, style = [Link]
)
)
[Link](
[Link](
x = labe.x
, y = labe.y
, color = #ffffff00
, style = [Link]
, textcolor = [Link]
, size = [Link]()
, text = [Link]
)
)
if [Link]() > 0
for i = 0 to [Link]() - 1
draw = [Link](i)
labe = [Link](i)
if i < 10
[Link](
[Link](
draw.x1
, draw.y1
, draw.x2
, draw.y2
, color = [Link]
, style = [Link]
)
)
[Link](
[Link](
x = labe.x
, y = labe.y
, color = #ffffff00
, style = [Link]
, textcolor = [Link]
, size = [Link]()
, text = [Link]
)
)
h = high
h1 = high[1]
h2 = high[2]
l = low
l1 = low [1]
l2 = low [2]
c = close
v = volume
t = time
n = bar_index
t1 = time[1]
string size = [Link]()
bool vol = ([Link](v, 21) * sfpthresh) < v ? true : false
bool blPrint = true
bool brPrint = true
switch sfpfilter
"Trend Following" =>
switch [Link]
1 => blPrint := true , brPrint := false
-1 => blPrint := false , brPrint := true
=> na
[Link](
[Link](
[Link]()
, [Link]([Link]([Link]()))
, [Link]([Link]([Link]()))
)
)
if [Link]() != l1
[Link](
[Link](
l1
, t1
, h1
)
)
else
[Link](
[Link](
l1
, t1
, h1
)
)
[Link](
[Link](
[Link]()
, [Link]([Link]([Link]()))
, [Link]([Link]([Link]()))
)
)
if [Link]() != h1
[Link](
[Link](
h1
, t1
, l1
)
)
else
[Link](
[Link](
h1
, t1
, l1
)
)
[Link](
[Link](
time
, (low < sfp.y ? low : sfp.y)
, label.style_label_up
, blsfpcs, "?\nSFP"
)
)
[Link](
[Link](
[Link]
, time
, sfp.y
, blsfpcs
, [Link]
, bar_index
)
)
[Link](i)
else
[Link](i)
[Link](
[Link](
time
, (high > sfp.y ? high : sfp.y)
, label.style_label_down
, brsfpcs
, "SFP\n?"
)
)
[Link](
[Link](
[Link]
, time
, sfp.y
, brsfpcs
, [Link]
, bar_index
)
)
[Link](i)
else
[Link](i)
if [Link]
if sfpshow > 0 and [Link]() > 0
for i = 0 to [Link](sfpshow - 1, [Link]() - 1)
x = [Link](i)
[Link](
[Link](
x = x.x
, y = x.y
, text = [Link]
, color = #ffffff00
, style = [Link]
, size = size
, textcolor = [Link]
, xloc = xloc.bar_time
)
)
if sfpshow > 0 and [Link]() > 0 and [Link]() > 0 and showdev
max = [Link]([Link](0).loc, [Link](0).loc)
use = [Link]([Link](0).loc, [Link](0).loc) == [Link](0).loc ?
[Link](0) : [Link](0)
bull = [Link]([Link](0).loc, [Link](0).loc) == [Link](0).loc ?
true : false
switch bull
false =>
[Link]([Link](x1 = use.x1, x2 = time, y1 = [Link]
- 4.0 * (use.y - [Link]), y2 = [Link] - 4.0 * (use.y - [Link]), xloc =
xloc.bar_time, color = chart.fg_color, style = [Link]()))
[Link]([Link](x1 = use.x1, x2 = time, y1 = [Link]
- 2.0 * (use.y - [Link]), y2 = [Link] - 2.0 * (use.y - [Link]), xloc =
xloc.bar_time, color = devcss, style = [Link]()))
[Link]([Link](x1 = use.x1, x2 = time, y1 = [Link]
- 2.5 * (use.y - [Link]), y2 = [Link] - 2.5 * (use.y - [Link]), xloc =
xloc.bar_time, color = devcss, style = [Link]()))
if devfill
[Link](
[Link](
[Link](0)
, [Link](1)
, color = [Link](devcss, 90)
)
)
if devlvl
[Link]([Link](x = use.x1, y = [Link] + 4.0 *
([Link] - use.y), text = [Link](4.0 * 100) + "%" + " (" +
[Link]([Link]([Link] + 4.0 * ([Link] - use.y), 2)) + ")", style =
label.style_label_right, textcolor = chart.fg_color, color = #ffffff00, size =
[Link](), xloc = xloc.bar_time))
[Link]([Link](x = use.x1, y = [Link] + 2.0 *
([Link] - use.y), text = [Link](2.0 * 100) + "%" + " (" +
[Link]([Link]([Link] + 2.0 * ([Link] - use.y), 2)) + ")", style =
label.style_label_right, textcolor = devcss , color = #ffffff00, size =
[Link](), xloc = xloc.bar_time))
[Link]([Link](x = use.x1, y = [Link] + 2.5 *
([Link] - use.y), text = [Link](2.5 * 100) + "%" + " (" +
[Link]([Link]([Link] + 2.5 * ([Link] - use.y), 2)) + ")", style =
label.style_label_right, textcolor = devcss , color = #ffffff00, size =
[Link](), xloc = xloc.bar_time))
true =>
[Link]([Link](x1 = use.x1, x2 = time, y1 = [Link]
+ 4.0 * ([Link] - use.y), y2 = [Link] + 4.0 * ([Link] - use.y), xloc =
xloc.bar_time, color = chart.fg_color, style = [Link]()))
[Link]([Link](x1 = use.x1, x2 = time, y1 = [Link]
+ 2.0 * ([Link] - use.y), y2 = [Link] + 2.0 * ([Link] - use.y), xloc =
xloc.bar_time, color = devcss, style = [Link]()))
[Link]([Link](x1 = use.x1, x2 = time, y1 = [Link]
+ 2.5 * ([Link] - use.y), y2 = [Link] + 2.5 * ([Link] - use.y), xloc =
xloc.bar_time, color = devcss, style = [Link]()))
if devfill
[Link](
[Link](
[Link](0)
, [Link](1)
, color = [Link](devcss, 90)
)
)
if devlvl
[Link]([Link](x = use.x1, y = [Link] + 4.0 *
([Link] - use.y), text = [Link](4.0 * 100) + "%" + " (" +
[Link]([Link]([Link] + 4.0 * ([Link] - use.y), 2)) + ")", style =
label.style_label_right, textcolor = chart.fg_color, color = #ffffff00, size =
[Link](), xloc = xloc.bar_time))
[Link]([Link](x = use.x1, y = [Link] + 2.0 *
([Link] - use.y), text = [Link](2.0 * 100) + "%" + " (" +
[Link]([Link]([Link] + 2.0 * ([Link] - use.y), 2)) + ")", style =
label.style_label_right, textcolor = devcss, color = #ffffff00, size =
[Link](), xloc = xloc.bar_time))
[Link]([Link](x = use.x1, y = [Link] + 2.5 *
([Link] - use.y), text = [Link](2.5 * 100) + "%" + " (" +
[Link]([Link]([Link] + 2.5 * ([Link] - use.y), 2)) + ")", style =
label.style_label_right, textcolor = devcss, color = #ffffff00, size =
[Link](), xloc = xloc.bar_time))
dFVG() =>
[h2, l2, c1, o1, c, o, h, l, h1, l1, fvatr] = ghl()
var FVG[] blFVG = [Link]<FVG>()
var FVG[] brFVG = [Link]<FVG>()
bool upfvg = false
bool dnfvg = false
float blth = l1 + (fvatr[1] * fvgthresh)
float brth = h1 - (fvatr[1] * fvgthresh)
cc = [Link]()
switch
what_fvg == "FVG" or what_fvg == "Breakers" =>
if l > h2 and cc and c1 > blth
upfvg := true
if upfvg[1]
if [Link]() > 0
fvg = [Link](0)
if [Link] == true and [Link] == false
[Link] := true
[Link] := na
fvg.raidx2 := na
[Link] := na
[Link] := #ffffff00
[Link](
[Link](
l [1]
, h2 [1]
, time[3]
, false
, na
)
)
if dnfvg[1]
if [Link]() > 0
fvg = [Link](0)
if [Link] == true and [Link] == false
fvg = [Link](0)
[Link] := true
[Link] := true
[Link] := na
fvg.raidx2 := na
[Link] := na
[Link] := #ffffff00
[Link](
[Link](
l2 [1]
, h [1]
, time[3]
, false
, na
)
)
if [Link]() > 0
for [i, fvg] in blFVG
if not [Link]
if fvg_src == "Close" ? [Link](c, o) < [Link] : fvg_src ==
"Wick" ? l < [Link] : fvg_src == "Avg" ? l < [Link]([Link], [Link]) : na
[Link] := true
[Link] := time
if what_fvg == "FVG"
[Link](i)
else
if (fvg_src == "Close" ? [Link](c, o) > [Link] : fvg_src ==
"Wick" ? h > [Link] : fvg_src == "Avg" ? h > [Link]([Link], [Link]) : na) and
what_fvg == "Breakers"
[Link](i)
if [Link]() > 0
for [i, fvg] in brFVG
if not [Link]
if (fvg_src == "Close" ? [Link](c, o) > [Link] : fvg_src ==
"Wick" ? h > [Link] : fvg_src == "Avg" ? h > [Link]([Link], [Link]) : na)
[Link] := true
[Link] := time
if what_fvg == "FVG"
[Link](i)
else
if (fvg_src == "Close" ? [Link](c, o) < [Link] : fvg_src ==
"Wick" ? l < [Link] : fvg_src == "Avg" ? l < [Link]([Link], [Link]) : na) and
what_fvg == "Breakers"
[Link](i)
if fvgoverlap
overlapFVG(blFVG, brFVG)
if dispraid
for [i, fvg] in blFVG
if not [Link] and not [Link]
if low < [Link] and close > [Link]
[Link] := true
[Link] := time
fvg.raidx2 := time
[Link] := low
[Link] := chart.fg_color
else
if low <= [Link] and [Link] == false and not [Link]
[Link] := true
fvg.raidx2 := time
else
if [Link] == false and not [Link]
fvg.raidx2 := time
[Link] := true
fvg.raidx2 := time
else
if [Link] == false and not [Link]
fvg.raidx2 := time
if [Link]
if [Link]() > 0 and fvg_num > 0
for i = 0 to [Link](fvg_num - 1, [Link]() - 1)
fvg = [Link](i)
dispFVG(fvg, i, true)
structure(color upcss, color dncss, bool draw, bool internal, int limit) =>
var structure ms = [Link](start = 0)
var ob [] blob = [Link]< ob >()
var ob [] brob = [Link]< ob >()
var drawms [] bldw = [Link]< drawms >()
var drawms [] brdw = [Link]< drawms >()
var sellbuyside[] sellside = [Link]<sellbuyside>()
var sellbuyside[] buyside = [Link]<sellbuyside>()
bool crossup = false
bool crossdn = false
var float up = na
var float dn = na
idbull = [Link](false, false, true)
idbear = [Link](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 = [Link] (200)
buy = low + atr
sel = high - atr
ph = [Link](high, mslen, mslen)
pl = [Link] (low , mslen, mslen)
var int [] phn = [Link]< int >(1, na)
var int [] pln = [Link]< int >(1, na)
var float[] php = [Link]<float>(1, na)
var float[] plp = [Link]<float>(1, na)
if internal
[Link]()
[Link]()
if ph
[Link](bar_index[mslen])
[Link](high[mslen])
if pl
[Link](bar_index[mslen])
[Link](low[mslen])
if [Link]() > 0
if high > [Link](0)
[Link]()
[Link]()
if [Link]() > 0
if low < [Link](0)
[Link]()
[Link]()
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 [Link] == 0
ms := [Link](bar_index, na, high, low , bar_index,
bar_index, 0, 1, na, bar_index)
if draw
[Link]([Link](time, time, high , "CHoCH" , upcss,
line.style_dashed))
[Link]([Link](time, time, low , "CHoCH" , dncss,
line.style_dashed))
[Link] := false
[Link] := false
if [Link] == 1
switch
low <= [Link] and close >= [Link] and buildsweep =>
[Link] := true
[Link] := low
[Link] := bar_index
if draw
dw = [Link](0)
dw.x2 := time
[Link] := line.style_dotted
[Link] := "x"
[Link](
[Link](
time
, time
, low
, "CHoCH"
, dncss
, line.style_dashed
)
)
high >= [Link] and close <= [Link] and buildsweep =>
[Link] := true
[Link] := high
[Link] := bar_index
if draw
dw = [Link](0)
dw.x2 := time
[Link] := line.style_dotted
[Link] := "x"
[Link](
[Link](
time
, time
, high
, "CHoCH"
, upcss
, line.style_dashed
)
)
[Link] := "choch"
[Link] := true
[Link] := 0
[Link](true, topP, idbull)
[Link] := -1
[Link] := [Link]
[Link] := na
[Link] := 2
[Link] := bar_index
[Link] := low
[Link] := [Link]
[Link] := bar_index
if draw
dw = [Link](0)
dw.x2 := time
[Link] := internal ? line.style_dashed : line.style_solid
[Link] := "choch"
[Link] := true
[Link] := 0
[Link](false, btmP, idbear)
[Link] := 1
[Link] := [Link]
[Link] := na
[Link] := 2
[Link] := bar_index
[Link] := high
[Link] := [Link]
[Link] := bar_index
if draw
dw = [Link](0)
dw.x2 := time
[Link] := internal ? line.style_dashed : line.style_solid
if [Link] == 2
switch [Link]
-1 =>
if low <= [Link]
[Link] := low
[Link] := bar_index
if bar_index % mslen * 2 == 0
if not na([Link]) and msmode == "Adjusted Points" and
[Link]() > 0
if [Link](0) < [Link]
// [Link] := [Link](0)
[Link] := [Link](0)
[Link] := [Link](0)
[Link] := [Link](0)
[Link] := [Link](0)
if draw
choch = [Link](0)
choch.x1 := time [bar_index - [Link](0)]
choch.x2 := time
choch.y := [Link](0)
if na([Link])
if crossup and close > open and close[1] > open[1]
[Link] := [Link]
[Link] := [Link]
[Link] := [Link]
if draw
[Link](
[Link](
time[bar_index - [Link]]
, time
, low [bar_index - [Link]]
, "BOS"
, dncss
, line.style_dashed
)
)
if draw
choch = [Link](0)
choch.x2 := time
switch
low <= [Link] and close >= [Link] and not na([Link]) and
buildsweep =>
[Link] := true
[Link] := low
if draw
dw = [Link](0)
dw.x2 := time
[Link] := line.style_dotted
[Link] := "x"
[Link](
[Link](
time
, time
, low
, "BOS"
, dncss
, line.style_dashed
)
)
if showside
id = [Link](true, true, true)
btm = (high[id] - atr[id]) > low[id] ? (high[id] -
atr[id]) : low[id]
[Link](
[Link](
high[id]
, btm
, time[id]
, sidesidecss
, "Sell Side"
, volume[id]
)
)
[Link] := false
[Link] := bar_index
[Link] := "bos"
[Link] := [Link]
[Link] := bar_index
[Link] := true
[Link] := 0
[Link](false, btmP, idbear)
id = [Link](true, false, false)
[Link] := bar_index
[Link] := na
[Link] := high [id]
[Link] := bar_index[id]
if draw
dw = [Link](0)
dw.x2 := time
[Link] := internal ? line.style_dashed :
line.style_solid
choch = [Link](0)
choch.x1 := time [id]
choch.x2 := time
choch.y := high [id]
switch
high >= [Link] and close <= [Link] and buildsweep =>
[Link] := true
[Link] := high
[Link] := bar_index
if draw
dw = [Link](0)
dw.x2 := time
[Link] := line.style_dotted
[Link] := "x"
[Link](
[Link](
time
, time
, high
, "CHoCH"
, upcss
, line.style_dashed
)
)
[Link] := "choch"
[Link] := [Link]
[Link] := bar_index
[Link] := true
[Link] := 0
[Link](true, topP, idbull)
id = [Link](false, false, false)
switch
na([Link]) =>
[Link] := low[id]
if draw
[Link](
[Link](
time
, time
, low
, "BOS"
, dncss
, line.style_dashed
)
)
choch = [Link](0)
choch.x1 := time[bar_index - [Link]]
=> [Link] := [Link]//low[id + 1] < low[id] ? low[id +
1] : low[id]
[Link] := na
[Link] := high
[Link] := 1
[Link] := bar_index
[Link] := bar_index
[Link] := [Link]
if draw
dw = [Link](0)
dw.x2 := time
[Link] := "CHoCH"
[Link] := internal ? line.style_dashed :
line.style_solid
choch = [Link](0)
choch.x2 := time
choch.y := [Link]
[Link] := "CHoCH"
if showside
id = [Link](false, true, true)
top = (low[id] + atr[id]) < high[id] ? (low[id] +
atr[id]) : high[id]
[Link](
[Link](
low[id]
, top
, time[id]
, buysidecss
, "Buy Side"
, volume[id]
)
)
[Link] := bar_index
[Link] := false
1 =>
if high >= [Link]
[Link] := high
[Link] := bar_index
if na([Link])
if crossdn and close < open and close[1] < open[1]
[Link] := [Link]
[Link] := [Link]
[Link] := [Link]
if draw
[Link](
[Link](
time[bar_index - [Link]]
, time
, high[bar_index - [Link]]
, "BOS"
, upcss
, line.style_dashed
)
)
if bar_index % mslen * 2 == 0
if not na([Link]) and msmode == "Adjusted Points" and
[Link]() > 0
if [Link](0) > [Link]
// [Link] := [Link](0)
[Link] := [Link](0)
[Link] := [Link](0)
[Link] := [Link](0)
[Link] := [Link](0)
// [Link] := [Link](0)
if draw
choch = [Link](0)
choch.x1 := time [bar_index - [Link](0)]
choch.x2 := time
choch.y := [Link](0)
if draw
choch = [Link](0)
choch.x2 := time
switch
high >= [Link] and close <= [Link] and not na([Link]) and
buildsweep =>
[Link] := true
[Link] := high
if draw
dw = [Link](0)
dw.x2 := time
[Link] := line.style_dotted
[Link] := "x"
[Link](
[Link](
time
, time
, high
, "BOS"
, upcss
, line.style_dashed
)
)
if showside
id = [Link](false, true, true)
top = (low[id] + atr[id]) < high[id] ? (low[id] +
atr[id]) : high[id]
[Link](
[Link](
low[id]
, top
, time[id]
, buysidecss
, "Buy Side"
, volume[id]
)
)
[Link] := bar_index
[Link] := "bos"
[Link] := [Link]
[Link] := bar_index
[Link] := true
[Link] := 0
[Link](true, topP, idbull)
id = [Link](false, false, false)
[Link] := bar_index
[Link] := na
[Link] := low [id]
[Link] := bar_index[id]
if draw
dw = [Link](0)
dw.x2 := time
[Link] := internal ? line.style_dashed :
line.style_solid
choch = [Link](0)
choch.x1 := time [id]
choch.x2 := time
choch.y := low [id]
switch
low <= [Link] and close >= [Link] and buildsweep =>
[Link] := true
[Link] := low
[Link] := bar_index
if draw
dw = [Link](0)
dw.x2 := time
[Link] := line.style_dotted
[Link] := "x"
[Link](
[Link](
time
, time
, low
, "CHoCH"
, dncss
, line.style_dashed
)
)
[Link] := "choch"
[Link] := [Link]
[Link] := bar_index
[Link] := true
[Link] := 0
[Link](false, btmP, idbear)
id = [Link](true, false, false)
switch
na([Link]) =>
[Link] := high[id]
if draw
[Link](
[Link](
time
, time
, high
, "BOS"
, upcss
, line.style_dashed
)
)
choch = [Link](0)
choch.x1 := time[bar_index - [Link]]
=> [Link] := [Link]//high[id + 1] > high[id] ?
high[id + 1] : high[id]
[Link] := na
[Link] := low
[Link] := -1
[Link] := bar_index
[Link] := [Link]
if draw
dw = [Link](0)
dw.x2 := time
[Link] := "CHoCH"
[Link] := internal ? line.style_dashed :
line.style_solid
choch = [Link](0)
choch.y := [Link]
choch.x2 := time
[Link] := "CHoCH"
if showside
id = [Link](true, true, true)
btm = (high[id] - atr[id]) > low[id] ? (high[id] -
atr[id]) : low[id]
[Link](
[Link](
high[id]
, btm
, time[id]
, sidesidecss
, "Sell Side"
, volume[id]
)
)
[Link] := bar_index
if showside
if [Link]() > 0
side = [Link](0)
if low < [Link]
if [Link] == false
if [Link]() > 0
side = [Link](0)
if high > [Link]
if [Link] == false
if sidemode == "Area"
[Link](
[Link](
top = [Link]
, bottom = [Link]
, left = [Link]
, right = time
, border_color = na
, bgcolor = [Link]
, xloc = xloc.bar_time
)
)
[Link](
[Link](
x1 = [Link]
, x2 = time
, y1 = [Link]
, y2 = [Link]
, xloc = xloc.bar_time
, color = [Link]([Link], 0)
, style = line.style_solid
)
)
[Link](
[Link](
x1 = bar_index
, x2 = bar_index + 10
, y1 = [Link]
, y2 = [Link]
, xloc = xloc.bar_index
, color = [Link]([Link], 0)
, style = line.style_dotted
)
)
[Link](
[Link](
x = bar_index
, y = [Link]
, color = #ffffff00
, style = label.style_label_up
, textcolor = [Link]([Link], 0)
, size = [Link]()
, text = "Buyside - " +
[Link]([Link](([Link] / sum) * 100)) + "%"
)
)
if [Link]() > 0
side = [Link](0)
float sum = [Link]
if [Link]() > 0 and [Link]() > 0
sum := [Link](0).vol + [Link](0).vol
if sidemode == "Area"
[Link](
[Link](
top = [Link]
, bottom = [Link]
, left = [Link]
, right = time
, border_color = na
, bgcolor = [Link]
, xloc = xloc.bar_time
)
)
[Link](
[Link](
x1 = [Link]
, x2 = time
, y1 = [Link]
, y2 = [Link]
, xloc = xloc.bar_time
, color = [Link]([Link], 0)
, style = line.style_solid
)
)
[Link](
[Link](
x1 = bar_index
, x2 = bar_index + 10
, y1 = [Link]
, y2 = [Link]
, xloc = xloc.bar_index
, color = [Link]([Link], 0)
, style = line.style_dotted
)
)
[Link](
[Link](
x = bar_index
, y = [Link]
, color = #ffffff00
, style = label.style_label_down
, textcolor = [Link]([Link], 0)
, size = [Link]()
, text = "Sellside - "+
[Link]([Link](([Link] / sum) * 100)) + "%"
)
)
if [Link]() > 0
ob = [Link](0)
if not [Link]
if low < [Link]
if [Link] == false
[Link] := true
else
if high > [Link]
if [Link] == false
[Link] := true
if [Link]() > 0
ob = [Link](0)
if not [Link]
if high > [Link]
if [Link] == false
[Link] := true
else
if low < [Link]
if [Link] == false
[Link] := true
if [Link]() > 0
for [i, metric] in blob
[Link]()
if [Link]() > 0
for [i, metric] in brob
[Link]()
if [Link]
if [Link]() > 0
for i = 0 to [Link](oblast - 1, [Link]() - 1)
obs = [Link](i)
display(obs, blob, i)
if [Link]() > 0
for i = 0 to [Link](oblast - 1, [Link]() - 1)
obs = [Link](i)
display(obs, brob, i)
if msbubble
[Link](
[Link](
x = obj.x1
, y = obj.y
, xloc = xloc.bar_time
, color = [Link]([Link], 80)
, style = label.style_circle
, size = [Link]
)
)
for i = 0 to [Link]() - 1
obj = [Link](i)
if i <= limit
[Link](
[Link](
x1 = obj.x1
, x2 = obj.x2
, y1 = obj.y
, y2 = obj.y
, color = [Link]
, style = [Link]
, xloc = xloc.bar_time
)
)
[Link](
[Link](
x = int([Link]([Link](0).get_x1(),
[Link](0).get_x2()))
, y = obj.y
, xloc = xloc.bar_time
, color = #ffffff00
, style = label.style_label_up
, textcolor = [Link]
, size = [Link]()
, text = [Link]
)
)
if msbubble
[Link](
[Link](
x = obj.x1
, y = obj.y
, xloc = xloc.bar_time
, color = [Link]([Link], 80)
, style = label.style_circle
, size = [Link]
)
)
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 [Link]
-1 =>
if [Link] <= zonethresh
if high > [Link] and close < [Link]
[Link] := 0
if close > [Link]
[Link] := false
[Link] := 0
float[] pp = [Link]<float>()
for i = 0 to bar_index - [Link]
[Link](low[i])
1 =>
if [Link] <= zonethresh
if low < [Link] and close > [Link]
[Link] := 0
if close < [Link]
[Link] := false
[Link] := 0
float[] pp = [Link]<float>()
for i = 0 to bar_index - [Link]
[Link](high[i])
[Link] += 1
if fvg_enable
dFVG()
if ehlshow
dEHL()
if showMapping
mapping()