Price Action Concepts (StratifyTrade)
Price Action Concepts (StratifyTrade)
0
International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
//TELEGRAM ==> https://t.me/+UAk3hqvoD89jZTlk
//@version=5
indicator("Price Action Concepts [StratifyTrade]", shorttitle = "Price Action
Concepts [1.2.1]", overlay = true, max_lines_count = 500, max_labels_count = 500,
max_boxes_count = 500, max_bars_back = 500, max_polylines_count = 100)
//-----------------------------------------------------------------------------{
//Boolean set
//-----------------------------------------------------------------------------{
s_BREAK = 0
s_CHANGE = 1
i_BREAK = 2
i_CHANGE = 3
i_pp_CHANGE = 4
green_candle = 5
red_candle = 6
s_CHANGEP = 7
i_CHANGEP = 8
boolean =
array.from(
false
, false
, false
, false
, false
, false
, false
, false
, false
)
//-----------------------------------------------------------------------------{
// User inputs
//-----------------------------------------------------------------------------{
t = color.t (ob_bull_css)
invcol = color.new (color.white
, 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
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
chart.point 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
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//{ - End
}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//{ - General Setup
}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
bar b = bar.new()
var pattern p = pattern.new()
if p.isfound
p.period += 1
if p.period == 50
p.period := 0
p.found := "None"
p.isfound := false
p.bull := na
switch
if ms_mode == "Dynamic"
switch
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//{ - End
}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//{ - ARRAYS
}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
lstyle(style) =>
hy = ta.valuewhen(h != h[1] , h , 1)
hx = ta.valuewhen(h == high , time , 1)
ly = ta.valuewhen(l != l[1] , l , 1)
lx = ta.valuewhen(l == low , time , 1)
if barstate.islast
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 := line.new(
d.n
, d.p
, b.n
, d.p
, color = d.css
, width = 1
, style = style
)
line.delete(msline.shift())
msline.push(id)
lbl := label.new(
int(math.avg(d.n, b.n))
, d.p
, d.txt
, color = invcol
, textcolor = d.css
, style = d.bull ? label.style_label_down : label.style_label_up
, size = size
, text_font_family = font.family_monospace
)
msDraw drw = na
n = bar_index
var ms up = ms.new(
array.new<float>()
, array.new< int >()
, array.new<float>()
)
var ms dn = ms.new(
array.new<float>()
, array.new< int >()
, array.new<float>()
)
switch show_swing_ms
switch show_internal_ms
switch
iH =>
up.p.unshift(b.h[iLen])
up.l.unshift(b.h[iLen])
up.n.unshift(n [iLen])
iL =>
dn.p.unshift(b.l[iLen])
dn.l.unshift(b.l[iLen])
dn.n.unshift(n [iLen])
sL =>
sdn.p.unshift(b.l[sLen])
sdn.l.unshift(b.l[sLen])
sdn.n.unshift(n [sLen])
sH =>
sup.p.unshift(b.h[sLen])
sup.l.unshift(b.h[sLen])
sup.n.unshift(n [sLen])
if ta.crossover(b.c, up.p.first())
bool CHANGE = na
string txt = na
if itrend < 0
CHANGE := true
switch
not CHANGE =>
txt := "BREAK"
css := i_ms_up_BREAK
blalert.bos := true
isdrw := true
drw := msDraw.new(
up.n.first()
, up.p.first()
, i_ms_up_BREAK
, txt
, true
)
CHANGE =>
isdrw := true
drw := msDraw.new(
up.n.first()
, up.p.first()
, i_ms_up_BREAK.darkcss(0.25, true)
, txt
, true
)
if mtf == false
switch
itrend := 1
up.n.clear()
up.p.clear()
bool CHANGE = na
string txt = na
if itrend > 0
CHANGE := true
switch
bralert.bos := true
txt := "BREAK"
css := i_ms_dn_BREAK
isdrw := true
drw := msDraw.new(
dn.n.first()
, dn.p.first()
, i_ms_dn_BREAK
, txt
, false
)
CHANGE =>
isdrw := true
drw := msDraw.new(
dn.n.first()
, dn.p.first()
, i_ms_dn_BREAK.darkcss(0.25, false)
, txt
, false
)
if mtf == false
switch
itrend := -1
dn.n.clear()
dn.p.clear()
if ta.crossover(b.c, sup.p.first())
bool CHANGE = na
string txt = na
if trend < 0
CHANGE := true
switch
blalert.swingbos := true
txt := "BREAK"
icss := s_ms_up_BREAK
isdrwS := true
drw := msDraw.new(
sup.n.first()
, sup.p.first()
, s_ms_up_BREAK
, txt
, true
)
CHANGE =>
isdrwS := true
drw := msDraw.new(
sup.n.first()
, sup.p.first()
, s_ms_up_BREAK.darkcss(0.25, true)
, txt
, true
)
if mtf == false
switch
trend := 1
sup.n.clear()
sup.p.clear()
if ta.crossunder(b.c, sdn.p.first())
bool CHANGE = na
string txt = na
if trend > 0
CHANGE := true
switch
bralert.swingbos := true
txt := "BREAK"
icss := s_ms_dn_BREAK
isdrwS := true
drw := msDraw.new(
sdn.n.first()
, sdn.p.first()
, s_ms_dn_BREAK
, txt
, false
)
CHANGE =>
isdrwS := true
drw := msDraw.new(
sdn.n.first()
, sdn.p.first()
, s_ms_dn_BREAK.darkcss(0.25, false)
, txt
, false
)
if mtf == false
switch
ob_filter == "None"
=> s_bear_ob := true
ob_filter == "BREAK" and txt == "BREAK" =>
s_bear_ob := true
ob_filter == "CHANGE" and txt == "CHANGE" =>
s_bear_ob := true
ob_filter == "CHANGE+" and txt == "CHANGE+" =>
s_bear_ob := true
trend := -1
sdn.n.clear()
sdn.p.clear()
[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, size.small, line.style_dashed)
if isdrwS
f_line(drw, size.small, line.style_solid)
if show_mtf_str
var tab = table.new(position = position.top_right, columns = 10, rows = 10,
bgcolor = na, frame_color = color.rgb(54, 58, 69, 0), frame_width = 1, border_color
= color.rgb(54, 58, 69, 100), border_width = 1)
table.cell(tab, 0, 1, text = "15" , text_color = color.silver, text_halign =
text.align_center, text_size = size.normal, bgcolor = chart.bg_color,
text_font_family = font.family_monospace, width = 2)
table.cell(tab, 0, 2, text = "1H" , text_color = color.silver, text_halign =
text.align_center, text_size = size.normal, bgcolor = chart.bg_color,
text_font_family = font.family_monospace, width = 2)
table.cell(tab, 0, 3, text = "4H" , text_color = color.silver, text_halign =
text.align_center, text_size = size.normal, bgcolor = chart.bg_color,
text_font_family = font.family_monospace, width = 2)
table.cell(tab, 0, 4, text = "1D" , text_color = color.silver, text_halign =
text.align_center, text_size = size.normal, bgcolor = chart.bg_color,
text_font_family = font.family_monospace, width = 2)
table.merge_cells(tab, 0, 5, 1, 5)
table.merge_cells(tab, 0, 6, 1, 6)
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//{ - End
}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//{ - Strong/Weak High/Low And Equilibrium
}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
zhl(len)=>
upper = ta.highest(len)
lower = ta.lowest(len)
[top, btm]
if top
phl.stopcross := true
phl.txtup := top > phl.topy ? "HH" : "HL"
if show_lbl
topl = label.new(
b.n - swing_r_lookback
, top
, phl.txtup
, color = invcol
, textcolor = toplvl
, style = label.style_label_down
, size = size.small
)
line.delete(phl.top[1])
phl.top := line.new(
b.n - sLen
, top
, b.n
, top
, color = toplvl)
phl.topy := top
phl.topx := b.n - sLen
phl.tup := top
phl.tupx := b.n - sLen
if itop
phl.itopcross := true
phl.itopy := itop
phl.itopx := b.n - iLen
phl.tup := math.max(high, phl.tup)
phl.tupx := phl.tup == high ? b.n : phl.tupx
if barstate.islast
line.set_xy1(
phl.top
, phl.tupx
, phl.tup
)
line.set_xy2(
phl.top
, b.n + 50
, phl.tup
)
label.set_x(
lbl
, b.n + 50
)
label.set_y(
lbl
, phl.tup
)
dnphl(trend) =>
if btm
phl.sbottomcross := true
phl.txtdn := btm > phl.bottomy ? "LL" : "LH"
if show_lbl
btml = label.new(
b.n - swing_r_lookback
, btm, phl.txtdn
, color = invcol
, textcolor = btmlvl
, style = label.style_label_up
, size = size.small
)
line.delete(phl.bottom[1])
phl.bottom := line.new(
b.n - sLen
, btm
, b.n
, btm
, color = btmlvl
)
phl.bottomy := btm
phl.bottomx := b.n - sLen
phl.tdn := btm
phl.tdnx := b.n - sLen
if ibtm
phl.ibottomcross := true
phl.ibottomy := ibtm
phl.ibottomx := b.n - iLen
if barstate.islast
line.set_xy1(
phl.bottom
, phl.tdnx
, phl.tdn
)
line.set_xy2(
phl.bottom
, b.n + 50
, phl.tdn
)
label.set_x(
lbl
, b.n + 50
)
label.set_y(
lbl
, phl.tdn
)
midphl() =>
if barstate.islast
hqlzone() =>
if barstate.islast
if show_mtb
upphl (trend)
dnphl (trend)
hqlzone()
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//{ - End
}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//{ - Volumetric Order Block
}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
method drawVOB(bool cdn, bool bull, color css, int loc) =>
, [
close
, open
, high
, low
, volume
, lookahead = barmerge.lookahead_off
)
var obC obj = obC.new(
array.new<float>()
, array.new<float>()
, array.new< int >()
, array.new<float>()
, array.new<float>()
, array.new<float>()
, array.new< int >()
, array.new< int >()
, array.new< int >()
, array.new< int >()
, array.new<float>()
, array.new<float>()
, array.new< int >()
)
if barstate.isfirst
for i = 0 to ob_num - 1
if cdn
obj.h.clear()
obj.l.clear()
obj.n.clear()
obj.h.unshift(hH[i])
obj.l.unshift(lL[i])
obj.n.unshift(b.t[i])
int iU = obj.l.indexof(obj.l.min())
int iD = obj.h.indexof(obj.h.max())
obj.dir.unshift(
bull
? (b.c[iU] > b.o[iU] ? 1 : -1)
: (b.c[iD] > b.o[iD] ? 1 : -1)
)
obj.top.unshift(
bull
? (
math.avg(
obj.h.max(), obj.l.min()) > obj.h.get(iU)
? obj.h.get(iU)
: math.avg(obj.h.max(), obj.l.min())
)
: obj.h.max()
)
obj.btm.unshift(
bull
? obj.l.min()
: (
math.avg(
obj.h.max(), obj.l.min()) < obj.l.get(iD)
? obj.l.get(iD)
: math.avg(obj.h.max(), obj.l.min())
)
)
obj.left.unshift(
bull
? obj.n.get(obj.l.indexof(obj.l.min()))
: obj.n.get(obj.h.indexof(obj.h.max()))
)
obj.avg.unshift(
math.avg(obj.top.first(), obj.btm.first())
)
obj.cV.unshift(
bull
? b.v[iU]
: b.v[iD]
)
obj.blVP.unshift ( 0 )
obj.brVP.unshift ( 0 )
obj.wM .unshift ( 1 )
if use_overlap
if obj.avg.size() > 1
if bull
if barstate.isconfirmed
for x = 0 to ob_num - 1
tg = switch ob_mitigation
"Middle" => obj.avg
"Absolute" => bull ? obj.btm : obj.top
if barstate.islast
if obj.avg.size() > 0
float tV = 0
obj.dV.clear()
seq = math.min(ob_num - 1, obj.avg.size() - 1)
for j = 0 to seq
tV += obj.cV.get(j)
if j == seq
for y = 0 to seq
obj.dV.unshift(
math.floor(
(obj.cV.get(y) / tV) * 100)
)
if use_middle_line
dmL.set_xy1(obj.left.get(i), obj.avg.get(i))
dmL.set_xy2(b.t , obj.avg.get(i))
if ob_metrics_show
rpBL = dblB.get_right()
rpBR = dbrB.get_right()
dbrB.set_right(rpBR + (b.t - b.t[1]) * obj.brVP.get(i))
dblB.set_right(rpBL + (b.t - b.t[1]) * obj.blVP.get(i))
if use_show_metric
txt = switch
deOB.set_text(
str.tostring(
txt + " (" + str.tostring(obj.dV.get(i)) + "%)")
)
deOB.set_text_size (size.auto)
deOB.set_text_halign(text.align_left)
deOB.set_text_color (use_grayscale ? color.rgb(255, 255, 255) :
color.new(css, 0))
if obj.wM.size() > 0
for i = 0 to obj.avg.size() - 1
switch obj.dir.get(i)
1 =>
switch obj.wM.get(i)
1 => obj.blVP.set(i, obj.blVP.get(i) + 1),
obj.wM.set(i, 2)
2 => obj.blVP.set(i, obj.blVP.get(i) + 1),
obj.wM.set(i, 3)
3 => obj.brVP.set(i, obj.brVP.get(i) + 1),
obj.wM.set(i, 1)
-1 =>
switch obj.wM.get(i)
if iH
hN.pop()
hN.unshift(int(b.n[iLen]))
if iL
lN.pop()
lN.unshift(int(b.n[iLen]))
if sH
hS.pop()
hS.unshift(int(b.n[sLen]))
if sL
lS.pop()
lS.unshift(int(b.n[sLen]))
if ob_show
if ob_swings
if bull_ob
blalert.ob := true
if bear_ob
bralert.ob := true
if s_bull_ob
blalert.swingob := true
if s_bear_ob
blalert.swingob := 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
change_tf = timeframe.change(fvg_tf)
if barstate.isfirst
for i = 0 to fvg_num - 1
draw.box.unshift(box.new (na, na, na, na, border_color =
color.new(color.white, 100), xloc = xloc.bar_time))
draw.ln.unshift (line.new(na, na, na, na, xloc = xloc.bar_time, width =
1, style = line.style_solid))
switch what_fvg
"FVG" =>
pup := bull ? gl : l
pdn := bull ? h : gh
cdn := bull ? gl > h and change_tf : gh < l and change_tf
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] < math.min(gc, go) and change_tf
: go < gc[1] and gl[1] < gh and gc < gc[1] and go < go[1] and
gl[1] > math.max(gc, go) and change_tf
pos := 1
"OG" =>
cords.unshift(
FVG.new(
na
, na
, bull
? true
: false
, pup
, pdn
, b.t - (b.t - b.t[1]) * pos
, b.t + (b.t - b.t[1]) * fvg_extend)
)
if bull
blalert.fvg := true
else
bralert.fvg := true
if barstate.isconfirmed
cords.remove(idx)
if barstate.islast
if cords.size() > 0
gbx = draw.box.get(i)
gln = draw.ln.get(i)
gcd = cords.get(i)
gtop = gcd.top
gbtm = gcd.btm
left = gcd.left
right = gcd.right
gbx.set_lefttop(left, gtop)
gbx.set_rightbottom(right, gbtm)
gbx.set_bgcolor(gcd.bull ? fvg_upcss : fvg_dncss)
if fvg_enable
cG(true )
cG(false)
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//{ - END
}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//{ - Accumulation And Distribution
}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
if iH
z.unshift(
zone.new(
chart.point.from_time(
time[len]
, high[len]
)
, high[len]
, 1
, time[len]
)
)
if iL
z.unshift(
zone.new(
chart.point.from_time(
time[len]
, low [len]
)
, low [len]
, -1
, time[len]
)
)
if z.size() > 1
if z.get(0).c == z.get(1).c
z.clear()
switch
if z.size() > 5
blalert.zone := true
for i = 0 to 5
slice.unshift(z.get(i).points)
if z.size() > 5
bralert.zone := true
for i = 0 to 5
slice.unshift(z.get(i).points)
if z.size() > 3
blalert.zone := true
for i = 0 to 3
slice.unshift(z.get(i).points)
if z.size() > 3
bralert.zone := true
for i = 0 to 3
slice.unshift(z.get(i).points)
if show_acc_dist_zone
drawZone(iLen)
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//{ - END
}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//{ - EQH / EQL
}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
dEHL() =>
switch
top =>
mx = math.max(top, w.pt)
mn = math.min(top, w.pt)
switch
var aZ = array.new<line>()
var aL = array.new<label>()
if aZ.size() > 50
aZ.pop().delete()
aL.pop().delete()
bralert.equal := true
w.pt := top
w.t := b.n - 1
btm =>
mx = math.max(btm, w.pb)
mn = math.min(btm, w.pb)
switch
mn > mx - atr * 0.1 =>
var aZ = array.new<line>()
var aL = array.new<label>()
if aZ.size() > 50
aZ.pop().delete()
aL.pop().delete()
blalert.equal := true
w.pb := btm
w.b := b.n - 1
if show_eql
dEHL()
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//{ - End
}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//{ - Plotting And Coloring
}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
p_css = css
b_css = css
w_css = css
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//{ - END
}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
if barstate.isfirst
var table errorBox = table.new(position.bottom_right, 1, 1, bgcolor =
color.new(#363a45, 100))
table.cell(errorBox, 0, 0, "© Stratify", text_color = color.gray,
text_halign = text.align_center, text_size = size.normal)
// This source code is subject to the terms of the Mozilla Public License 2.0 at
https://mozilla.org/MPL/2.0/
// © zizou
//@version=5
//// indicator("zizou's Garbage Algo - ", overlay = true)
// Trend Features
LongTrendAverage = input(false, 'Trend Cloud', group='TREND FEATURES')
TrendFollower = input(false, 'Trend Follower', group='TREND FEATURES')
ShowComulus = input(false, 'Comulus Cloud', group='TREND FEATURES')
CirrusCloud = input(false, 'Cirrus Cloud', group='TREND FEATURES')
// Risk Management
// Signal Generation
supertrend(_close, factor, atrLen) =>
atr = ta.atr(atrLen)
upperBand = _close + factor * atr
lowerBand = _close - factor * atr
prevLowerBand = nz(lowerBand[1])
prevUpperBand = nz(upperBand[1])
lowerBand := lowerBand > prevLowerBand or close[1] < prevLowerBand ?
lowerBand : prevLowerBand
upperBand := upperBand < prevUpperBand or close[1] > prevUpperBand ?
upperBand : prevUpperBand
int direction = na
float superTrend = na
prevSuperTrend = superTrend[1]
if na(atr[1])
direction := 1
else if prevSuperTrend == prevUpperBand
direction := close > upperBand ? -1 : 1
else
direction := close < lowerBand ? 1 : -1
superTrend := direction == -1 ? lowerBand : upperBand
[superTrend, direction]
// SMA
ocAvg = math.avg(open, close)
sma4 = ta.sma(close, 8)
sma5 = ta.sma(close, 9)
sma9 = ta.sma(close, 13)
psar = ta.sar(0.02, 0.02, 0.2)
// Colors
green = #68b4d0, green2 = #68b4d0
red = #d18c6e, red2 = #d18c6e
adxlen = 15
dilen = 15
dirmov(len) =>
up = ta.change(high)
down = -ta.change(low)
plusDM = na(up) ? na : up > down and up > 0 ? up : 0
minusDM = na(down) ? na : down > up and down > 0 ? down : 0
truerange = ta.rma(ta.tr, len)
plus = fixnan(100 * ta.rma(plusDM, len) / truerange)
minus = fixnan(100 * ta.rma(minusDM, len) / truerange)
[plus, minus]
adx(dilen, adxlen) =>
[plus, minus] = dirmov(dilen)
sum = plus + minus
adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
adx
sig = adx(dilen, adxlen)
// High Lows
y3 = low - (ta.atr(30) * 2), y1B = low - ta.atr(30)
y4 = high + (ta.atr(30) * 2), y2B = high + ta.atr(30)
// Plots
windowsize = 100
offset = 0.9
sigma = 6
//plot(ta.alma(source, windowsize, offset, sigma))
windowsize2 = 310
offset2 = 0.85
sigma2 = 32
//plot(ta.alma(source, windowsize2, offset2, sigma2))
// Chart Features
smoothrng(x, t, m) =>
wper = t * 2 - 1
avrng = ta.ema(math.abs(x - x[1]), t)
smoothrng = ta.ema(avrng, wper) * m
smoothrng
smrng = smoothrng(close, 22, 6)
rngfilt(x, r) =>
rngfilt = x
rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r
: x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r
rngfilt
filt = rngfilt(close, smrng)
//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
upward = 0.0
upward := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1])
downward = 0.0
downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 :
nz(downward[1])
// Trend Cloud
tclength = 600
hullma = ta.wma(2*ta.wma(close, tclength/2)-ta.wma(close, tclength),
math.floor(math.sqrt(tclength)))
plot(LongTrendAverage ? hullma : na, 'Trend Cloud', linewidth=4, color=close[8] >
hullma ? color.new(#00e2ff, 65) : color.new(#fe0100, 65))
// Comulus Cloud
candle = ta.alma(source, windowsize2, offset2, sigma2)
reach = ta.alma(source, windowsize, offset, sigma)
candlep = plot(ShowComulus ? candle : na, color=color.new(color.white, 100))
reachp = plot(ShowComulus ? reach : na, color=color.new(color.white, 100))
fill(reachp, candlep, color= candle > reach ? color.new(#fe0100, 85) :
color.new(#00e2ff, 85))
// Chart Features
x3 = 22
x4 = 9
x5 = 15
x6 = 5
smoothrngX1(x, t, m) =>
wper = t * 2 - 1
avrng = ta.ema(math.abs(x - x[1]), t)
smoothrngX1 = ta.ema(avrng, wper) * m
smoothrngX1
smrngx1x = smoothrngX1(close, x3, x4)
smrngx1x2 = smoothrngX1(close, x5, x6)
rngfiltx1x1(x, r) =>
rngfiltx1x1 = x
rngfiltx1x1 := x > nz(rngfiltx1x1[1]) ? x - r < nz(rngfiltx1x1[1]) ?
nz(rngfiltx1x1[1]) : x - r : x + r > nz(rngfiltx1x1[1]) ? nz(rngfiltx1x1[1]) : x +
r
rngfiltx1x1
filtx1 = rngfiltx1x1(close, smrngx1x)
filtx12 = rngfiltx1x1(close, smrngx1x2)
//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
upwardx1 = 0.0
upwardx1 := filtx1 > filtx1[1] ? nz(upwardx1[1]) + 1 : filtx1 < filtx1[1] ? 0 :
nz(upwardx1[1])
downwardx1 = 0.0
downwardx1 := filtx1 < filtx1[1] ? nz(downwardx1[1]) + 1 : filtx1 > filtx1[1] ? 0 :
nz(downwardx1[1])
buy = bull and nbuysell ? label.new(bar_index, y3, sma4 >= sma5 ? "Strong Buy" :
"Buy", xloc.bar_index, yloc.price, #68b4d0, label.style_label_up, color.white,
size.normal) : na
sell = bear and nbuysell ? label.new(bar_index, y4, sma4 <= sma5 ? "Strong Sell" :
"Sell", xloc.bar_index, yloc.price, #d18c6e, label.style_label_down, color.white,
size.normal) : na
// Other initializations
avg_volume = ta.sma(volume, 20)
very_weak_multiplier = 0.5
weak_multiplier = 1
strong_multiplier = 1.5
// Rejection handling
var int[] demandRejections = array.new_int(history_of_demand_to_keep, 0)
var int[] supplyRejections = array.new_int(history_of_demand_to_keep, 0)
var int[] demandCreationBars = array.new_int(history_of_demand_to_keep, na)
var int[] supplyCreationBars = array.new_int(history_of_demand_to_keep, na)
f_check_demand_rejections() =>
for i = 0 to history_of_demand_to_keep - 1
if not na(array.get(demandCreationBars, i))
if bar_index - array.get(demandCreationBars, i) > 15 and bar_index -
array.get(demandCreationBars, i) % 15 == 0
label.new(bar_index, high, "Checking demand rejection",
color=color.red)
dBox = array.get(current_demand_box, i)
if (na(dBox))
continue
withinBox = (high >= box.get_bottom(dBox) and high <=
box.get_top(dBox)) or (close >= box.get_bottom(dBox) and close <=
box.get_top(dBox))
bearishCandlesCount = math.sum(close < open ? 1 : 0, 15)
if withinBox and bearishCandlesCount >= 7
label.new(bar_index, low, "Bearish count > 7",
color=color.blue)
array.set(demandRejections, i, array.get(demandRejections, i) +
1)
f_check_supply_rejections() =>
for i = 0 to history_of_demand_to_keep - 1
if not na(array.get(supplyCreationBars, i))
if bar_index - array.get(supplyCreationBars, i) > 15 and bar_index -
array.get(supplyCreationBars, i) % 15 == 0
label.new(bar_index, low, "Checking supply rejection",
color=color.red)
sBox = array.get(current_supply_box, i)
if (na(sBox))
continue
withinBox = (low <= box.get_top(sBox) and low >=
box.get_bottom(sBox)) or (close <= box.get_top(sBox) and close >=
box.get_bottom(sBox))
bullishCandlesCount = math.sum(close > open ? 1 : 0, 15)
if withinBox and bullishCandlesCount >= 7
label.new(bar_index, high, "Bullish count > 7",
color=color.blue)
array.set(supplyRejections, i, array.get(supplyRejections, i) +
1)
f_extend_box_endpoint(box_array) =>
for i = 0 to array.size(box_array) - 1
box.set_right(array.get(box_array, i), bar_index + 30) // Extend only 20
bars
atr567 = ta.atr(50)
swing_high = ta.pivothigh(high, swing_length, swing_length)
swing_low = ta.pivotlow(low, swing_length, swing_length)
var swing_high_values = array.new_float(5,0.00)
var swing_low_values = array.new_float(5,0.00)
var swing_high_bns = array.new_int(5,0)
var swing_low_bns = array.new_int(5,0)
var current_supply_poi = array.new_box(history_of_demand_to_keep, na)
var current_demand_poi = array.new_box(history_of_demand_to_keep, na)
var supply_bos = array.new_box(5, na)
var demand_bos = array.new_box(5, na)
if not na(swing_high)
f_array_add_pop(swing_high_values, swing_high)
f_array_add_pop(swing_high_bns, bar_index[swing_length])
if show_price_action_labels
f_sh_sl_labels(swing_high_values, 1)
f_supply_demand(swing_high_values, swing_high_bns, current_supply_box,
current_supply_poi, 1, atr567)
else if not na(swing_low)
f_array_add_pop(swing_low_values, swing_low)
f_array_add_pop(swing_low_bns, bar_index[swing_length])
if show_price_action_labels
f_sh_sl_labels(swing_low_values, -1)
f_supply_demand(swing_low_values, swing_low_bns, current_demand_box,
current_demand_poi, -1, atr567)
f_sd_to_bos(current_supply_box, supply_bos, current_supply_poi, 1)
f_sd_to_bos(current_demand_box, demand_bos, current_demand_poi, -1)
f_extend_box_endpoint(current_supply_box)
f_extend_box_endpoint(current_demand_box)
// Inside the main execution, after the box is drawn, check for rejections
if not na(swing_low)
f_array_add_pop(swing_low_values, swing_low)
f_array_add_pop(swing_low_bns, bar_index[swing_length])
if show_price_action_labels
f_sh_sl_labels(swing_low_values, -1)
f_supply_demand(swing_low_values, swing_low_bns, current_demand_box,
current_demand_poi, -1, atr567)
f_check_demand_rejections()
if not na(swing_high)
f_array_add_pop(swing_high_values, swing_high)
f_array_add_pop(swing_high_bns, bar_index[swing_length])
if show_price_action_labels
f_sh_sl_labels(swing_high_values, 1)
f_supply_demand(swing_high_values, swing_high_bns, current_supply_box,
current_supply_poi, 1, atr567)
f_check_supply_rejections()
trigger2 = bull ? 1 : 0
countBull = ta.barssince(bull)
countBear = ta.barssince(bear)
trigger = nz(countBull, bar_index) < nz(countBear, bar_index) ? 1 : 0
atrBand = ta.atr(atrLen) * atrRisk
atrStop = trigger == 1 ? low - atrBand : high + atrBand
stop_y = lastTrade(atrStop)
stop = levels ? label.new(time, close, "SL " + str.tostring(stop_y, decimals),
xloc.bar_time, yloc.price, red2, label.style_label_left, color.white,
size.normal) : na
label.set_x(stop, label.get_x(stop) + math.round(ta.change(time) * lvlDistance))
label.set_y(stop, stop_y)
label.delete(stop[1])
//import protradingart/pta_plot/6 as pp
//pp.peakprofit(bull, bear)