Guardeer Trading Indicator Script
//-----------------------------------------------------------------------------{
// Boolean set
//-----------------------------------------------------------------------------{
s_BOS = 0
s_CHoCH = 1
i_BOS = 2
i_CHoCH = 3
i_pp_CHoCH = 4
green_candle = 5
red_candle = 6
s_CHoCHP = 7
i_CHoCHP = 8
boolean =
[Link](
false
, false
, false
, false
, false
, false
, false
, false
, false
)
//-----------------------------------------------------------------------------{
// User inputs
//-----------------------------------------------------------------------------{
t = color.t(ob_bull_css)
invcol = [Link]([Link], 100)
//{ - UDT
}
type bar
float o = open
float c = close
float h = high
float l = low
float v = volume
int n = bar_index
int t = time
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 FVG
box [] box
line[] ln
bool bull
float top
float btm
int left
int right
type ms
float[] p
int [] n
float[] l
type msDraw
int n
float p
color css
string txt
bool bull
type obC
float[] top
float[] btm
int [] left
float[] avg
float[] dV
float[] cV
int [] wM
int [] blVP
int [] brVP
int [] dir
float[] h
float[] l
int [] n
type obD
box [] ob
box [] eOB
box [] blB
box [] brB
line[] mL
type zone
[Link] points
float p
int c
int t
type hqlzone
box pbx
box ebx
box lbx
label plb
label elb
label lbl
type ehl
float pt
int t
float pb
int b
type pattern
string found = "None"
bool isfound = false
int period = 0
bool bull = false
type alerts
bool chochswing = false
bool chochplusswing = false
bool swingbos = false
bool chochplus = false
bool choch = false
bool bos = false
bool equal = false
bool ob = false
bool swingob = false
bool zone = false
bool fvg = false
bool obtouch = false
//{ - End
}
//{ - General Setup
}
bar b = [Link]()
var pattern p = [Link]()
if [Link]
[Link] += 1
if [Link] == 50
[Link] := 0
[Link] := "None"
[Link] := false
[Link] := false
switch
if ms_mode == "Dynamic"
switch
vv >= 1.5 or vv <= -1.5 => iLen := 10
vv >= 1.6 or vv <= -1.6 => iLen := 9
vv >= 1.7 or vv <= -1.7 => iLen := 8
vv >= 1.8 or vv <= -1.8 => iLen := 7
vv >= 1.9 or vv <= -1.9 => iLen := 6
vv >= 2.0 or vv <= -2.0 => iLen := 5
=> iLen
//{ - End
}
//{ - ARRAYS
}
lstyle(style) =>
hy = [Link](h != h[1] , h , 1)
hx = [Link](h == high , time , 1)
ly = [Link](l != l[1] , l , 1)
lx = [Link](l == low , time , 1)
if [Link]
line.set_xy1(hl , hx , hy)
line.set_xy2(hl , extension , hy)
label.set_xy(hlb, extension , hy)
line.set_xy1(ll , lx , ly)
line.set_xy2(ll , extension , ly)
label.set_xy(lbl, extension , ly)
if lvl_daily
if lvl_weekly
if lvl_monthly
if lvl_yearly
//{ - End
}
//{ - Market Structure
}
var line id = na
var label lbl = na
id := [Link](
x1 = d.n,
y1 = d.p,
x2 = b.n,
y2 = d.p,
color = [Link],
width = 1,
style = style
)
[Link]([Link]())
[Link](id)
lbl := [Link](
x = int([Link](d.n, b.n)),
y = d.p,
text = [Link],
color = invcol,
textcolor = [Link],
style = [Link] ? label.style_label_down : label.style_label_up,
size = size,
text_font_family = font.family_monospace
)
msDraw drw = na
var ms up = [Link](
[Link]<float>(),
[Link]< int >(),
[Link]<float>()
)
var ms dn = [Link](
[Link]<float>(),
[Link]< int >(),
[Link]<float>()
)
switch show_swing_ms
switch show_internal_ms
switch
iH =>
[Link](b.h[iLen])
[Link](b.h[iLen])
[Link](n [iLen])
iL =>
[Link](b.l[iLen])
[Link](b.l[iLen])
[Link](n [iLen])
sL =>
[Link](b.l[sLen])
[Link](b.l[sLen])
[Link](n [sLen])
sH =>
[Link](b.h[sLen])
[Link](b.h[sLen])
[Link](n [sLen])
if [Link](b.c, [Link]())
if itrend < 0
CHoCH := true
switch
txt := "BOS"
css := i_ms_up_BOS
[Link] := true
isdrw := true
drw := [Link](
[Link](),
[Link](),
i_ms_up_BOS,
txt,
true
)
CHoCH =>
isdrw := true
drw := [Link](
[Link](),
[Link](),
i_ms_up_BOS.darkcss(0.25, true),
txt,
true
)
if mtf == false
switch
itrend := 1
[Link]()
[Link]()
if [Link](b.c, [Link]())
if itrend > 0
CHoCH := true
switch
[Link] := true
txt := "BOS"
css := i_ms_dn_BOS
isdrw := true
drw := [Link](
[Link](),
[Link](),
i_ms_dn_BOS,
txt,
false
)
CHoCH =>
isdrw := true
drw := [Link](
[Link](),
[Link](),
i_ms_dn_BOS.darkcss(0.25, false),
txt,
false
)
if mtf == false
switch
itrend := -1
[Link]()
[Link]()
if trend < 0
CHoCH := true
switch
txt := "BOS"
icss := s_ms_up_BOS
isdrwS := true
drw := [Link](
[Link](),
[Link](),
s_ms_up_BOS,
txt,
true
)
CHoCH =>
isdrwS := true
drw := [Link](
[Link](),
[Link](),
s_ms_up_BOS.darkcss(0.25, true),
txt,
true
)
if mtf == false
switch
trend := 1
[Link]()
[Link]()
if [Link](b.c, [Link]())
bool CHoCH = false
string txt = na
if trend > 0
CHoCH := true
switch
[Link] := true
txt := "BOS"
icss := s_ms_dn_BOS
isdrwS := true
drw := [Link](
[Link](),
[Link](),
s_ms_dn_BOS,
txt,
false
)
CHoCH =>
isdrwS := true
drw := [Link](
[Link](),
[Link](),
s_ms_dn_BOS.darkcss(0.25, false),
txt,
false
)
if mtf == false
switch
trend := -1
[Link]()
[Link]()
[css, bear_ob, bull_ob, itrend, drw, isdrw, s_bear_ob, s_bull_ob, trend, icss,
isdrwS]
[css, bear_ob, bull_ob, itrend, drw, isdrw, s_bear_ob, s_bull_ob, trend, icss,
isdrwS] = structure(false)
if isdrw
f_line(drw, [Link], line.style_dashed)
if isdrwS
f_line(drw, [Link], line.style_solid)
if show_mtf_str
//{ - End
}
//{ - Strong/Weak High/Low And Equilibrium
}
zhl(len)=>
upper = [Link](len)
lower = [Link](len)
var float out = 0
out := b.h[len] > upper ? 0 : b.l[len] < lower ? 1 : out[1]
[top, btm]
upphl(trend) =>
if top
[Link] := true
[Link] := top > [Link] ? "HH" : "HL"
if show_lbl
topl = [Link](
x = b.n - swing_r_lookback,
y = top,
text = [Link],
color = invcol,
textcolor = toplvl,
style = label.style_label_down,
size = [Link]
)
[Link]((phl[1]).top)
[Link] := [Link](
x1 = b.n - sLen,
y1 = top,
x2 = b.n,
y2 = top,
color = toplvl)
[Link] := top
[Link] := b.n - sLen
[Link] := top
[Link] := b.n - sLen
if itop
[Link] := true
[Link] := itop
[Link] := b.n - iLen
[Link] := [Link](high, [Link])
[Link] := [Link] == high ? b.n : [Link]
[Link] := [Link] != [Link][1] ? b.v : [Link]
if [Link]
line.set_xy1(
[Link],
[Link],
[Link]
)
line.set_xy2(
[Link],
b.n + 50,
[Link]
)
label.set_x(
lbl,
b.n + 50
)
label.set_y(
lbl,
[Link]
)
dnphl(trend) =>
if btm
[Link] := true
[Link] := btm > [Link] ? "LH" : "LL"
if show_lbl
btml = [Link](
x = b.n - swing_r_lookback,
y = btm,
text = [Link],
color = invcol,
textcolor = btmlvl,
style = label.style_label_up,
size = [Link]
)
[Link]((phl[1]).bottom)
[Link] := [Link](
x1 = b.n - sLen,
y1 = btm,
x2 = b.n,
y2 = btm,
color = btmlvl
)
[Link] := btm
[Link] := b.n - sLen
[Link] := btm
[Link] := b.n - sLen
if ibtm
[Link] := true
[Link] := ibtm
[Link] := b.n - iLen
if [Link]
line.set_xy1(
[Link],
[Link],
[Link]
)
line.set_xy2(
[Link],
b.n + 50,
[Link]
)
label.set_x(
lbl,
b.n + 50
)
label.set_y(
lbl,
[Link]
)
midphl() =>
if [Link]
hqlzone() =>
if [Link]
[Link].set_lefttop(left=int([Link]([Link], [Link]))
, top=[Link])
[Link].set_rightbottom(right=b.n + 50 ,
bottom=0.95 * [Link] + 0.05 * [Link])
if show_mtb
upphl (trend)
dnphl (trend)
hqlzone()
//{ - End
}
//{ - Volumetric Order Block
}
expression = [
close,
open,
high,
low,
volume
],
lookahead = barmerge.lookahead_off
)
var obC obj = [Link](
[Link]<float>(),
[Link]<float>(),
[Link]< int >(),
[Link]<float>(),
[Link]<float>(),
[Link]<float>(),
[Link]< int >(),
[Link]< int >(),
[Link]< int >(),
[Link]< int >(),
[Link]<float>(),
[Link]<float>(),
[Link]< int >()
)
if [Link]
for i = 0 to ob_num - 1
[Link] .eL(false, false, use_grayscale ? [Link]([Link], 0) :
[Link](css,0))
[Link] .eB(false, use_grayscale ? [Link]([Link], 90) : css,
swing)
[Link](false, css_metric_up ,
swing)
[Link](false, css_metric_dn ,
swing)
[Link](true , use_grayscale ? [Link]([Link], 90) : css,
swing)
if cdn
[Link]()
[Link]()
[Link]()
[Link](hH[i])
[Link](lL[i])
[Link](b.t[i])
// [Link]()
// [Link]()
int iU = [Link]([Link]()) + 1
int iD = [Link]([Link]()) + 1
[Link](
bull
? (b.c[iU] > b.o[iU] ? 1 : -1)
: (b.c[iD] > b.o[iD] ? 1 : -1)
)
[Link](
bull
? pos[iU]
: [Link]()
)
[Link](
bull
? [Link]()
: pos[iD]
)
[Link](
bull
? [Link]([Link]([Link]()))
: [Link]([Link]([Link]()))
)
[Link](
[Link]([Link](), [Link]())
)
[Link](
bull
? b.v[iU]
: b.v[iD]
)
if ob_pos == "Precise"
switch bull
true =>
if [Link](0) < (b.c[iU] < b.o[iU] ? b.c[iU] : b.o[iU]) and
[Link](0) > hlcc4[iU]
[Link](0, [Link](0))
[Link](0, [Link]([Link](), [Link]()))
false =>
if [Link](0) > (b.c[iU] < b.o[iU] ? b.o[iD] : b.c[iD]) and
[Link](0) < hlcc4[iD]
[Link](0, [Link](0))
[Link](0, [Link]([Link](), [Link]()))
[Link] ( 0 )
[Link] ( 0 )
[Link] .unshift ( 1 )
if use_overlap
if [Link]() > 1
if bull
? [Link]() < [Link](1)
: [Link]() > [Link](1)
[Link] .remove(rmP)
[Link] .remove(rmP)
[Link] .remove(rmP)
[Link] .remove(rmP)
[Link] .remove(rmP)
[Link] .remove(rmP)
[Link] .remove(rmP)
[Link] .remove(rmP)
[Link] .remove(rmP)
if [Link]
for x = 0 to ob_num - 1
tg = switch ob_mitigation
"Middle" => [Link]
"Absolute" => bull ? [Link] : [Link]
if [Link]
if [Link]() > 0
// Alert
if bull
? [Link](low , [Link](0))
: [Link] (high, [Link](0))
switch bull
true => [Link] := true
false => [Link] := true
float tV = 0
[Link]()
seq = [Link](ob_num - 1, [Link]() - 1)
for j = 0 to seq
tV += [Link](j)
if j == seq
for y = 0 to seq
[Link](
[Link](
([Link](y) / tV) * 100)
)
[Link]()
if use_middle_line
dmL.set_xy1(x=[Link](i), y=[Link](i))
dmL.set_xy2(x=b.t , y=[Link](i))
if ob_metrics_show
rpBL = dblB.get_right()
rpBR = dbrB.get_right()
dbrB.set_right(rpBR + (b.t - b.t[1]) * [Link](i))
dblB.set_right(rpBL + (b.t - b.t[1]) * [Link](i))
if use_show_metric
txt = switch
deOB.set_text(
[Link](
txt + " (" + [Link]([Link](i)) + "%)")
)
deOB.set_text_size ([Link])
deOB.set_text_halign(text.align_left)
deOB.set_text_color (use_grayscale ? [Link] :
[Link](css, 0))
if [Link]() > 0
for i = 0 to [Link]() - 1
switch [Link](i)
1 =>
switch [Link](i)
switch [Link](i)
if iH
[Link]()
[Link](int(b.n[iLen]))
if iL
[Link]()
[Link](int(b.n[iLen]))
if sH
[Link]()
[Link](int(b.n[sLen]))
if sL
[Link]()
[Link](int(b.n[sLen]))
if ob_show
if ob_swings
if bull_ob
[Link] := true
if bear_ob
[Link] := true
if s_bull_ob
[Link] := true
if s_bear_ob
[Link] := true
//{ - End
}
//{ - FVG | VI | OG
}
[h, l, c, o] = ghl()
[go, gh, gl, gc] = tfG()
float pup = na
float pdn = na
bool cdn = na
int pos = 2
cc = [Link](fvg_tf)
if [Link]
for i = 0 to fvg_num - 1
switch what_fvg
"FVG" =>
pup := bull ? gl : l
pdn := bull ? h : gh
cdn := bull ? gl > h and cc : gh < l and cc
pos := 2
"VI" =>
pup := bull
? (gc > go
? go
: gc)
: (gc[1] > go[1]
? go[1]
: gc[1])
pdn := bull
? (gc[1] > go[1]
? gc[1]
: go[1])
: (gc > go
? gc
: go)
cdn := bull
? go > gc[1] and gh[1] > gl and gc > gc[1] and go > go[1] and
gh[1] < [Link](gc, go) and cc
: go < gc[1] and gl[1] < gh and gc < gc[1] and go < go[1] and
gl[1] > [Link](gc, go) and cc
pos := 1
"OG" =>
[Link](
[Link](
box = na,
ln = na,
bull = bull
? true
: false ,
top = pup[1] ,
btm = pdn[1],
left = b.t - (b.t - b.t[1]) * pos + 1,
right = b.t + (b.t - b.t[1]) * fvg_extend + 1)
)
if bull
[Link] := true
else
[Link] := true
if [Link]
[Link](idx)
if [Link]
if [Link]() > 0
gtop = [Link]
gbtm = [Link]
left = [Link]
right = [Link]
gbx.set_lefttop(left=left, top=gtop)
gbx.set_rightbottom(right=right, bottom=gbtm)
gbx.set_bgcolor([Link] ? fvg_upcss : fvg_dncss)
if fvg_enable
cG(true )
cG(false)
//{ - END
}
//{ - Accumulation And Distribution
}
drawZone(int len) =>
var zone[] z = [Link]<zone>()
if iH
[Link](
[Link](
points = [Link].from_time(
time[len],
high [len]
),
p = high [len],
c = 1,
t = time[len]
)
)
if iL
[Link](
[Link](
points = [Link].from_time(
time[len],
low [len]
),
p = low [len],
c = -1,
t = time[len]
)
)
if [Link]() > 1
if [Link](0).c == [Link](1).c
[Link]()
switch
if [Link]() > 5
[Link] := true
for i = 0 to 5
[Link]([Link](i).points)
if [Link]() > 5
[Link] := true
for i = 0 to 5
[Link]([Link](i).points)
if [Link]() > 3
[Link] := true
for i = 0 to 3
[Link]([Link](i).points)
if [Link]() > 3
[Link] := true
for i = 0 to 3
[Link]([Link](i).points)
drawZone(iLen)
//{ - END
}
//{ - EQH / EQL
}
dEHL() =>
switch
top =>
mx = [Link](top, [Link])
mn = [Link](top, [Link])
switch
var aZ = [Link]<line>()
var aL = [Link]<label>()
if [Link]() > 50
[Link]().delete()
[Link]().delete()
[Link] := true
[Link] := top
w.t := b.n - 1
btm =>
mx = [Link](btm, [Link])
mn = [Link](btm, [Link])
switch
var aZ = [Link]<line>()
var aL = [Link]<label>()
if [Link]() > 50
[Link]().delete()
[Link]().delete()
[Link] := true
[Link] := btm
w.b := b.n - 1
if show_eql
dEHL()
//{ - End
}
//{ - Plotting And Coloring
}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
p_css = css
b_css = css
w_css = css
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//{ - END
}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
alertcondition([Link] , "Bullish BOS", "Bullish BOS")
alertcondition([Link] , "Bullish CHOCH", "Bullish CHOCH")
alertcondition([Link] , "Bullish CHOCH+", "Bullish CHOCH+")
alertcondition([Link], "Bullish Swing CHOCH+", "Bullish Swing
CHOCH+")
alertcondition([Link] , "Bullish Swing CHOCH", "Bullish CHOCH")
alertcondition([Link] , "Bullish Swing BOS", "Bullish Swing BOS")
alertcondition([Link] , "EQL", "EQL")
alertcondition([Link] , "Bullish FVG", "Bullish FVG")
alertcondition([Link] , "Bullish Order Block", "Bullish Order
Block")
alertcondition([Link] , "Bullish Swing Order Block", "Bullish Swing
Order Block")
alertcondition([Link] , "Accumulation Zone", "Accumulation Zone")
alertcondition([Link] , "Candle Entering in a Bullish Order Block",
"Candle Entering in a Bullish Order Block")
longSignal = [Link]
shortSignal = [Link]
if longSignal
[Link](bar_index, low, "LONG", color=[Link],
style=label.style_label_up, textcolor=[Link])
if shortSignal
[Link](bar_index, high, "SHORT", color=[Link],
style=label.style_label_down, textcolor=[Link])