Guardeer Trading Indicator Script

0% found this document useful (0 votes)
2K views36 pages
The document is a TradingView Pine Script code for an indicator called 'Guardeer'. It includes various user inputs for market structure, volumetric order blocks, accumulation and distribution zones, and fair value gaps, allowing customization of visual elements on charts. The script also defines multiple data types and functions to analyze market trends and display relevant information on the trading chart.

Uploaded by

Pavan Kumar
License
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

//@version=6

indicator(title="Guardeer", shorttitle="Guardeer", 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_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
//-----------------------------------------------------------------------------{

show_swing_ms = [Link](defval="All", title="Swing ",


inline="1", group="MARKET STRUCTURE", options=["All", "CHoCH", "CHoCH+", "BOS",
"None"])
show_internal_ms = [Link](defval="All", title="Internal ",
inline="2", group="MARKET STRUCTURE", options=["All", "CHoCH", "CHoCH+", "BOS",
"None"])
internal_r_lookback = [Link](defval=5, title="", inline="2",
group="MARKET STRUCTURE", minval=2)
swing_r_lookback = [Link](defval=50, title="", inline="1",
group="MARKET STRUCTURE", minval=2)
ms_mode = [Link](defval="Manual", title="Market
Structure Mode", inline="a", group="MARKET STRUCTURE", tooltip="[Manual] Use
selected lenght\n[Dynamic] Use automatic lenght", options=["Manual", "Dynamic"])
show_mtf_str = [Link](defval=true, title="MTF Scanner",
inline="9", group="MARKET STRUCTURE", tooltip="Display Multi-Timeframe Market
Structure Trend Directions. Green = Bullish. Red = Bearish")
show_eql = [Link](defval=false, title="Show EQH/EQL",
inline="6", group="MARKET STRUCTURE")
plotcandle_bool = [Link](defval=false, title="Plotcandle",
inline="3", group="MARKET STRUCTURE", tooltip="Displays a cleaner colored
candlestick chart in place of the default candles. (requires hiding the current
ticker candles)")
barcolor_bool = [Link](defval=false, title="Bar Color",
inline="4", group="MARKET STRUCTURE", tooltip="Color the candle bodies according to
market strucutre trend")

i_ms_up_BOS = [Link](defval=#089981, title="", inline="2",


group="MARKET STRUCTURE")
i_ms_dn_BOS = [Link](defval=#f23645, title="", inline="2",
group="MARKET STRUCTURE")
s_ms_up_BOS = [Link](defval=#089981, title="", inline="1",
group="MARKET STRUCTURE")
s_ms_dn_BOS = [Link](defval=#f23645, title="", inline="1",
group="MARKET STRUCTURE")

lvl_daily = [Link](defval=false, title="Day ",


inline="1", group="HIGHS & LOWS MTF")
lvl_weekly = [Link](defval=false, title="Week ",
inline="2", group="HIGHS & LOWS MTF")
lvl_monthly = [Link](defval=false, title="Month",
inline="3", group="HIGHS & LOWS MTF")
lvl_yearly = [Link](defval=false, title="Year ",
inline="4", group="HIGHS & LOWS MTF")
css_d = [Link](defval=[Link], title="",
inline="1", group="HIGHS & LOWS MTF")
css_w = [Link](defval=[Link], title="",
inline="2", group="HIGHS & LOWS MTF")
css_m = [Link](defval=[Link], title="",
inline="3", group="HIGHS & LOWS MTF")
css_y = [Link](defval=[Link], title="",
inline="4", group="HIGHS & LOWS MTF")
s_d = [Link](defval='⎯⎯⎯', title='', inline='1',
group='HIGHS & LOWS MTF', options=['⎯⎯⎯', '----', '····'])
s_w = [Link](defval='⎯⎯⎯', title='', inline='2',
group='HIGHS & LOWS MTF', options=['⎯⎯⎯', '----', '····'])
s_m = [Link](defval='⎯⎯⎯', title='', inline='3',
group='HIGHS & LOWS MTF', options=['⎯⎯⎯', '----', '····'])
s_y = [Link](defval='⎯⎯⎯', title='', inline='4',
group='HIGHS & LOWS MTF', options=['⎯⎯⎯', '----', '····'])

ob_show = [Link](defval=true, title="Show Last ",


inline="1", group="VOLUMETRIC ORDER BLOCKS", tooltip="Display volumetric order
blocks on the chart \n\n[Input] Ammount of volumetric order blocks to show")
ob_num = [Link](defval=5, title="", inline="1",
group="VOLUMETRIC ORDER BLOCKS", tooltip="Orderblocks number", minval=1, maxval=10)
ob_metrics_show = [Link](defval=true, title="Internal Buy/Sell
Activity", inline="2", group="VOLUMETRIC ORDER BLOCKS", tooltip="Display volume
metrics that have formed the orderblock")
css_metric_up = [Link](defval=[Link](#089981, 50),
title=" ", inline="2", group="VOLUMETRIC ORDER BLOCKS")
css_metric_dn = [Link](defval=[Link](#f23645 , 50),
title="", inline="2", group="VOLUMETRIC ORDER BLOCKS")
ob_swings = [Link](defval=false, title="Swing Order
Blocks", inline="a", group="VOLUMETRIC ORDER BLOCKS", tooltip="Display swing
volumetric order blocks")
css_swing_up = [Link](defval=[Link]([Link] , 90),
title=" ", inline="a", group="VOLUMETRIC ORDER BLOCKS")
css_swing_dn = [Link](defval=[Link]([Link], 90),
title="", inline="a", group="VOLUMETRIC ORDER BLOCKS")
ob_filter = [Link](defval="None",
title="Filtering ", inline="d", group="VOLUMETRIC ORDER BLOCKS",
tooltip="Filter out volumetric order blocks by BOS/CHoCH/CHoCH+", options=["None",
"BOS", "CHoCH", "CHoCH+"])
ob_mitigation = [Link](defval="Absolute",
title="Mitigation ", inline="4", group="VOLUMETRIC ORDER BLOCKS",
tooltip="Trigger to remove volumetric order blocks", options=["Absolute",
"Middle"])
ob_pos = [Link](defval="Precise",
title="Positioning ", inline="k", group="VOLUMETRIC ORDER BLOCKS",
tooltip="Position of the Order Block\n[Full] Cover the whole candle\n[Middle] Cover
half candle\n[Accurate] Adjust to volatility\n[Precise] Same as Accurate but more
precise", options=["Full", "Middle", "Accurate", "Precise"])
use_grayscale = [Link](defval=false, title="Grayscale",
inline="6", group="VOLUMETRIC ORDER BLOCKS", tooltip="Use gray as basic order
blocks color")
use_show_metric = [Link](defval=true, title="Show Metrics",
inline="7", group="VOLUMETRIC ORDER BLOCKS", tooltip="Show volume associated with
the orderblock and his relevance")
use_middle_line = [Link](defval=true, title="Show Middle-Line",
inline="8", group="VOLUMETRIC ORDER BLOCKS", tooltip="Show mid-line order blocks")
use_overlap = [Link](defval=true, title="Hide Overlap",
inline="9", group="VOLUMETRIC ORDER BLOCKS", tooltip="Hide overlapping order
blocks")
use_overlap_method = [Link](defval="Previous", title="Overlap
Method ", inline="Z", group="VOLUMETRIC ORDER BLOCKS", tooltip="[Recent] Preserve
the most recent volumetric order blocks\n\n[Previous] Preserve the previous
volumetric order blocks", options=["Recent", "Previous"])
ob_bull_css = [Link](defval=[Link](#089981 , 90),
title="", inline="1", group="VOLUMETRIC ORDER BLOCKS")
ob_bear_css = [Link](defval=[Link](#f23645 , 90),
title="", inline="1", group="VOLUMETRIC ORDER BLOCKS")

show_acc_dist_zone = [Link](defval=false, title="", inline="1",


group="Accumulation And Distribution")
zone_mode = [Link](defval="Fast", title="", inline="1",
group="Accumulation And Distribution", tooltip="[Fast] Find small zone pattern
formation\n[Slow] Find bigger zone pattern formation", options=["Slow", "Fast"])
acc_css = [Link](defval=[Link](#089981 , 60),
title="", inline="1", group="Accumulation And Distribution")
dist_css = [Link](defval=[Link](#f23645 , 60),
title="", inline="1", group="Accumulation And Distribution")

show_lbl = [Link](defval=true, title="Show swing point",


inline="1", group="High and Low", tooltip="Display swing point")
show_mtb = [Link](defval=true, title="Show
High/Low/Equilibrium", inline="2", group="High and Low", tooltip="Display
Strong/Weak High And Low and Equilibrium")
toplvl = [Link](defval=[Link], title="Premium
Zone ", inline="3", group="High and Low")
midlvl = [Link](defval=[Link], title="Equilibrium
Zone", inline="4", group="High and Low")
btmlvl = [Link](defval=#089981, title="Discount
Zone ", inline="5", group="High and Low")

fvg_enable = [Link](defval=false, title=" ",


inline="1", group="FAIR VALUE GAP", tooltip="Display fair value gap")
what_fvg = [Link](defval="FVG", title="", inline="1",
group="FAIR VALUE GAP", tooltip="Display fair value gap", options=["FVG", "VI",
"OG"])
fvg_num = [Link](defval=5, title="Show Last ",
inline="1a", group="FAIR VALUE GAP", tooltip="Number of fvg to show")
fvg_upcss = [Link](defval=[Link](#089981, 80),
title="", inline="1", group="FAIR VALUE GAP")
fvg_dncss = [Link](defval=[Link]([Link] , 80),
title="", inline="1", group="FAIR VALUE GAP")
fvg_extend = [Link](defval=10, title="Extend FVG",
inline="2", group="FAIR VALUE GAP", tooltip="Extend the display of the FVG.")
fvg_src = [Link](defval="Close",
title="Mitigation ", inline="3", group="FAIR VALUE GAP", tooltip="[Close] Use the
close of the body as trigger\n\n[Wick] Use the extreme point of the body as
trigger", options=["Close", "Wick"])
fvg_tf = [Link](defval="", title="Timeframe ",
inline="4", group="FAIR VALUE GAP", tooltip="Timeframe of the fair value gap")

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]()

alerts blalert = [Link]()


alerts bralert = [Link]()

if [Link]

[Link] += 1

if [Link] == 50

[Link] := 0
[Link] := "None"
[Link] := false
[Link] := false

switch

b.c > b.o => [Link](green_candle, true)


b.c < b.o => [Link](red_candle , true)

f_zscore(src, lookback) =>

(src - [Link](src, lookback)) / [Link](src, lookback)

var int iLen = internal_r_lookback


var int sLen = swing_r_lookback

vv = f_zscore(((close - close[iLen]) / close[iLen]) * 100,iLen)

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

var msline = [Link]<line>(0)

iH = [Link](high, iLen, iLen)


sH = [Link](high, sLen, sLen)
iL = [Link] (low , iLen, iLen)
sL = [Link] (low , sLen, sLen)

//{ - End
}
//{ - ARRAYS
}

hl () => [high, low]

[pdh, pdl] = [Link]([Link] , 'D' , hl() , lookahead =


barmerge.lookahead_on)
[pwh, pwl] = [Link]([Link] , 'W' , hl() , lookahead =
barmerge.lookahead_on)
[pmh, pml] = [Link]([Link] , 'M' , hl() , lookahead =
barmerge.lookahead_on)
[pyh, pyl] = [Link]([Link] , '12M', hl() , lookahead =
barmerge.lookahead_on)

lstyle(style) =>

out = switch style

'⎯⎯⎯' => line.style_solid


'----' => line.style_dashed
'····' => line.style_dotted

mtfphl(h, l ,tf ,css, pdhl_style) =>

var line hl = [Link](


x1 = na,
y1 = na,
x2 = na,
y2 = na,
xloc = xloc.bar_time,
color = css,
style = lstyle(pdhl_style)
)

var line ll = [Link](


x1 = na,
y1 = na,
x2 = na,
y2 = na,
xloc = xloc.bar_time,
color = css,
style = lstyle(pdhl_style)
)

var label lbl = [Link](


x = na,
y = na,
xloc = xloc.bar_time,
text = [Link]('P{0}L', tf),
color = invcol,
textcolor = css,
size = [Link],
style = label.style_label_left
)

var label hlb = [Link](


x = na,
y = na,
xloc = xloc.bar_time,
text = [Link]('P{0}H', tf),
color = invcol,
textcolor = css,
size = [Link],
style = label.style_label_left
)

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]

extension = time + (time - time[1]) * 50

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

mtfphl(pdh , pdl , 'D' , css_d, s_d)

if lvl_weekly

mtfphl(pwh , pwl , 'W' , css_w, s_w)

if lvl_monthly

mtfphl(pmh , pml, 'M' , css_m, s_m)

if lvl_yearly

mtfphl(pyh , pyl , '12M', css_y, s_y)

//{ - End
}
//{ - Market Structure
}

darkcss(css, factor, bull) =>

blue = color.b(css) * (1 - factor)


red = color.r(css) * (1 - factor)
green = color.g(css) * (1 - factor)

[Link](red, green, blue, 0)

f_line(d, size, style) =>

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
)

if [Link]() >= 250

[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
)

structure(bool mtf) =>

msDraw drw = na

bool isdrw = false


bool isdrwS = false

var color css = na


var color icss = na

var int itrend = 0


var int trend = 0

bool bull_ob = false


bool bear_ob = false

bool s_bull_ob = false


bool s_bear_ob = false
n = bar_index

var ms up = [Link](
[Link]<float>(),
[Link]< int >(),
[Link]<float>()
)

var ms dn = [Link](
[Link]<float>(),
[Link]< int >(),
[Link]<float>()
)

var ms sup = [Link](


[Link]<float>(),
[Link]< int >(),
[Link]<float>()
)

var ms sdn = [Link](


[Link]<float>(),
[Link]< int >(),
[Link]<float>()
)

switch show_swing_ms

"All" => [Link](s_BOS , true ), [Link](s_CHoCH, true ) ,


[Link](s_CHoCHP, true )
"CHoCH" => [Link](s_BOS , false), [Link](s_CHoCH, true ) ,
[Link](s_CHoCHP, false )
"CHoCH+" => [Link](s_BOS , false), [Link](s_CHoCH, false) ,
[Link](s_CHoCHP, true )
"BOS" => [Link](s_BOS , true ), [Link](s_CHoCH, false) ,
[Link](s_CHoCHP, false )
"None" => [Link](s_BOS , false), [Link](s_CHoCH, false) ,
[Link](s_CHoCHP, false )
=> na

switch show_internal_ms

"All" => [Link](i_BOS, true ), [Link](i_CHoCH, true ),


[Link](i_CHoCHP, true )
"CHoCH" => [Link](i_BOS, false), [Link](i_CHoCH, true ),
[Link](i_CHoCHP, false)
"CHoCH+" => [Link](i_BOS, false), [Link](i_CHoCH, false ),
[Link](i_CHoCHP, true )
"BOS" => [Link](i_BOS, true ), [Link](i_CHoCH, false ),
[Link](i_CHoCHP, false)
"None" => [Link](i_BOS, false), [Link](i_CHoCH, false ),
[Link](i_CHoCHP, false)
=> na

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])

// INTERNAL BULLISH STRUCTURE


if [Link]() > 0 and [Link]() > 1

if [Link](b.c, [Link]())

bool CHoCH = false


string txt = na

if itrend < 0

CHoCH := true

switch

not CHoCH =>

txt := "BOS"
css := i_ms_up_BOS

[Link] := true

if [Link](i_BOS) and mtf == false and na(drw)

isdrw := true
drw := [Link](
[Link](),
[Link](),
i_ms_up_BOS,
txt,
true
)

CHoCH =>

[Link]() > [Link](1) ? [Link] : [Link]

txt := [Link]() > [Link](1) ? "CHoCH+" :


"CHoCH"
css := i_ms_up_BOS.darkcss(0.25, true)

if ([Link]() > [Link](1) ?


[Link](i_CHoCHP) : [Link](i_CHoCH)) and mtf == false and na(drw)

isdrw := true
drw := [Link](
[Link](),
[Link](),
i_ms_up_BOS.darkcss(0.25, true),
txt,
true
)

if mtf == false

switch

ob_filter == "None" =>


bull_ob := true
ob_filter == "BOS" and txt == "BOS" =>
bull_ob := true
ob_filter == "CHoCH" and txt == "CHoCH" =>
bull_ob := true
ob_filter == "CHoCH+" and txt == "CHoCH+" =>
bull_ob := true

itrend := 1
[Link]()
[Link]()

// INTERNAL BEARISH STRUCTURE


if [Link]() > 0 and [Link]() > 1

if [Link](b.c, [Link]())

bool CHoCH = false


string txt = na

if itrend > 0

CHoCH := true

switch

not CHoCH =>

[Link] := true

txt := "BOS"
css := i_ms_dn_BOS

if [Link](i_BOS) and mtf == false and na(drw)

isdrw := true
drw := [Link](
[Link](),
[Link](),
i_ms_dn_BOS,
txt,
false
)

CHoCH =>

if [Link]() < [Link](1)


[Link] := true
else
[Link] := true

txt := [Link]() < [Link](1) ? "CHoCH+" :


"CHoCH"
css := i_ms_dn_BOS.darkcss(0.25, false)

if ([Link]() < [Link](1) ?


[Link](i_CHoCHP) : [Link](i_CHoCH)) and mtf == false and na(drw)

isdrw := true
drw := [Link](
[Link](),
[Link](),
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
[Link]()
[Link]()

// SWING BULLISH STRUCTURE


if [Link]() > 0 and [Link]() > 1
if [Link](b.c, [Link]())

bool CHoCH = false


string txt = na

if trend < 0

CHoCH := true

switch

not CHoCH =>


[Link] := true

txt := "BOS"
icss := s_ms_up_BOS

if [Link](s_BOS) and mtf == false and na(drw)

isdrwS := true
drw := [Link](
[Link](),
[Link](),
s_ms_up_BOS,
txt,
true
)

CHoCH =>

if [Link]() > [Link](1)


[Link] := true
else
[Link] := true

txt := [Link]() > [Link](1) ? "CHoCH+" : "CHoCH"


icss := s_ms_up_BOS.darkcss(0.25, true)

if ([Link]() > [Link](1) ?


[Link](s_CHoCHP) : [Link](s_CHoCH)) and mtf == false and na(drw)

isdrwS := true
drw := [Link](
[Link](),
[Link](),
s_ms_up_BOS.darkcss(0.25, true),
txt,
true
)

if mtf == false

switch

ob_filter == "None" =>


s_bull_ob := true
ob_filter == "BOS" and txt == "BOS" =>
s_bull_ob := true
ob_filter == "CHoCH" and txt == "CHoCH" =>
s_bull_ob := true
ob_filter == "CHoCH+" and txt == "CHoCH+" =>
s_bull_ob := true

trend := 1
[Link]()
[Link]()

// SWING BEARISH STRUCTURE


if [Link]() > 0 and [Link]() > 1

if [Link](b.c, [Link]())
bool CHoCH = false
string txt = na

if trend > 0

CHoCH := true

switch

not CHoCH =>

[Link] := true

txt := "BOS"
icss := s_ms_dn_BOS

if [Link](s_BOS) and mtf == false and na(drw)

isdrwS := true
drw := [Link](
[Link](),
[Link](),
s_ms_dn_BOS,
txt,
false
)

CHoCH =>

if [Link]() < [Link](1)


[Link] := true
else
[Link] := true

txt := [Link]() < [Link](1) ? "CHoCH+" :


"CHoCH"
icss := s_ms_dn_BOS.darkcss(0.25, false)

if ([Link]() < [Link](1) ?


[Link](s_CHoCHP) : [Link](s_CHoCH)) and mtf == false and na(drw)

isdrwS := true
drw := [Link](
[Link](),
[Link](),
s_ms_dn_BOS.darkcss(0.25, false),
txt,
false
)

if mtf == false

switch

ob_filter == "None" =>


s_bear_ob := true
ob_filter == "BOS" and txt == "BOS" =>
s_bear_ob := true
ob_filter == "CHoCH" and txt == "CHoCH" =>
s_bear_ob := true
ob_filter == "CHoCH+" and txt == "CHoCH+" =>
s_bear_ob := true

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)

[_, _, _, itrend15, _, _, _, _, _, _, _] = [Link]("", "15" ,


expression=structure(true))
[_, _, _, itrend1H, _, _, _, _, _, _, _] = [Link]("", "60" ,
expression=structure(true))
[_, _, _, itrend4H, _, _, _, _, _, _, _] = [Link]("", "240" ,
expression=structure(true))
[_, _, _, itrend1D, _, _, _, _, _, _, _] = [Link]("", "1440" ,
expression=structure(true))

if show_mtf_str

var tab = [Link](position = position.top_right, columns = 10, rows = 10,


bgcolor = na, frame_color = [Link](54, 58, 69, 0), frame_width = 1, border_color
= [Link](54, 58, 69, 100), border_width = 1)
[Link](table_id=tab, column=0, row=1, text = "15" , text_color =
[Link], text_halign = text.align_center, text_size = [Link], bgcolor =
chart.bg_color, text_font_family = font.family_monospace, width = 2)
[Link](table_id=tab, column=0, row=2, text = "1H" , text_color =
[Link], text_halign = text.align_center, text_size = [Link], bgcolor =
chart.bg_color, text_font_family = font.family_monospace, width = 2)
[Link](table_id=tab, column=0, row=3, text = "4H" , text_color =
[Link], text_halign = text.align_center, text_size = [Link], bgcolor =
chart.bg_color, text_font_family = font.family_monospace, width = 2)
[Link](table_id=tab, column=0, row=4, text = "1D" , text_color =
[Link], text_halign = text.align_center, text_size = [Link], bgcolor =
chart.bg_color, text_font_family = font.family_monospace, width = 2)

[Link](table_id=tab, column=1, row=1, text = itrend15 == 1 ? "BULLISH" :


itrend15 == -1 ? "BEARISH" : na , text_halign = text.align_center, text_size =
[Link], text_color = itrend15 == 1 ? i_ms_up_BOS.darkcss(-0.25, true) :
itrend15 == -1 ? i_ms_dn_BOS.darkcss(0.25, false) : [Link], bgcolor =
chart.bg_color, text_font_family = font.family_monospace)
[Link](table_id=tab, column=1, row=2, text = itrend1H == 1 ? "BULLISH" :
itrend1H == -1 ? "BEARISH" : na , text_halign = text.align_center, text_size =
[Link], text_color = itrend1H == 1 ? i_ms_up_BOS.darkcss(-0.25, true) :
itrend1H == -1 ? i_ms_dn_BOS.darkcss(0.25, false) : [Link], bgcolor =
chart.bg_color, text_font_family = font.family_monospace)
[Link](table_id=tab, column=1, row=3, text = itrend4H == 1 ? "BULLISH" :
itrend4H == -1 ? "BEARISH" : na , text_halign = text.align_center, text_size =
[Link], text_color = itrend4H == 1 ? i_ms_up_BOS.darkcss(-0.25, true) :
itrend4H == -1 ? i_ms_dn_BOS.darkcss(0.25, false) : [Link], bgcolor =
chart.bg_color, text_font_family = font.family_monospace)
[Link](table_id=tab, column=1, row=4, text = itrend1D == 1 ? "BULLISH" :
itrend1D == -1 ? "BEARISH" : na , text_halign = text.align_center, text_size =
[Link], text_color = itrend1D == 1 ? i_ms_up_BOS.darkcss(-0.25, true) :
itrend1D == -1 ? i_ms_dn_BOS.darkcss(0.25, false) : [Link], bgcolor =
chart.bg_color, text_font_family = font.family_monospace)
[Link](table_id=tab, column=0, row=5, text = "Detected Pattern",
text_halign = text.align_center, text_size = [Link], text_color =
[Link], bgcolor = chart.bg_color, text_font_family = font.family_monospace)
[Link](table_id=tab, column=0, row=6, text = [Link], text_halign =
text.align_center, text_size = [Link], text_color = na([Link]) ? [Link] :
[Link] ? i_ms_up_BOS.darkcss(-0.25, true) : [Link] == false ?
i_ms_dn_BOS.darkcss(0.25, false) : na, bgcolor = chart.bg_color, text_font_family =
font.family_monospace)
table.merge_cells(table_id=tab, column=0, row=5, width=1, height=5)
table.merge_cells(table_id=tab, column=0, row=6, width=1, height=6)

//{ - End
}
//{ - Strong/Weak High/Low And Equilibrium
}

var phl = [Link](


top = na,
bottom = na,
top_label = [Link](x=na , y=na , color = invcol , textcolor = i_ms_dn_BOS ,
style = label.style_label_down , size = [Link] , text = ""),
bottom_label = [Link](x=na , y=na , color = invcol , textcolor =
i_ms_up_BOS , style = label.style_label_up , size = [Link] , text = ""),
stopcross = true,
sbottomcross = true,
itopcross = true,
ibottomcross = true,
txtup = "",
txtdn = "",
topy = 0,
bottomy = 0,
topx = 0,
bottomx = 0,
tup = high,
tdn = low,
tupx = 0,
tdnx = 0,
itopy = 0,
itopx = 0,
ibottomy = 0,
ibottomx = 0,
uV = na,
dV = na
)

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 = out == 0 and out[1] != 0 ? b.h[len] : 0


btm = out == 1 and out[1] != 1 ? b.l[len] : 0

[top, btm]

[top , btm ] = zhl(sLen)


[itop, ibtm] = zhl(iLen)

upphl(trend) =>

var label lbl = [Link](


x = na,
y = na,
color = invcol,
textcolor = toplvl,
style = label.style_label_down,
size = [Link]
)

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]
)

dist = [Link]([Link] / ([Link] + [Link])) * 100


label.set_text (lbl, trend < 0
? "Strong High | " + [Link]([Link], [Link]) + " (" +
[Link]([Link](dist,0)) + "%)"
: "Weak High | " + [Link]([Link], [Link]) + " (" +
[Link]([Link](dist,0)) + "%)")

dnphl(trend) =>

var label lbl = [Link](


x = na,
y = na,
color = invcol,
textcolor = btmlvl,
style = label.style_label_up,
size = [Link]
)

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

[Link] := [Link](low, [Link])


[Link] := [Link] == low ? 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]
)

dist = [Link]([Link] / ([Link] + [Link])) * 100


label.set_text (lbl, trend > 0
? "Strong Low | " + [Link]([Link], [Link]) + " (" +
[Link]([Link](dist,0)) + "%)"
: "Weak Low | " + [Link]([Link], [Link]) + " (" +
[Link]([Link](dist,0)) + "%)")

midphl() =>

avg = [Link]([Link].get_y2(), [Link].get_y2())

var line l = [Link](


x1 = b.n - sLen,
y1 = avg,
x2 = b.n + 50,
y2 = avg,
color = midlvl,
style = line.style_solid
)

var label lbl = [Link](


x = b.n + 50,
y = avg,
text = "Equilibrium",
style = label.style_label_left,
color = invcol,
textcolor = midlvl,
size = [Link]
)

if [Link]

more = ([Link].get_x1() + [Link].get_x2()) > ([Link].get_x1() +


[Link].get_x2()) ? [Link].get_x1() : [Link].get_x1()
line.set_xy1(l , more , avg)
line.set_xy2(l , b.n + 50, avg)
label.set_x (lbl , b.n + 50 )
label.set_y (lbl , avg )
dist = [Link]((l.get_y2() - close) / close) * 100
label.set_text (lbl, "Equilibrium (" + [Link]([Link](dist,0)) +
"%)")

hqlzone() =>

if [Link]

var hqlzone dZone = [Link](


pbx = [Link](
left = na,
top = na,
right = na,
bottom = na,
bgcolor = [Link](toplvl, 70),
border_color = na
),
ebx = [Link](
left = na,
top = na,
right = na,
bottom = na,
bgcolor = [Link](midlvl, 70),
border_color = na
),
lbx = [Link](
left = na,
top = na,
right = na,
bottom = na,
bgcolor = [Link](btmlvl, 70),
border_color = na
),

plb = [Link](x=na, y=na, text = "Premium" , color = invcol,


textcolor = toplvl, style = label.style_label_down, size = [Link]),
elb = [Link](x=na, y=na, text = "Equilibrium", color = invcol,
textcolor = midlvl, style = label.style_label_left, size = [Link]),
lbl = [Link](x=na, y=na, text = "Discount" , color = invcol,
textcolor = btmlvl, style = label.style_label_up , size = [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])

[Link].set_lefttop(left=int([Link]([Link], [Link])), top=0.525


* [Link] + 0.475 * [Link])
[Link].set_rightbottom(right=b.n + 50 ,
bottom=0.525 * [Link] + 0.475 * [Link])

[Link].set_lefttop(left=int([Link]([Link], [Link])), top=0.95


* [Link] + 0.05 * [Link])
[Link].set_rightbottom(right=b.n + 50
, bottom=[Link])

[Link].set_xy( x = int([Link]([Link]([Link], [Link]), int(b.n


+ 50))) , y = [Link])
[Link].set_xy( x = int(b.n + 50)
, y = [Link]([Link], [Link]))
[Link].set_xy( x = int([Link]([Link]([Link], [Link]), int(b.n
+ 50))) , y = [Link])

if show_mtb

upphl (trend)
dnphl (trend)
hqlzone()

//{ - End
}
//{ - Volumetric Order Block
}

eB(b, ext, css, swing) =>


[Link](
[Link](
left = na,
top = na,
right = na,
bottom = na,
xloc = xloc.bar_time,
text_font_family = font.family_monospace,
extend = ext ? [Link] : [Link],
border_color = swing ? [Link](css, 0) :
[Link]([Link],100),
bgcolor = css,
border_width = 1
)
)

eL(l, ext, solid, css) =>


[Link](
[Link](
x1 = na,
y1 = na,
x2 = na,
y2 = na,
width = 1,
color = css,
xloc = xloc.bar_time,
extend = ext ? [Link] : [Link],
style = solid ? line.style_solid : line.style_dashed
)
)

drawVOB(cdn, bull, css, loc, swing) =>

[cC, oO, hH, lL, vV] = [Link](


[Link],
"",

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 >()
)

var obD draw = [Link](


[Link]<box >(),
[Link]<box >(),
[Link]<box >(),
[Link]<box >(),
[Link]<line>()
)

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)

float pos = ob_pos == "Full"


? (bull ? high : low)
: ob_pos == "Middle"
? ohlc4
: ob_pos == "Accurate"
? hl2
: hl2

if cdn

[Link]()
[Link]()
[Link]()

for i = 0 to [Link]((loc - b.n)) - 1

[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

int rmP = use_overlap_method == "Recent" ? 1 : 0

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]

for [idx, pt] in tg

if (bull ? cC < pt : cC > pt)


[Link] .remove(idx)
[Link] .remove(idx)
[Link] .remove(idx)
[Link] .remove(idx)
[Link] .remove(idx)
[Link] .remove(idx)
[Link] .remove(idx)
[Link] .remove(idx)
[Link] .remove(idx)

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]()

for i = 0 to [Link](ob_num - 1, [Link]() - 1)

dmL = [Link] .get(i)


dOB = [Link] .get(i)
dblB = [Link](i)
dbrB = [Link](i)
deOB = [Link](i)
dOB.set_lefttop (left=[Link] .get(i) ,
top=[Link](i))
deOB.set_lefttop (left=b.t ,
top=[Link](i))
dOB.set_rightbottom (right=b.t ,
bottom=[Link](i))
deOB.set_rightbottom(right=b.t + (b.t - b.t[1]) * 100 ,
bottom=[Link](i))

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

dblB.set_lefttop (left=[Link](i), top=[Link](i))


dbrB.set_lefttop (left=[Link](i), top=[Link](i))
dblB.set_rightbottom (right=[Link](i),
bottom=[Link](i))
dbrB.set_rightbottom (right=[Link](i),
bottom=[Link](i))

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

[Link](i) >= 1000000000 =>


[Link]([Link]([Link](i) / 1000000000,3)) + "B"
[Link](i) >= 1000000 =>
[Link]([Link]([Link](i) / 1000000,3)) + "M"
[Link](i) >= 1000 =>
[Link]([Link]([Link](i) / 1000,3)) + "K"
[Link](i) < 1000 =>
[Link]([Link]([Link](i)))

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 ob_metrics_show and [Link]

if [Link]() > 0

for i = 0 to [Link]() - 1

switch [Link](i)
1 =>

switch [Link](i)

1 => [Link](i, [Link](i) + 1),


[Link](i, 2)
2 => [Link](i, [Link](i) + 1),
[Link](i, 3)
3 => [Link](i, [Link](i) + 1),
[Link](i, 1)
-1 =>

switch [Link](i)

1 => [Link](i, [Link](i) + 1),


[Link](i, 2)
2 => [Link](i, [Link](i) + 1),
[Link](i, 3)
3 => [Link](i, [Link](i) + 1),
[Link](i, 1)

var hN = [Link]<int>(1, b.n)


var lN = [Link]<int>(1, b.n)
var hS = [Link]<int>(1, b.n)
var lS = [Link]<int>(1, b.n)

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

bull_ob.drawVOB(true , ob_bull_css, [Link](), false)


bear_ob.drawVOB(false, ob_bear_css, [Link](), false)

if ob_swings

s_bull_ob.drawVOB(true , css_swing_up, [Link](), true)


s_bear_ob.drawVOB(false, css_swing_dn, [Link](), true)

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
}

ghl() => [Link]([Link], fvg_tf, expression=[high[2], low[2],


close[1], open[1]])
tfG() => [Link]([Link], fvg_tf, expression=[open, high, low,
close])

cG(bool bull) =>

[h, l, c, o] = ghl()
[go, gh, gl, gc] = tfG()

var FVG draw = [Link](


[Link]<box>(),
[Link]<line>()
)

var FVG[] cords = [Link]<FVG>()

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

[Link]([Link] (left=na, top=na, right=na, bottom=na,


border_color = [Link]([Link], 100), xloc = xloc.bar_time))
[Link] ([Link](x1=na, y1=na, x2=na, y2=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 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" =>

pup := bull ? b.l : gl[1]


pdn := bull ? gh[1] : gh
cdn := bull ? gl > gh[1] and cc : gh < gl[1] and cc
pos := 1

if not na(cdn[1]) and cdn[1]

[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]

for [idx, obj] in cords

if [Link] ? b.c < [Link] : b.c > [Link]

[Link](idx)

if [Link]

if [Link]() > 0

for i = [Link](fvg_num - 1, [Link]() - 1) to 0


gbx = [Link](i)
gln = [Link](i)
gcd = [Link](i)

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)

gln.set_xy1(x=left, y=[Link](gbx.get_top(), gbx.get_bottom()))


gln.set_xy2(x=right, y=[Link](gbx.get_top(), gbx.get_bottom()))
gln.set_color([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

zone_mode == "Slow" =>

if [Link]() > 5

if [Link](0).c == -1 and [Link](1).c == 1 and [Link](2).c == -1 and


[Link](3).c == 1 and [Link](4).c == -1 and [Link](5).c == 1

if [Link](0).p > [Link](2).p and [Link](2).p > [Link](4).p

if [Link](1).p < [Link](3).p and [Link](3).p < [Link](5).p

[Link] := true

[Link](top = [Link](5).p, bottom = [Link](4).p, left =


[Link](5).t, right = [Link](0).t, bgcolor = acc_css, border_color =
[Link]([Link], 100), xloc = xloc.bar_time)
slice = [Link]<[Link]>()

for i = 0 to 5

[Link]([Link](i).points)

[Link](slice, xloc = xloc.bar_time, line_color =


[Link](acc_css, 0), line_width = 2)
[Link] := "Accumulation Zone"
[Link] := true
[Link] := true
[Link] := 0
[Link]()

if [Link]() > 5

if [Link](0).c == 1 and [Link](1).c == -1 and [Link](2).c == 1 and


[Link](3).c == -1 and [Link](4).c == 1 and [Link](5).c == -1

if [Link](0).p < [Link](2).p and [Link](2).p < [Link](4).p

if [Link](1).p > [Link](3).p and [Link](3).p > [Link](5).p

[Link] := true

[Link](top = [Link](5).p, bottom = [Link](4).p, left =


[Link](5).t, right = [Link](0).t, bgcolor = dist_css, border_color =
[Link]([Link], 100), xloc = xloc.bar_time)
slice = [Link]<[Link]>()

for i = 0 to 5

[Link]([Link](i).points)

[Link](slice, xloc = xloc.bar_time, line_color =


[Link](dist_css, 0), line_width = 2)
[Link] := "Distribution Zone"
[Link] := false
[Link] := true
[Link] := 0
[Link]()
zone_mode == "Fast" =>

if [Link]() > 3

if [Link](0).c == -1 and [Link](1).c == 1 and [Link](2).c == -1 and


[Link](3).c == 1

if [Link](0).p > [Link](2).p

if [Link](1).p < [Link](3).p

[Link] := true

[Link](top = [Link](3).p, bottom = [Link](2).p, left =


[Link](3).t, right = [Link](0).t, bgcolor = acc_css, border_color =
[Link]([Link], 100), xloc = xloc.bar_time)
slice = [Link]<[Link]>()

for i = 0 to 3

[Link]([Link](i).points)

[Link](slice, xloc = xloc.bar_time, line_color =


[Link](acc_css, 0), line_width = 2)
[Link] := "Accumulation Zone"
[Link] := true
[Link] := true
[Link] := 0
[Link]()

if [Link]() > 3

if [Link](0).c == 1 and [Link](1).c == -1 and [Link](2).c == 1 and


[Link](3).c == -1

if [Link](0).p < [Link](2).p

if [Link](1).p > [Link](3).p

[Link] := true

[Link](top = [Link](2).p, bottom = [Link](3).p, left =


[Link](3).t, right = [Link](0).t, bgcolor = dist_css, border_color =
[Link]([Link], 100), xloc = xloc.bar_time)
slice = [Link]<[Link]>()

for i = 0 to 3

[Link]([Link](i).points)

[Link](slice, xloc = xloc.bar_time, line_color =


[Link](dist_css, 0), line_width = 2)
[Link] := "Distribution Zone"
[Link] := false
[Link] := true
[Link] := 0
[Link]()
if show_acc_dist_zone

drawZone(iLen)

//{ - END
}
//{ - EQH / EQL
}
dEHL() =>

var ehl w = [Link](pt=0, t=0, pb=0, b=0)


top = [Link](high, 1, 1)
btm = [Link](low , 1, 1)
atr = [Link](200)

switch

top =>

mx = [Link](top, [Link])
mn = [Link](top, [Link])

switch

mx < mn + atr * 0.1 =>

var aZ = [Link]<line>()
var aL = [Link]<label>()

if [Link]() > 50

[Link]().delete()
[Link]().delete()

[Link]([Link](x1=w.t, y1=[Link], x2=b.n - 1, y2=top, color


= i_ms_dn_BOS, style = line.style_dotted))
[Link]([Link](x=int([Link](b.n - 1, w.t)), y=top,
text="EQH", color = invcol, textcolor = i_ms_dn_BOS, style =
label.style_label_down, size = [Link]))

[Link] := true

[Link] := top
w.t := b.n - 1

btm =>

mx = [Link](btm, [Link])
mn = [Link](btm, [Link])

switch

mn > mx - atr * 0.1 =>

var aZ = [Link]<line>()
var aL = [Link]<label>()

if [Link]() > 50
[Link]().delete()
[Link]().delete()

[Link]([Link](x1=w.b, y1=[Link], x2=b.n - 1, y2=btm, color


= i_ms_up_BOS, style = line.style_dotted))
[Link]([Link](x=int([Link](b.n - 1, w.b)), y=btm,
text="EQL", color = invcol, textcolor = i_ms_up_BOS, style = label.style_label_up,
size = [Link]))

[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

p_css := plotcandle_bool ? (css) : na


b_css := barcolor_bool ? (css) : na
w_css := plotcandle_bool ? [Link](120, 123, 134, 50) : na

plotcandle(open,high,low,close , color = p_css , wickcolor = w_css , bordercolor =


p_css , editable = false)
barcolor(b_css, editable = false)

//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//{ - 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")

alertcondition([Link] , "Bearish BOS", "Bearish BOS")


alertcondition([Link] , "Bearish CHOCH", "Bearish CHOCH")
alertcondition([Link] , "Bearish CHOCH+", "Bearish CHOCH+")
alertcondition([Link], "Bearish Swing CHOCH+", "Bearish Swing
CHOCH+")
alertcondition([Link] , "Bearish Swing CHOCH", "Bearish CHOCH")
alertcondition([Link] , "Bearish Swing BOS", "Bearish Swing BOS")
alertcondition([Link] , "EQH", "EQH")
alertcondition([Link] , "Bearish FVG", "Bearish FVG")
alertcondition([Link] , "Bearish Order Block", "Bearish Order
Block")
alertcondition([Link] , "Bearish Swing Order Block", "Bearish Swing
Order Block")
alertcondition([Link] , "Distribution Zone", "Distribution Zone")
alertcondition([Link] , "Candle Entering in a Bearish Order Block",
"Candle Entering in a Bearish 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])

// These must be outside of if-blocks:


plotshape(longSignal, title="Long Signal", location=[Link],
color=[Link], style=[Link], size=[Link])
plotshape(shortSignal, title="Short Signal", location=[Link],
color=[Link], style=[Link], size=[Link])

You might also like