PunkChainer™ Price Action Concepts [? PunkAlgo 4.0]
PunkChainer™ Price Action Concepts [? PunkAlgo 4.0]
0
International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © PunkAlgo - formerly know as PunkAlgo
//@version=5
indicator("PunkChainer™ Price Action Concepts [🧊 PunkAlgo 4.0]", shorttitle =
"PunkAlgo - Price Action Concepts [1.0]", overlay = true, max_lines_count = 500,
max_labels_count = 500, max_boxes_count = 500, max_bars_back = 500,
max_polylines_count = 100)
// Liquidity Concepts
lookback = input.int(12,"Pivot Point Length",minval = 2,group = "🧊 Liquidity
Concepts")
liq_valid = input.int(7,"Liquidation Validity",minval = 1,tooltip = "Measure how
many candles should max pass to count as liquidity. Ex: if set to 7, the
liquidation should happen in those 7 bars; otherwise, it is not valid.",inline =
"AA",group = "Inputs")
liq_bool = input.bool(true,"Use Pivot Length",inline = "AA",group = "🧊 Liquidity
Concepts")
switch liq_bool
true => liq_valid := lookback
false => na
=> liq_valid
HH_css = input.color(color.white, "HH & HL", inline = "HHLL2", group = "🧊 Liquidity
Concepts")
LL_css = input.color(color.gray , "LL & LH", inline = "HHLL2", group = "🧊 Liquidity
Concepts")
transline = 0
switch show_liq
true => major_trans := 100, minor_trans := 100
false => na
type barLiq
float o = open
float h = high
float l = low
float c = close
float v = volume
int idx = bar_index
int t = time
// type col
// color gray = color.gray
// color black = color.black
// color green = color.green
// color red = color.red
// color blue = color.blue
// color purpl1e = color.purpl1e
// color ared = #e60000
// color ablue = #3366ff
// color inv = #ffffff00
type zBin
float[] LH
float[] HL
float[] LL
float[] HH
int[] LHindex
int[] HLindex
int[] LLindex
int[] HHindex
float[] LHchoch
float[] HLchoch
float[] LLchoch
float[] HHchoch
int[] LHchochIndex
int[] HLchochIndex
int[] LLchochIndex
int[] HHchochIndex
float[] _popl1H
int[] _popl1Hidx
array.new<float>()
, 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<float>()
, array.new<float>()
, array.new<int>()
, array.new<int>()
, array.new<int>()
, array.new<int>()
, array.new<float>()
, array.new<int>()
barLiq = barLiq.new()
// col = col.new()
var int itrendLiq = 0
f_drawLine(x1, y1, x2, y2, color, widh, bBar, txt, down, dashed,transline) =>
var line id = na
line.set_color(id, color.new(color,transline))
line.set_width(id, widh)
// && => HH LL LH
isNot() =>
float a = na
float b = na
float c = na
float d = na
float e = na
if not na(hl)
[loc1, loc2, loc3, loc4] = findprevious()
a := zz
b := loc1
c := loc2
d := loc3
e := loc4
e
float res = na
float sup = na
res := _lh ? zz : res[1]
sup := _hl ? zz : sup[1]
int trendLiq = na
iff_3 = close < sup ? -1 : nz(trendLiq[1])
trendLiq := close > res ? 1 : iff_3
//table int
if _hh
id = show_pivot ? na : label.new(barLiq.idx[lookback], barLiq.h[lookback], text
= "HH", style = label.style_label_down, size = lbl_t, color = colinv, textcolor =
HH_css)
bin.HH.push(barLiq.h[lookback])
bin.HHindex.push(barLiq.idx[lookback])
bxHHchOchPoint.push(barLiq.h[1])
if bin.HH.size() > 0
if barLiq.idx % (lookback * 2) == 0
bin.HHchoch.push(bin.HH.pop())
bin.HHchochIndex.push(bin.HHindex.pop())
if bin.HH.size() > 0
for j = 0 to bin.HH.size()
if bin.HH.size() <= 0
break
else
var _poph1H = array.new<float>()
var _poph1Hidx = array.new<int>()
var int barLiqsince = ta.barssince(ta.crossunder(barLiq.c,
bin.HH.last()))
if ta.crossover(barLiq.h, bin.HH.last())
bool choch = false
if itrendLiq < 0
choch := true
txt = choch ? "" : ""
_poph1H.push(bin.HH.pop())
_poph1Hidx.push(bin.HHindex.pop())
if math.abs(_poph1Hidx.last() - barLiq.idx) > 500
break
else
col = choch ? CHOCH_bull_css : BOS_bull_css
itrendLiq := 1
tot_structure_bull += 1
if bin.HHchoch.size() > 0
for j = 0 to bin.HHchoch.size()
if bin.HHchoch.size() <= 0
break
else
var _poph1Hchoch = array.new<float>()
var _poph1HchochIndex = array.new<int>()
if ta.crossover(barLiq.c, bin.HHchoch.last())
bool choch = false
if itrendLiq < 0
choch := true
txt = choch ? "" : ""
_poph1Hchoch.push(bin.HHchoch.pop())
_poph1HchochIndex.push(bin.HHchochIndex.pop())
if math.abs(_poph1HchochIndex.last() - barLiq.idx) > 500
break
else
col = choch ? CHOCH_bull_css : BOS_bull_css
f_drawLine(_poph1HchochIndex.last(), _poph1Hchoch.last(),
barLiq.idx, _poph1Hchoch.last(), col, 1, barLiq.idx, txt, true, txt == "" ? true :
false, transline)
itrendLiq := 1
tot_structure_bull += 1
if bxHHchOchPoint.size() > 0
barLiqsince = ta.barssince(ta.crossover(barLiq.h ,bxHHchOchPoint.last()))
var float lastLvl = na
var int index = na
if ta.crossover(barLiq.h, bxHHchOchPoint.last())
lastLvl := bxHHchOchPoint.last()
index := barLiq.idx[1]
if _ll
id = show_pivot ? na : label.new(barLiq.idx[lookback], barLiq.l[lookback], text
= "LL", style = label.style_label_up, size = lbl_t, color = colinv, textcolor =
LL_css)
bin.LL.push(barLiq.l[lookback])
bin.LLindex.push(barLiq.idx[lookback])
bxLLchOch.push(barLiq.l[1])
if bin.LL.size() > 0
if barLiq.idx % (lookback * 2) == 0
bin.LLchoch.push(bin.LL.pop())
bin.LLchochIndex.push(bin.LLindex.pop())
if bin.LL.size() > 0
for j = 0 to bin.LL.size()
if bin.LL.size() <= 0
break
else
var _popl1L = array.new<float>()
var _popl1Lidx = array.new<int>()
var int barLiqsince = ta.barssince(ta.crossunder(barLiq.c,
bin.LL.last()))
if ta.crossunder(barLiq.l, bin.LL.last())
bool choch = false
if itrendLiq > 0
choch := true
txt = choch ? "" : ""
_popl1L.push(bin.LL.pop())
_popl1Lidx.push(bin.LLindex.pop())
if math.abs(_popl1Lidx.last() - barLiq.idx) > 500
break
else
col = choch ? CHOCH_bear_css : BOS_bear_css
f_drawLine(_popl1Lidx.last(), _popl1L.last(), barLiq.idx,
_popl1L.last(), col, 1, barLiq.idx, txt, false, txt == "" ? true : false,
transline)
itrendLiq := -1
tot_structure_bear += 1
if bin.LLchoch.size() > 0
for j = 0 to bin.LLchoch.size()
if bin.LLchoch.size() <= 0
break
else
var _popl1Lchoch = array.new<float>()
var _popl1LchochIndex = array.new<int>()
if ta.crossunder(barLiq.c, bin.LLchoch.last())
bool choch = false
if itrendLiq > 0
choch := true
txt = choch ? "" : ""
_popl1Lchoch.push(bin.LLchoch.pop())
_popl1LchochIndex.push(bin.LLchochIndex.pop())
if math.abs(_popl1LchochIndex.last() - barLiq.idx) > 500
break
else
col = choch ? CHOCH_bear_css : BOS_bear_css
f_drawLine(_popl1LchochIndex.last(), _popl1Lchoch.last(),
barLiq.idx, _popl1Lchoch.last(), col, 1, barLiq.idx, txt, false, txt == "" ? true :
false, transline)
itrendLiq := -1
tot_structure_bear += 1
if bxLLchOch.size() > 0
barLiqsince = ta.barssince(ta.crossunder(barLiq.l ,bxLLchOch.last()))
var float lastLvl = na
var int index = na
if ta.crossunder(barLiq.h, bxLLchOch.last())
lastLvl := bxLLchOch.last()
index := barLiq.idx[1]
if _hl
id = show_pivot ? na : label.new(barLiq.idx[lookback], barLiq.l[lookback], text
= "HL", style = label.style_label_up, size = lbl_t, color = colinv, textcolor =
HH_css)
bin.HL.push(barLiq.l[lookback])
bin.HLindex.push(barLiq.idx[lookback])
bxHLPoint.push(barLiq.l[lookback])
if bin.HL.size() > 0
for j = 0 to bin.HL.size()
if bin.HL.size() <= 0
break
else
if bin.HL.size() > 0
var _poph1L = array.new<float>()
var _poph1Lidx = array.new<int>()
var int barLiqsince = ta.barssince(ta.crossunder(barLiq.c,
bin.HL.last()))
if ta.crossunder(barLiq.l, bin.HL.last())
_poph1L.push(bin.HL.pop())
_poph1Lidx.push(bin.HLindex.pop())
if math.abs(_poph1Lidx.last() - barLiq.idx) > 500
break
else
show_pivot ? na : f_drawLine(_poph1Lidx.last(),
_poph1L.last(), barLiq.idx, _poph1L.last(), HH_css, 1, barLiq.idx, "", false,
false, 0)
if bxHLPoint.size() > 0
barLiqsince = ta.barssince(ta.crossunder(barLiq.l ,bxHLPoint.last()))
var float lastLvl = na
var int index = na
if ta.crossunder(barLiq.h, bxHLPoint.last())
lastLvl := bxHLPoint.last()
index := barLiq.idx[1]
if _lh
id = show_pivot ? na : label.new(barLiq.idx[lookback], barLiq.h[lookback], text
= "LH", style = label.style_label_down, size = lbl_t, color = colinv, textcolor =
LL_css)
bin.LH.push(barLiq.h[lookback])
bin.LHindex.push(barLiq.idx[lookback])
bxLHPoint.push(barLiq.h[lookback])
if bin.LH.size() > 0
for j = 0 to bin.LH.size()
if bin.LH.size() <= 0
break
else
if ta.crossover(barLiq.h, bin.LH.last())
bin._popl1H.push(bin.LH.pop())
bin._popl1Hidx.push(bin.LHindex.pop())
if math.abs(bin._popl1Hidx.last() - barLiq.idx) > 500
break
else
show_pivot ? na : f_drawLine(bin._popl1Hidx.last(),
bin._popl1H.last(), barLiq.idx, bin._popl1H.last(), LL_css, 1, barLiq.idx, "",
false, false, 0)
if bxLHPoint.size() > 0
barLiqsince = ta.barssince(ta.crossover(barLiq.h ,bxLHPoint.last()))
var float lastLvl = na
var int index = na
if ta.crossover(barLiq.h, bxLHPoint.last())
lastLvl := bxLHPoint.last()
index := barLiq.idx[1]
css(x) =>
var color col = na
if x == "CHoCH"
col := itrendLiq == 1 ? css_bull : css_bear
else if x == "Default"
col := barLiq.c > barLiq.o ? css_up : css_dn
col
csss = css(css_candle)
c_src = close > open ? close : open
c_csrc = close > open ? open : close
int b_wick = 0
switch show_wick
false => na
true => b_wick := 100
// Liquidity ALERTS
alertcondition(src_onetap_lh, title = "Bearish Liquidity Grab", message =
"Bearish Liquidity Grab")
alertcondition(src_onetap_hl, title = "Bullish Liquidity Grab", message =
"Bullish Liquidity Grab")
//-----------------------------------------------------------------------------{
//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 =
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)
obtxt = input.string("Small" , "Metric Size"
, ["Tiny", "Small", "Normal", "Large", "Huge"], inline = "7", group = "VOLUMETRIC
ORDER BLOCKS" )
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
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
bool obtouch = false
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
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
mtfphl(pyh , pyl , '12M', css_y, s_y)
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//{ - 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
)
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 CHoCH = na
string txt = na
if itrend < 0
CHoCH := true
switch
txt := "BOS"
css := i_ms_up_BOS
blalert.bos := true
isdrw := true
drw := msDraw.new(
up.n.first()
, up.p.first()
, i_ms_up_BOS
, txt
, true
)
CHoCH =>
isdrw := true
drw := msDraw.new(
up.n.first()
, up.p.first()
, i_ms_up_BOS.darkcss(0.25, true)
, txt
, true
)
if mtf == false
switch
itrend := 1
up.n.clear()
up.p.clear()
// INTERNAL BEARISH STRUCTURE
if dn.p.size() > 0 and up.l.size() > 1
if ta.crossunder(b.c, dn.p.first())
bool CHoCH = na
string txt = na
if itrend > 0
CHoCH := true
switch
bralert.bos := true
txt := "BOS"
css := i_ms_dn_BOS
isdrw := true
drw := msDraw.new(
dn.n.first()
, dn.p.first()
, i_ms_dn_BOS
, txt
, false
)
CHoCH =>
isdrw := true
drw := msDraw.new(
dn.n.first()
, dn.p.first()
, i_ms_dn_BOS.darkcss(0.25, false)
, txt
, false
)
if mtf == false
switch
ob_filter == "None" =>
bear_ob := true
ob_filter == "BOS" and txt == "BOS" =>
bear_ob := true
ob_filter == "CHoCH" and txt == "CHoCH" =>
bear_ob := true
ob_filter == "CHoCH+" and txt == "CHoCH+" =>
bear_ob := true
itrend := -1
dn.n.clear()
dn.p.clear()
if ta.crossover(b.c, sup.p.first())
bool CHoCH = na
string txt = na
if trend < 0
CHoCH := true
switch
blalert.swingbos := true
txt := "BOS"
icss := s_ms_up_BOS
isdrwS := true
drw := msDraw.new(
sup.n.first()
, sup.p.first()
, s_ms_up_BOS
, txt
, true
)
CHoCH =>
if mtf == false
switch
trend := 1
sup.n.clear()
sup.p.clear()
if ta.crossunder(b.c, sdn.p.first())
bool CHoCH = na
string txt = na
if trend > 0
CHoCH := true
switch
bralert.swingbos := true
txt := "BOS"
icss := s_ms_dn_BOS
isdrwS := true
drw := msDraw.new(
sdn.n.first()
, sdn.p.first()
, s_ms_dn_BOS
, txt
, false
)
CHoCH =>
if sup.l.first() < sup.l.get(1)
bralert.chochplusswing := true
else
bralert.chochswing := true
isdrwS := true
drw := msDraw.new(
sdn.n.first()
, sdn.p.first()
, s_ms_dn_BOS.darkcss(0.25, false)
, txt
, false
)
if mtf == false
switch
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
table.merge_cells(tab, 0, 5, 1, 5)
table.merge_cells(tab, 0, 6, 1, 6)
zhl(len)=>
upper = ta.highest(len)
lower = ta.lowest(len)
[top, btm]
upphl(trend) =>
if top
phl.stopcross := true
phl.txtup := top > phl.topy ? "HH" : "HL"
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
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 ? "LH" : "LL"
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
var hqlzone dZone = hqlzone.new(
box.new(
na
, na
, na
, na
, bgcolor = color.new(toplvl, 70)
, border_color = na
)
, box.new(
na
, na
, na
, na
, bgcolor = color.new(midlvl, 70)
, border_color = na
)
, box.new(
na
, na
, na
, na
, bgcolor = color.new(btmlvl, 70)
, border_color = na
)
dZone.pbx.set_lefttop(int(math.max(phl.topx, phl.bottomx))
, phl.tup)
dZone.pbx.set_rightbottom(b.n + 50 , 0.95 * phl.tup
+ 0.05 * phl.tdn)
if show_mtb
upphl (trend)
dnphl (trend)
hqlzone()
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//{ - End
}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//{ - Volumetric Order Block
}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
method drawVOB(bool cdn, bool bull, color css, int loc, bool swing) =>
, [
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.push(hH[i])
obj.l.push(lL[i])
obj.n.push(b.t[i])
// obj.h.reverse()
// obj.l.reverse()
int iU = obj.l.indexof(obj.l.min()) + 1
int iD = obj.h.indexof(obj.h.max()) + 1
obj.dir.unshift(
bull
? (b.c[iU] > b.o[iU] ? 1 : -1)
: (b.c[iD] > b.o[iD] ? 1 : -1)
)
obj.top.unshift(
bull
? pos[iU]
: obj.h.max()
)
obj.btm.unshift(
bull
? obj.l.min()
: pos[iD]
)
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]
)
if ob_pos == "Precise"
switch bull
true =>
if obj.avg.get(0) < (b.c[iU] < b.o[iU] ? b.c[iU] : b.o[iU]) and
obj.top.get(0) > hlcc4[iU]
obj.top.set(0, obj.avg.get(0))
obj.avg.set(0, math.avg(obj.top.first(), obj.btm.first()))
false =>
if obj.avg.get(0) > (b.c[iU] < b.o[iU] ? b.o[iD] : b.c[iD]) and
obj.btm.get(0) < hlcc4[iD]
obj.btm.set(0, obj.avg.get(0))
obj.avg.set(0, math.avg(obj.top.first(), obj.btm.first()))
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
// Alert
if bull
? ta.crossunder(low , obj.top.get(0))
: ta.crossover (high, obj.btm.get(0))
switch bull
true => blalert.obtouch := true
false => bralert.obtouch := true
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)
)
obj.dV.reverse()
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 (obtxt.txSz())
deOB.set_text_halign(text.align_left)
deOB.set_text_color (use_grayscale ? color.silver :
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)
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
cc = timeframe.change(fvg_tf)
if barstate.isfirst
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] < math.min(gc, go) and cc
: go < gc[1] and gl[1] < gh and gc < gc[1] and go < go[1] and
gl[1] > math.max(gc, go) and cc
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
for i = math.min(fvg_num - 1, cords.size() - 1) to 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
if z.get(0).c == 1 and z.get(1).c == -1 and z.get(2).c == 1 and
z.get(3).c == -1 and z.get(4).c == 1 and z.get(5).c == -1
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
if z.get(0).c == 1 and z.get(1).c == -1 and z.get(2).c == 1 and
z.get(3).c == -1
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() =>
var ehl w = ehl.new(0, 0, 0, 0)
top = ta.pivothigh(high, 1, 1)
btm = ta.pivotlow(low , 1, 1)
atr = ta.atr(200)
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
var aZ = array.new<line>()
var aL = array.new<label>()
if aZ.size() > 50
aZ.pop().delete()
aL.pop().delete()
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)