CC
CC
// EMA input//
Length1 = input.int(21, minval = 1)
Length2 = input.int(55, minval = 1)
Length3 = input.int(77, minval = 1)
Length4 = input.int(89, minval = 1)
Length5 = input.int(200, minval = 1)
// MA input//
Length6 = input.int(10, minval = 1)
Length7 = input.int(50, minval = 1)
Length8 = input.int(100, minval = 1)
Length9 = input.int(200, minval = 1)
xPrice = close
// EMA //
xEMA1 = ta.ema(xPrice, Length1)
xEMA2 = ta.ema(xPrice, Length2)
xEMA3 = ta.ema(xPrice, Length3)
xEMA4 = ta.ema(xPrice, Length4)
xEMA5 = ta.ema(xPrice, Length5)
// MA //
xSMA1 = ta.sma(xPrice, Length6)
xSMA2 = ta.sma(xPrice, Length7)
xSMA3 = ta.sma(xPrice, Length8)
xSMA4 = ta.sma(xPrice, Length9)
// EMA plot//
plot(xEMA1, linewidth = 2, color = color.rgb(255, 0, 255), title = 'EMA 1')
plot(xEMA2, linewidth = 2, color = color.new(color.green, 0), title = 'EMA 2')
plot(xEMA3, linewidth = 2, color = color.new(color.aqua, 0), title = 'EMA 3')
plot(xEMA4, linewidth = 2, color = color.new(color.purple, 0), title = 'EMA 4')
plot(xEMA5, linewidth = 2, color = color.new(color.white, 0), title = 'EMA 5')
// MA plot//
plot(xSMA1, linewidth = 2, color = color.new(color.red, 0), title = 'MA 1')
plot(xSMA2, linewidth = 2, color = color.new(color.lime, 0), title = 'MA 2')
plot(xSMA3, linewidth = 2, color = color.new(color.orange, 0), title = 'MA 3')
plot(xSMA4, linewidth = 2, color = color.new(color.yellow, 0), title = 'MA 4')
//////////////////
plot(na)
//
MSG = 'MARKET STRUCTURE'
VBG = 'VOLUMETRIC ORDER BLOCKS'
MST = 'Limit market structure calculation to improve memory speed time'
SLT = '[INPUT] Limit swing structure to tot bars back'
IDT = '[INPUT] Start date of the internal structure'
CST = 'Color candle based on trend detection system'
OBT = 'Display internal buy and sell activity'
OBD = 'Show Last number of orderblock'
OBMT = '[Length] Use Length to adjust cordinate of the orderblocks\n[Full] Use
whole candle body'
_ = ' ------------ –––––––––––––––––––––––––– INPUTS
––––––––––––––––––––––––––– ------------
'
bool windowsis = input.bool(true, 'Window', inline = 'kla', group = MSG)
int mswindow = input.int(5000, '', tooltip = MST, group = MSG, inline = 'kla',
minval = 1000)
bool obshow = input.bool(true, 'Show Last', tooltip = OBD, group = VBG, inline =
'obshow')
int oblast = input.int(5, '', group = VBG, inline = 'obshow', minval = 0)
color obupcs = input.color(color.new(#089981, 90), '', inline = 'obshow', group =
VBG)
color obdncs = input.color(color.new(#f23645, 90), '', inline = 'obshow', group =
VBG)
bool obshowactivity = input.bool(true, 'Show Buy/Sell Activity', inline = 'act',
group = VBG, tooltip = OBT)
color obactup = input.color(color.new(#089981, 50), '', inline = 'act', group =
VBG)
color obactdn = input.color(color.new(#f23645, 50), '', inline = 'act', group =
VBG)
obshowbb = input.bool(false, 'Show Breakers', inline = 'bb', group = VBG, tooltip =
'Display Breakers')
color bbup = input.color(color.new(#089981, 100), '', inline = 'bb', group = VBG)
color bbdn = input.color(color.new(#f23645, 100), '', inline = 'bb', group = VBG)
obmode = input.string('Length', 'Construction', options = ['Length', 'Full'],
tooltip = OBMT, inline = 'atr', group = VBG)
len = input.int(5, '', inline = 'atr', group = VBG, minval = 1)
obmiti = input.string('Close', 'Mitigation Method', options = ['Close', 'Wick',
'Avg'], tooltip = 'Mitigation method for when to trigger order blocks', group =
VBG)
obtxt = input.string('Normal', 'Metric Size', options = ['Tiny', 'Small', 'Normal',
'Large', 'Huge', 'Auto'], tooltip = 'Order block Metrics text size', inline =
'txt', group = VBG)
showmetric = input.bool(true, 'Show Metrics', group = VBG)
showline = input.bool(true, 'Show Mid-Line', group = VBG)
overlap = input.bool(true, 'Hide Overlap', group = VBG, inline = 'ov')
wichlap = input.string('Recent', '', options = ['Recent', 'Old'], inline = 'ov',
group = VBG)
fvg_enable = input.bool(false, '', inline = '1', group = 'FAIR VALUE GAP', tooltip
= 'Display fair value gap')
what_fvg = input.string('FVG', '', inline = '1', group = 'FAIR VALUE GAP', tooltip
= 'Display fair value gap', options = ['FVG', 'Breakers'])
fvg_num = input.int(5, 'Show Last', inline = '1a', group = 'FAIR VALUE GAP',
tooltip = 'Number of fvg to show', minval = 0)
fvg_upcss = input.color(color.new(#089981, 80), '', inline = '1', group = 'FAIR
VALUE GAP')
fvg_dncss = input.color(color.new(#f23645, 80), '', inline = '1', group = 'FAIR
VALUE GAP')
fvgbbup = input.color(color.new(#089981, 100), '', inline = '1', group = 'FAIR
VALUE GAP')
fvgbbdn = input.color(color.new(#f23645, 100), '', inline = '1', group = 'FAIR
VALUE GAP')
fvg_src = input.string('Close', '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', 'Avg'])
fvgthresh = input.float(0, 'Threshold', tooltip = 'Filter out non significative
FVG', group = 'FAIR VALUE GAP', inline = 'asd', minval = 0, maxval = 2, step = 0.1)
fvgoverlap = input.bool(true, 'Hide Overlap', 'Hide overlapping FVG', group = 'FAIR
VALUE GAP')
fvgline = input.bool(true, 'Show Mid-Line', group = 'FAIR VALUE GAP')
fvgextend = input.bool(false, 'Extend FVG', group = 'FAIR VALUE GAP')
dispraid = input.bool(false, 'Display Raids', inline = 'raid', group = 'FAIR VALUE
GAP')
//}
_ = ' ------------ –––––––––––––––––––––––––– UDT
––––––––––––––––––––––––––– ------------
' //{
type hqlzone
box pbx
box ebx
box lbx
label plb
label elb
label lbl
type Zphl
line top
line bottom
label top_label
label bottom_label
bool stopcross
bool sbottomcross
bool itopcross
bool ibottomcross
string txtup
string txtdn
float topy
float bottomy
float topx
float bottomx
float tup
float tdn
int tupx
int tdnx
float itopy
float itopx
float ibottomy
float ibottomx
float uV
float dV
type entered
bool normal = false
bool breaker = false
type store
array<line> ln
array<label> lb
array<box> bx
array<linefill> lf
type structure
int zn
float zz
float bos
float choch
int loc
int temp
int trend
int start
float main
int xloc
bool upsweep
bool dnsweep
string txt = na
type drawms
int x1
int x2
float y
string txt
color css
string style
type ob
bool bull
float top
float btm
float avg
int loc
color css
float vol
int dir
int move
int blPOS
int brPOS
int xlocbl
int xlocbr
bool isbb = false
int bbloc
type FVG
float top = na
float btm = na
int loc = bar_index
bool isbb = false
int bbloc = na
bool israid = false
float raidy = na
int raidloc = na
int raidx2 = na
bool active = false
color raidcs = na
type SFP
float y
int loc
float ancor
type sfpbuildlbl
int x
float y
string style
color css
string txt
type sfpbuildline
int x1
int x2
float y
color css
float ancor
int loc
type equalbuild
int x1
float y1
int x2
float y2
color css
string style
type equalname
int x
float y
string txt
color css
string style
type ehl
float pt
int t
float pb
int b
type sellbuyside
float top
float btm
int loc
color css
string txt
float vol
type timer
bool start = false
int count = 0
//}
_ = ' ------------ –––––––––––––––––––––––––– SETUP
––––––––––––––––––––––––––– ------------
' //{
if barstate.islast
for obj in bin.ln
obj.delete()
for obj in bin.lb
obj.delete()
for obj in bin.bx
obj.delete()
for obj in bin.lf
obj.delete()
bin.ln.clear()
bin.lb.clear()
bin.bx.clear()
bin.lf.clear()
invcol = #ffffff00
float atr = ta.atr(200) / (5 / len)
//}
_ = ' ------------ –––––––––––––––––––––––––– UTILITY
––––––––––––––––––––––––––– ------------
' //{
ghl() =>
[high[2], low[2], close[1], open[1], close, open, high, low, high[1], low[1],
ta.atr(200)]
min = 99999999.
max = 0.
idx = 0
if use_max
for i = 0 to bar_index - loc by 1
max := math.max(high[i], max)
min := max == high[i] ? low[i] : min
idx := max == high[i] ? i : idx
idx
else
for i = 0 to bar_index - loc by 1
min := math.min(low[i], min)
max := min == low[i] ? high[i] : max
idx := min == low[i] ? i : idx
idx
idx
SFPData() =>
[high, high[1], high[2], low, low[1], low[2], close, volume, time, bar_index,
time[1]]
SFPcords() =>
RealTF = barstate.isrealtime ? 0 : 1
[h, h1, h2, l, l1, l2, c, v, t, n, t1] = SFPData()
method find(structure ms, bool use_max, bool sweep, bool useob) =>
min = 99999999.
max = 0.
idx = 0
if not sweep
if bar_index - ms.loc - 1 > 0
if use_max
for i = 0 to bar_index - ms.loc - 1 by 1
max := math.max(high[i], max)
min := max == high[i] ? low[i] : min
idx := max == high[i] ? i : idx
idx
if useob
if high[idx + 1] > high[idx]
max := high[idx + 1]
min := low[idx + 1]
idx := idx + 1
idx
else
for i = 0 to bar_index - ms.loc - 1 by 1
min := math.min(low[i], min)
max := min == low[i] ? high[i] : max
idx := min == low[i] ? i : idx
idx
if useob
if low[idx + 1] < low[idx]
max := high[idx + 1]
min := low[idx + 1]
idx := idx + 1
idx
else
if use_max
for i = 0 to bar_index - ms.loc by 1
max := math.max(high[i], max)
min := max == high[i] ? low[i] : min
idx := max == high[i] ? i : idx
idx
if useob
if high[idx + 1] > high[idx]
max := high[idx + 1]
min := low[idx + 1]
idx := idx + 1
idx
else
for i = 0 to bar_index - ms.loc by 1
min := math.min(low[i], min)
max := min == low[i] ? high[i] : max
idx := min == low[i] ? i : idx
idx
if useob
if low[idx + 1] < low[idx]
max := high[idx + 1]
min := low[idx + 1]
idx := idx + 1
idx
else
if bar_index - ms.xloc - 1 > 0
if use_max
for i = 0 to bar_index - ms.xloc - 1 by 1
max := math.max(high[i], max)
min := max == high[i] ? low[i] : min
idx := max == high[i] ? i : idx
idx
if useob
if high[idx + 1] > high[idx]
max := high[idx + 1]
min := low[idx + 1]
idx := idx + 1
idx
else
for i = 0 to bar_index - ms.xloc - 1 by 1
min := math.min(low[i], min)
max := min == low[i] ? high[i] : max
idx := min == low[i] ? i : idx
idx
if useob
if low[idx + 1] < low[idx]
max := high[idx + 1]
min := low[idx + 1]
idx := idx + 1
idx
else
if use_max
for i = 0 to bar_index - ms.xloc by 1
max := math.max(high[i], max)
min := max == high[i] ? low[i] : min
idx := max == high[i] ? i : idx
idx
if useob
if high[idx + 1] > high[idx]
max := high[idx + 1]
min := low[idx + 1]
idx := idx + 1
idx
else
for i = 0 to bar_index - ms.xloc by 1
min := math.min(low[i], min)
max := min == low[i] ? high[i] : max
idx := min == low[i] ? i : idx
idx
if useob
if low[idx + 1] < low[idx]
max := high[idx + 1]
min := low[idx + 1]
idx := idx + 1
idx
idx
method fnOB(array<ob> block, bool bull, float cords, int idx) =>
switch bull
true =>
blobenter.normal := false
blobenter.breaker := false
block.unshift(ob.new(true, cords, low[idx], math.avg(cords, low[idx]),
time[idx], obupcs, volume[idx], close[idx] > open[idx] ? 1 : -1, 1, 1, 1,
time[idx]))
false =>
brobenter.normal := false
brobenter.breaker := false
block.unshift(ob.new(false, high[idx], cords, math.avg(cords, high[idx]),
time[idx], obdncs, volume[idx], close[idx] > open[idx] ? 1 : -1, 1, 1, 1,
time[idx]))
block.remove(i)
false =>
block.remove(i)
if bear.size() > 1
for i = bear.size() - 1 to 1 by 1
stuff = bear.get(i)
current = bear.get(0)
v = wichlap == 'Recent' ? i : 0
switch
stuff.btm > current.btm and stuff.btm < current.top =>
bear.remove(v)
stuff.top < current.top and stuff.btm > current.btm =>
bear.remove(v)
stuff.top > current.top and stuff.btm < current.btm =>
bear.remove(v)
stuff.top < current.top and stuff.top > current.btm =>
bear.remove(v)
if brFVG.size() > 1
for i = brFVG.size() - 1 to 1 by 1
stuff = brFVG.get(i)
current = brFVG.get(0)
switch
stuff.btm > current.btm and stuff.btm < current.top =>
brFVG.remove(i)
stuff.top < current.top and stuff.btm > current.btm =>
brFVG.remove(i)
stuff.top > current.top and stuff.btm < current.btm =>
brFVG.remove(i)
stuff.top < current.top and stuff.top > current.btm =>
brFVG.remove(i)
switch metric.move
1 =>
metric.brPOS := metric.brPOS + 1
metric.move := 2
metric.move
2 =>
metric.brPOS := metric.brPOS + 1
metric.move := 3
metric.move
3 =>
metric.blPOS := metric.blPOS + 1
metric.move := 1
metric.move
if obshowactivity
bin.bx.unshift(box.new(top = id.top, bottom = id.avg, left = id.loc, right
= id.xlocbl, border_color = na, bgcolor = obactup, xloc = xloc.bar_time))
bin.bx.unshift(box.new(top = id.avg, bottom = id.btm, left = id.loc, right
= id.xlocbr, border_color = na, bgcolor = obactdn, xloc = xloc.bar_time))
if showline
bin.ln.unshift(line.new(x1 = id.loc, x2 = time, y1 = id.avg, y2 = id.avg,
color = color.new(id.css, 0), xloc = xloc.bar_time, style = line.style_dashed))
if showmetric
if i == math.min(oblast - 1, full.size() - 1)
float tV = 0
array<float> dV = array.new<float>()
seq = math.min(oblast - 1, full.size() - 1)
for j = 0 to seq by 1
cV = full.get(j)
tV := tV + cV.vol
if j == seq
for y = 0 to seq by 1
dV.push(math.floor(full.get(y).vol / tV * 100))
ids = full.get(y)
bin.lb.unshift(label.new(bar_index - 1, ids.avg, textcolor
= color.new(ids.css, 0), style = label.style_label_left, size = obtxt.txSz(), color
= #ffffff00, text = str.tostring(math.round(full.get(y).vol, 3), format =
format.volume) + ' (' + str.tostring(dV.get(y)) + '%)'))
else
bin.bx.unshift(box.new(top = fvg.top, bottom = fvg.btm, left = fvg.loc,
right = fvg.bbloc, border_color = na, bgcolor = bull ? fvg_upcss : fvg_dncss, xloc
= xloc.bar_time))
bin.bx.unshift(box.new(top = fvg.top, bottom = fvg.btm, left = fvg.bbloc,
right = time, border_color = bull ? fvg_dncss : fvg_upcss, bgcolor = bull ?
fvg_dncss : fvg_upcss, xloc = xloc.bar_time, extend = ext))
if fvgline
bin.ln.unshift(line.new(x1 = fvg.loc, x2 = fvg.bbloc, y1 =
math.avg(fvg.top, fvg.btm), y2 = math.avg(fvg.top, fvg.btm), color = color.new(bull
? fvg_upcss : fvg_dncss, 0), xloc = xloc.bar_time))
bin.ln.unshift(line.new(x1 = fvg.bbloc, x2 = time, y1 =
math.avg(fvg.top, fvg.btm), y2 = math.avg(fvg.top, fvg.btm), color = color.new(bull
? fvg_dncss : fvg_upcss, 0), xloc = xloc.bar_time, extend = ext, style =
line.style_dashed))
//}
_ = ' ------------ –––––––––––––––––––––––––– FUNCTION
––––––––––––––––––––––––––– ------------
' //{
mapping() =>
var float up = na
var float dn = na
var float point = na
var int trend = 0
var int idx = na
var int sum = na
var int project = na
var array<chart.point> charts = array.new<chart.point>()
if na(up)
up := high
idx := bar_index
idx
if na(dn)
dn := low
idx := bar_index
idx
if high > up
if trend == -1
id = IDMIDX(false, idx)
charts.unshift(chart.point.from_time(time[id], low[id]))
idx := bar_index
point := low[id]
sum := time[id]
sum
up := high
dn := low
project := time
trend := 1
trend
if low < dn
if trend == 1
id = IDMIDX(true, idx)
charts.unshift(chart.point.from_time(time[id], high[id]))
idx := bar_index
point := high[id]
sum := time[id]
sum
up := high
dn := low
project := time
trend := -1
trend
if barstate.islast
var line ln = na
var polyline pl = na
ln.delete()
pl.delete()
ln := na
pl := na
ln := line.new(x1 = sum, x2 = project, y1 = point, y2 = trend == 1 ? up :
dn, xloc = xloc.bar_time, color = color.red)
pl := polyline.new(charts, line_color = mappingcss, xloc = xloc.bar_time,
line_style = mappingStyle.lstyle())
pl
dFVG() =>
[h2, l2, c1, o1, c, o, h, l, h1, l1, fvatr] = ghl()
var array<FVG> blFVG = array.new<FVG>()
var array<FVG> brFVG = array.new<FVG>()
bool upfvg = false
bool dnfvg = false
float blth = l1 + fvatr[1] * fvgthresh
float brth = h1 - fvatr[1] * fvgthresh
cc = timeframe.change()
switch
what_fvg == 'FVG' or what_fvg == 'Breakers' =>
if l > h2 and cc and c1 > blth
upfvg := true
upfvg
if upfvg[1]
if blFVG.size() > 0
fvg = blFVG.get(0)
if fvg.israid == true and fvg.active == false
fvg.active := true
fvg.raidloc := na
fvg.raidx2 := na
fvg.raidy := na
fvg.raidcs := #ffffff00
fvg.raidcs
blFVG.unshift(FVG.new(l[1], h2[1], time[3], false, na))
if dnfvg[1]
if brFVG.size() > 0
fvg = brFVG.get(0)
if fvg.israid == true and fvg.active == false
fvg = brFVG.get(0)
fvg.active := true
fvg.active := true
fvg.raidloc := na
fvg.raidx2 := na
fvg.raidy := na
fvg.raidcs := #ffffff00
fvg.raidcs
if blFVG.size() > 0
for [i, fvg] in blFVG
if not fvg.isbb
if fvg_src == 'Close' ? math.min(c, o) < fvg.btm : fvg_src ==
'Wick' ? l < fvg.btm : fvg_src == 'Avg' ? l < math.avg(fvg.top, fvg.btm) : false
fvg.isbb := true
fvg.bbloc := time
if what_fvg == 'FVG'
blFVG.remove(i)
else
if (fvg_src == 'Close' ? math.max(c, o) > fvg.top : fvg_src ==
'Wick' ? h > fvg.top : fvg_src == 'Avg' ? h > math.avg(fvg.top, fvg.btm) : false)
and what_fvg == 'Breakers'
blFVG.remove(i)
if brFVG.size() > 0
for [i, fvg] in brFVG
if not fvg.isbb
if fvg_src == 'Close' ? math.max(c, o) > fvg.top : fvg_src ==
'Wick' ? h > fvg.top : fvg_src == 'Avg' ? h > math.avg(fvg.top, fvg.btm) : false
fvg.isbb := true
fvg.bbloc := time
if what_fvg == 'FVG'
brFVG.remove(i)
else
if (fvg_src == 'Close' ? math.min(c, o) < fvg.btm : fvg_src ==
'Wick' ? l < fvg.btm : fvg_src == 'Avg' ? l < math.avg(fvg.top, fvg.btm) : false)
and what_fvg == 'Breakers'
brFVG.remove(i)
if fvgoverlap
overlapFVG(blFVG, brFVG)
if dispraid
for [i, fvg] in blFVG
if not fvg.israid and not fvg.isbb
if low < fvg.top and close > fvg.top
fvg.israid := true
fvg.raidloc := time
fvg.raidx2 := time
fvg.raidy := low
fvg.raidcs := chart.fg_color
fvg.raidcs
else
if low <= fvg.raidy and fvg.active == false and not fvg.isbb
fvg.active := true
fvg.raidx2 := time
fvg.raidx2
else
if fvg.active == false and not fvg.isbb
fvg.raidx2 := time
fvg.raidx2
fvg.active := true
fvg.raidx2 := time
fvg.raidx2
else
if fvg.active == false and not fvg.isbb
fvg.raidx2 := time
fvg.raidx2
if barstate.islast
if blFVG.size() > 0 and fvg_num > 0
for i = 0 to math.min(fvg_num - 1, blFVG.size() - 1) by 1
fvg = blFVG.get(i)
dispFVG(fvg, i, true)
structure(color upcss, color dncss, bool draw, bool internal, int limit) =>
var structure ms = structure.new(start = 0)
var array<ob> blob = array.new<ob>()
var array<ob> brob = array.new<ob>()
var array<drawms> bldw = array.new<drawms>()
var array<drawms> brdw = array.new<drawms>()
var array<sellbuyside> sellside = array.new<sellbuyside>()
var array<sellbuyside> buyside = array.new<sellbuyside>()
bool crossup = false
bool crossdn = false
var float up = na
var float dn = na
idbull = ms.find(false, false, true)
idbear = ms.find(true, false, true)
btmP = obmode == 'Length' ? high[idbear] - 1 * atr[idbear] < low[idbear] ?
low[idbear] : high[idbear] - 1 * atr[idbear] : low[idbear]
topP = obmode == 'Length' ? low[idbull] + 1 * atr[idbull] > high[idbull] ?
high[idbull] : low[idbull] + 1 * atr[idbull] : high[idbull]
atr = ta.atr(200)
buy = low + atr
sel = high - atr
ph = ta.pivothigh(high, mslen, mslen)
pl = ta.pivotlow(low, mslen, mslen)
var array<int> phn = array.new<int>(1, na)
var array<int> pln = array.new<int>(1, na)
var array<float> php = array.new<float>(1, na)
var array<float> plp = array.new<float>(1, na)
if internal
blob.clear()
brob.clear()
if bool(ph)
phn.unshift(bar_index[mslen])
php.unshift(high[mslen])
if bool(pl)
pln.unshift(bar_index[mslen])
plp.unshift(low[mslen])
if php.size() > 0
if high > php.get(0)
php.clear()
phn.clear()
if plp.size() > 0
if low < plp.get(0)
plp.clear()
pln.clear()
if na(up)
up := high
up
if na(dn)
dn := low
dn
if high > up
up := high
dn := low
crossup := true
crossup
if low < dn
up := high
dn := low
crossdn := true
crossdn
if ms.start == 0
ms := structure.new(bar_index, na, high, low, bar_index, bar_index, 0, 1,
na, bar_index)
if draw
bldw.unshift(drawms.new(time, time, high, 'CHoCH', upcss,
line.style_dashed))
brdw.unshift(drawms.new(time, time, low, 'CHoCH', dncss,
line.style_dashed))
ms.upsweep := false
ms.dnsweep := false
if ms.start == 1
switch
low <= ms.choch and close >= ms.choch and buildsweep =>
ms.dnsweep := true
ms.choch := low
ms.xloc := bar_index
if draw
dw = brdw.get(0)
dw.x2 := time
dw.style := line.style_dotted
dw.txt := 'x'
brdw.unshift(drawms.new(time, time, low, 'CHoCH', dncss,
line.style_dashed))
high >= ms.bos and close <= ms.bos and buildsweep =>
ms.upsweep := true
ms.bos := high
ms.xloc := bar_index
if draw
dw = bldw.get(0)
dw.x2 := time
dw.style := line.style_dotted
dw.txt := 'x'
bldw.unshift(drawms.new(time, time, high, 'CHoCH', upcss,
line.style_dashed))
ms.txt := 'choch'
lc.start := true
lc.count := 0
blob.fnOB(true, topP, idbull)
ms.trend := -1
ms.choch := ms.bos
ms.bos := na
ms.start := 2
ms.loc := bar_index
ms.main := low
ms.temp := ms.loc
ms.xloc := bar_index
if draw
dw = brdw.get(0)
dw.x2 := time
dw.style := internal ? line.style_dashed : line.style_solid
dw.style
ms.txt := 'choch'
lc.start := true
lc.count := 0
brob.fnOB(false, btmP, idbear)
ms.trend := 1
ms.choch := ms.choch
ms.bos := na
ms.start := 2
ms.loc := bar_index
ms.main := high
ms.temp := ms.loc
ms.xloc := bar_index
if draw
dw = bldw.get(0)
dw.x2 := time
dw.style := internal ? line.style_dashed : line.style_solid
dw.style
if ms.start == 2
switch ms.trend
-1 =>
if low <= ms.main
ms.main := low
ms.temp := bar_index
ms.temp
if bar_index % mslen * 2 == 0
if not na(ms.bos) and msmode == 'Adjusted Points' and
php.size() > 0
if php.get(0) < ms.choch
// ms.xloc := phn.get(0)
ms.choch := php.get(0)
ms.loc := phn.get(0)
ms.xloc := phn.get(0)
ms.temp := phn.get(0)
if draw
choch = bldw.get(0)
choch.x1 := time[bar_index - phn.get(0)]
choch.x2 := time
choch.y := php.get(0)
choch.y
if na(ms.bos)
if crossup and close > open and close[1] > open[1]
ms.bos := ms.main
ms.loc := ms.temp
ms.xloc := ms.loc
if draw
brdw.unshift(drawms.new(time[bar_index - ms.loc], time,
low[bar_index - ms.loc], 'BOS', dncss, line.style_dashed))
if draw
choch = bldw.get(0)
choch.x2 := time
choch.x2
switch
low <= ms.bos and close >= ms.bos and not na(ms.bos) and
buildsweep =>
ms.dnsweep := true
ms.bos := low
if draw
dw = brdw.get(0)
dw.x2 := time
dw.style := line.style_dotted
dw.txt := 'x'
brdw.unshift(drawms.new(time, time, low, 'BOS', dncss,
line.style_dashed))
ms.xloc := bar_index
ms.xloc
ms.txt := 'bos'
ms.zz := ms.bos
ms.zn := bar_index
lc.start := true
lc.count := 0
brob.fnOB(false, btmP, idbear)
id = ms.find(true, false, false)
ms.xloc := bar_index
ms.bos := na
ms.choch := high[id]
ms.loc := bar_index[id]
if draw
dw = brdw.get(0)
dw.x2 := time
dw.style := internal ? line.style_dashed :
line.style_solid
choch = bldw.get(0)
choch.x1 := time[id]
choch.x2 := time
choch.y := high[id]
choch.y
switch
high >= ms.choch and close <= ms.choch and buildsweep =>
ms.upsweep := true
ms.choch := high
ms.xloc := bar_index
if draw
dw = bldw.get(0)
dw.x2 := time
dw.style := line.style_dotted
dw.txt := 'x'
bldw.unshift(drawms.new(time, time, high, 'CHoCH', upcss,
line.style_dashed))
ms.txt := 'choch'
ms.zz := ms.choch
ms.zn := bar_index
lc.start := true
lc.count := 0
blob.fnOB(true, topP, idbull)
id = ms.find(false, false, false)
switch
na(ms.bos) =>
ms.choch := low[id]
if draw
brdw.unshift(drawms.new(time, time, low, 'BOS',
dncss, line.style_dashed))
choch = brdw.get(0)
choch.x1 := time[bar_index - ms.temp]
choch.x1
=>
ms.choch := ms.bos //low[id + 1] < low[id] ? low[id +
1] : low[id]
ms.choch
ms.bos := na
ms.main := high
ms.trend := 1
ms.loc := bar_index
ms.xloc := bar_index
ms.temp := ms.loc
if draw
dw = bldw.get(0)
dw.x2 := time
dw.txt := 'CHoCH'
dw.style := internal ? line.style_dashed :
line.style_solid
choch = brdw.get(0)
choch.x2 := time
choch.y := ms.choch
choch.txt := 'CHoCH'
choch.txt
ms.xloc := bar_index
blarea.normal := false
blarea.normal
1 =>
if na(ms.bos)
if crossdn and close < open and close[1] < open[1]
ms.bos := ms.main
ms.loc := ms.temp
ms.xloc := ms.loc
if draw
bldw.unshift(drawms.new(time[bar_index - ms.loc], time,
high[bar_index - ms.loc], 'BOS', upcss, line.style_dashed))
if bar_index % mslen * 2 == 0
if not na(ms.bos) and msmode == 'Adjusted Points' and
plp.size() > 0
if plp.get(0) > ms.choch
// ms.xloc := pln.get(0)
ms.choch := plp.get(0)
ms.loc := pln.get(0)
ms.xloc := pln.get(0)
ms.temp := pln.get(0)
// ms.loc := pln.get(0)
if draw
choch = brdw.get(0)
choch.x1 := time[bar_index - pln.get(0)]
choch.x2 := time
choch.y := plp.get(0)
choch.y
if draw
choch = brdw.get(0)
choch.x2 := time
choch.x2
switch
high >= ms.bos and close <= ms.bos and not na(ms.bos) and
buildsweep =>
ms.upsweep := true
ms.bos := high
if draw
dw = bldw.get(0)
dw.x2 := time
dw.style := line.style_dotted
dw.txt := 'x'
bldw.unshift(drawms.new(time, time, high, 'BOS', upcss,
line.style_dashed))
ms.xloc := bar_index
ms.xloc
ms.txt := 'bos'
ms.zz := ms.bos
ms.zn := bar_index
lc.start := true
lc.count := 0
blob.fnOB(true, topP, idbull)
id = ms.find(false, false, false)
ms.xloc := bar_index
ms.bos := na
ms.choch := low[id]
ms.loc := bar_index[id]
if draw
dw = bldw.get(0)
dw.x2 := time
dw.style := internal ? line.style_dashed :
line.style_solid
choch = brdw.get(0)
choch.x1 := time[id]
choch.x2 := time
choch.y := low[id]
choch.y
switch
low <= ms.choch and close >= ms.choch and buildsweep =>
ms.dnsweep := true
ms.choch := low
ms.xloc := bar_index
if draw
dw = brdw.get(0)
dw.x2 := time
dw.style := line.style_dotted
dw.txt := 'x'
brdw.unshift(drawms.new(time, time, low, 'CHoCH', dncss,
line.style_dashed))
ms.xloc := bar_index
ms.xloc
if blob.size() > 0
ob = blob.get(0)
if not ob.isbb
if low < ob.top
if blobenter.normal == false
blobenter.normal := true
blobenter.normal
else
if high > ob.btm
if blobenter.breaker == false
blobenter.breaker := true
blobenter.breaker
if brob.size() > 0
ob = brob.get(0)
if not ob.isbb
if high > ob.btm
if brobenter.normal == false
brobenter.normal := true
brobenter.normal
else
if low < ob.top
if brobenter.breaker == false
brobenter.breaker := true
brobenter.breaker
if blob.size() > 0
for [i, metric] in blob
metric.umt()
if brob.size() > 0
for [i, metric] in brob
metric.umt()
if barstate.islast
if blob.size() > 0
for i = 0 to math.min(oblast - 1, blob.size() - 1) by 1
obs = blob.get(i)
display(obs, blob, i)
if brob.size() > 0
for i = 0 to math.min(oblast - 1, brob.size() - 1) by 1
obs = brob.get(i)
display(obs, brob, i)
if msbubble
bin.lb.unshift(label.new(x = obj.x1, y = obj.y, xloc =
xloc.bar_time, color = color.new(obj.css, 80), style = label.style_circle, size =
size.tiny))
for i = 0 to brdw.size() - 1 by 1
obj = brdw.get(i)
if i <= limit
bin.ln.unshift(line.new(x1 = obj.x1, x2 = obj.x2, y1 = obj.y, y2 =
obj.y, color = obj.css, style = obj.style, xloc = xloc.bar_time))
bin.lb.unshift(label.new(x = int(math.avg(bin.ln.get(0).get_x1(),
bin.ln.get(0).get_x2())), y = obj.y, xloc = xloc.bar_time, color = #ffffff00, style
= label.style_label_up, textcolor = obj.css, size = mstext.txSz(), text = obj.txt))
if msbubble
bin.lb.unshift(label.new(x = obj.x1, y = obj.y, xloc =
xloc.bar_time, color = color.new(obj.css, 80), style = label.style_circle, size =
size.tiny))
ms
//}
_ = ' ------------ –––––––––––––––––––––––––– EXECUTION
––––––––––––––––––––––––––– ------------
' //{
structure ms = na
if windowsis
if bar_index > last_bar_index - mswindow
ms := structure(swingcssup, swingcssdn, showSwing, false, swingLimit)
ms
if windowsis == false
ms := structure(swingcssup, swingcssdn, showSwing, false, swingLimit)
ms
color css = na
if fvg_enable
dFVG()
if showMapping
mapping()