Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 11

//@version=4

//
study(title="Basic Pivott Boss Tool", shorttitle="PivottBoss Tool",
overlay=true,max_bars_back=4000)

getSeries(e, timeFrame) => security(syminfo.tickerid, timeFrame, e,


lookahead=barmerge.lookahead_on)

vw = input(false,"VWAP")
vwaplength= input(title="Length", type=input.integer, defval=1)
DCPR = input(true, title="Show Daily CPR")
WCPR = input(false, title="Show Weekly CPR")
MCPR = input(false, title="Show Monthly CPR")
YCPRPlot = input(title = "Show Yearly CPR", type=input.bool, defval=false)

DCAM = input(true, title="Show Daily Camarilla")


WCAM = input(false, title="Show Weekly Camarilla")
MCAM = input(false, title="Show Monthly Camarilla")

PrevDHL = input(true, title="Show Previous Day High / Low")

/// VWAP ///


cvwap = ema(vwap,vwaplength)
plotvwap = plot(vw ? cvwap : na ,color= color.yellow, transp=0, title = "VWAP",
linewidth=1)

//Previous D datas
PrevDClose = getSeries(close[1], 'D')
PrevDOpen = getSeries(open[1], 'D')
PrevDHigh = getSeries(high[1], 'D')
PrevDLow = getSeries(low[1], 'D')

//Daily CPR
DPivot = (PrevDHigh + PrevDLow + PrevDClose) / 3.0
DBC = (PrevDHigh + PrevDLow) / 2.0
DTC = (DPivot - DBC) + DPivot

//Daily Camarilla

dh5 = (PrevDHigh/PrevDLow) * PrevDClose


dh4 = PrevDClose + (PrevDHigh - PrevDLow) * 1.1 / 2.0
dh3 = PrevDClose + (PrevDHigh - PrevDLow) * 1.1 / 4.0
dl3 = PrevDClose - (PrevDHigh - PrevDLow) * 1.1 / 4.0
dl4 = PrevDClose - (PrevDHigh - PrevDLow) * 1.1 / 2.0
dl5 = PrevDClose - (dh5 - PrevDClose)

dh6 = dh5 + 1.168 * (dh5 - dh4)


dl6 = PrevDClose - (dh6 - PrevDClose)

plot(DCPR and DPivot and (timeframe.isintraday) ? DPivot : na, title="D: Pivot",


color=color.aqua, linewidth=1, style=plot.style_stepline, offset=0, transp=0)
p1=plot(DCPR and DBC and (timeframe.isintraday) ? DBC : na, title="D: BC",
color=color.aqua, linewidth=1, style=plot.style_stepline, offset=0, transp=0)
p2=plot(DCPR and DTC and (timeframe.isintraday) ? DTC : na, title="D: TC",
color=color.aqua, linewidth=1, style=plot.style_stepline, offset=0, transp=0)
fill(p1,p2,color=color.aqua,transp=95)

plot(PrevDHL and PrevDHigh and (timeframe.isintraday) ? PrevDHigh : na,


title="PDH", color=color.gray, linewidth=1,style=plot.style_circles, offset=0,
transp=0)
plot(PrevDHL and PrevDLow and (timeframe.isintraday) ? PrevDLow : na, title="PDL",
color=color.gray, linewidth=1,style=plot.style_circles, offset=0, transp=0)

plot(DCAM and dh6 and (timeframe.isintraday) ? dh6 : na, title="D: H6", color=dh6
!= dh6[1] ? na : color.green, linewidth=2, style=plot.style_line, offset=0,
transp=0)
plot(DCAM and dh5 ? dh5 : na, title="H5", color=dh5 != dh5[1] ? na : color.red,
linewidth=1, style=plot.style_line, offset=0)
plot(DCAM and dh4 ? dh4 : na, title="H4", color=dh4 != dh4[1] ? na :
color.green, linewidth=1, style=plot.style_line, offset=0)
plot(DCAM and dh3 ? dh3 : na, title="H3", color=dh3 != dh3[1] ? na : color.red,
linewidth=2, style=plot.style_line, offset=0)
plot(DCAM and dl3 ? dl3 : na, title="L3", color=dl3 != dl3[1] ? na :
color.green, linewidth=2, style=plot.style_line, offset=0)
plot(DCAM and dl4 ? dl4 : na, title="L4", color=dl4 != dl4[1] ? na : color.red,
linewidth=1, style=plot.style_line, offset=0)
plot(DCAM and dl5 ? dl5 : na, title="L5", color=dl5 != dl5[1] ? na :
color.green, linewidth=1, style=plot.style_line, offset=0)
plot(DCAM and dl6 and (timeframe.isintraday) ? dl6 : na, title="D: L6", color=dl6
!= dl6[1] ? na : color.red, linewidth=2, style=plot.style_line, offset=0, transp=0)
//Previous W datas
PrevWClose = getSeries(close[1], 'W')
PrevWOpen = getSeries(open[1], 'W')
PrevWHigh = getSeries(high[1], 'W')
PrevWLow = getSeries(low[1], 'W')

//Weekly CPR
WPivot = (PrevWHigh + PrevWLow + PrevWClose) / 3
WBC = (PrevWHigh + PrevWLow) / 2
WTC = (WPivot - WBC ) + WPivot

//Weekly Camarilla
wh5 = (PrevWHigh/PrevWLow) * PrevWClose
wh4 = PrevWClose + (PrevWHigh - PrevWLow) * 1.1 / 2.0
wh3 = PrevWClose + (PrevWHigh - PrevWLow) * 1.1 / 4.0
wl3 = PrevWClose - (PrevWHigh - PrevWLow) * 1.1 / 4.0
wl4 = PrevWClose - (PrevWHigh - PrevWLow) * 1.1 / 2.0
wl5 = PrevWClose - (wh5 - PrevWClose)

//PrevWHL = input(true, title="Show Previous Week High / Low")

plot(WCPR and WPivot and (timeframe.isintraday or timeframe.isdaily) ? WPivot : na,


title="W: Pivot", color=color.fuchsia, linewidth=1, style=plot.style_stepline,
offset=0, transp=0)
p3=plot(WCPR and WBC and (timeframe.isintraday or timeframe.isdaily) ? WBC : na,
title="W: BC", color=color.fuchsia, linewidth=1, style=plot.style_stepline,
offset=0, transp=0)
p4=plot(WCPR and WTC and (timeframe.isintraday or timeframe.isdaily) ? WTC : na,
title="W: TC", color=color.fuchsia, linewidth=1, style=plot.style_stepline,
offset=0, transp=0)
fill(p3,p4, color=color.fuchsia,transp=95)

//plot(PrevWHL and PrevWHigh and (timeframe.isintraday or timeframe.isdaily) ?


PrevWHigh : na, title="PrevWHigh", color=color.orange, linewidth=2,
style=plot.style_circles, offset=0, transp=40)
//plot(PrevWHL and PrevWLow and (timeframe.isintraday or timeframe.isdaily) ?
PrevWLow : na, title="PrevWLow", color=color.orange, linewidth=2,
style=plot.style_circles, offset=0, transp=40)
plot(WCAM and wh5 and (timeframe.isintraday or timeframe.isdaily) ? wh5 : na,
title="W: H5", color=color.purple, linewidth=1, style=plot.style_circles, transp=0)
plot(WCAM and wh4 and (timeframe.isintraday or timeframe.isdaily) ? wh4 : na,
title="W: H4", color=color.purple, linewidth=1, style=plot.style_circles, transp=0)
plot(WCAM and wh3 and (timeframe.isintraday or timeframe.isdaily) ? wh3 : na,
title="W: h3", color=color.red, linewidth=1, style=plot.style_circles, transp=0)
plot(WCAM and wl3 and (timeframe.isintraday or timeframe.isdaily) ? wl3 : na,
title="W: L3", color=color.teal, linewidth=1, style=plot.style_circles,transp=0)
plot(WCAM and wl4 and (timeframe.isintraday or timeframe.isdaily) ? wl4 : na,
title="W: L4", color=color.purple, linewidth=1, style=plot.style_circles, transp=0)
plot(WCAM and wl5 and (timeframe.isintraday or timeframe.isdaily) ? wl5 : na,
title="W: L5", color=color.purple, linewidth=1, style=plot.style_circles, transp=0)

//Previous M datas
PrevMClose = getSeries(close[1], 'M')
PrevMOpen = getSeries(open[1], 'M')
PrevMHigh = getSeries(high[1], 'M')
PrevMLow = getSeries(low[1], 'M')

//Monthly CPR
MPivot = (PrevMHigh + PrevMLow + PrevMClose) / 3
MBC = (PrevMHigh + PrevMLow) / 2
MTC = (MPivot - MBC ) + MPivot

//Monthly Camarilla
mh5 = (PrevMHigh/PrevMLow) * PrevMClose
mh4 = PrevMClose + (PrevMHigh - PrevMLow) * 1.1 / 2.0
mh3 = PrevMClose + (PrevMHigh - PrevMLow) * 1.1 / 4.0
ml3 = PrevMClose - (PrevMHigh - PrevMLow) * 1.1 / 4.0
ml4 = PrevMClose - (PrevMHigh - PrevMLow) * 1.1 / 2.0
ml5 = PrevMClose - (mh5 - PrevMClose)

//MPivot = input(true, title="Show Mly Pivot")

//PrevMHL = input(false, title="Show Previous Month High / Low")

plot(MCPR and MPivot and (timeframe.isintraday or timeframe.isdaily or


timeframe.isweekly) ? MPivot : na, title="M: Pivot", color=color.lime, linewidth=1,
style=plot.style_stepline, offset=0, transp=0)
p5=plot(MCPR and MBC and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly) ? MBC : na, title="M: BC", color=color.lime, linewidth=1,
style=plot.style_stepline, offset=0, transp=0)
p6=plot(MCPR and MTC and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly) ? MTC : na, title="M: TC", color=color.lime, linewidth=1,
style=plot.style_stepline, offset=0, transp=0)
fill(p5,p6,color=color.lime,transp=95)

//plot(PrevMHL and PrevMHigh and (timeframe.isintraday or timeframe.isdaily or


timeframe.isweekly) ? PrevMHigh : na, title="PrevMHigh", color=color.orange,
linewidth=2, style=plot.style_stepline, offset=0, transp=40)
//plot(PrevMHL and PrevMLow and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly) ? PrevMLow : na, title="PrevMLow", color=color.orange,
linewidth=2, style=plot.style_stepline, offset=0, transp=40)
plot(MCAM and mh5 and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly) ? mh5 : na, title="M: H5", color=color.olive, linewidth=2,
offset=0, transp=0)
plot(MCAM and mh4 and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly) ? mh4 : na, title="M: H4", color=color.olive,
linewidth=2,offset=0, transp=0)
plot(MCAM and mh3 and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly) ? mh3 : na, title="M: H3", color=color.red, linewidth=2,
offset=0, transp=0)
plot(MCAM and ml3 and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly) ? ml3 : na, title="M: L3", color=color.green,
linewidth=2,offset=0, transp=0)
plot(MCAM and ml4 and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly) ? ml4 : na, title="M: L4", color=color.olive, linewidth=2,
offset=0, transp=0)
plot(MCAM and ml5 and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly) ? ml5 : na, title="M: L5", color=color.olive, linewidth=2,
offset=0, transp=0)

/////Yearly CPR /////////


pivot = (high + low + close) /3 //Central Pivot
BC = (high + low) / 2 //Below Central pivot
TC = (pivot - BC) + pivot //Top Central pivot

YPivot = security(syminfo.tickerid, "12M", pivot[1], barmerge.gaps_off,


barmerge.lookahead_on)
YBC = security(syminfo.tickerid, "12M", BC[1], barmerge.gaps_off,
barmerge.lookahead_on)
YTC = security(syminfo.tickerid, "12M", TC[1], barmerge.gaps_off,
barmerge.lookahead_on)

plot(YCPRPlot ? YPivot : na, title = "Y:Pivot" , color = color.yellow, style =


plot.style_stepline, linewidth =1)
y1=plot(YCPRPlot ? (YBC <= YTC ? YBC : YTC) : na , title = "Y:BC" , color =
color.yellow, style = plot.style_stepline, linewidth =1)
y2=plot(YCPRPlot ? (YTC >= YBC ? YTC : YBC) : na , title = "Y:TC" , color =
color.yellow, style = plot.style_stepline, linewidth =1)
fill(y1,y2,color=color.yellow, transp=95)

//Tomorrow's Pivot Calculation


tp = input(false, title="Show Next CPR (Use 15 min TF)")
tpr = input(title="Next CPR resolution", defval="D", options=["D", "W", "M",
"12M"])
tpopen = security(syminfo.tickerid, tpr, open, barmerge.gaps_off,
barmerge.lookahead_on)
tphigh = security(syminfo.tickerid, tpr, high, barmerge.gaps_off,
barmerge.lookahead_on)
tplow = security(syminfo.tickerid, tpr, low, barmerge.gaps_off,
barmerge.lookahead_on)
tpclose = security(syminfo.tickerid, tpr, close, barmerge.gaps_off,
barmerge.lookahead_on)

tppivot = (tphigh + tplow + tpclose) / 3.0


tpbc = (tphigh + tplow) / 2.0
tptc = (tppivot - tpbc) + tppivot

//UX Input Arguments


tpPPC = color.blue
tpBCC = color.blue
tpTCC = color.blue

plot(tp and tppivot ? tppivot : na, title="Next Pivot", color=tpPPC, linewidth=2,


style=plot.style_cross, offset=25, transp=0)
tp1=plot(tp and tpbc ? tpbc: na, title="Next BC", color=tpBCC, linewidth=2,
style=plot.style_cross, offset=25, transp=0)
tp2=plot(tp and tptc ? tptc : na, title="Next TC", color=tpTCC, linewidth=2,
style=plot.style_cross, offset=25, transp=0)
fill(tp1,tp2,transp=95)

//Next Day Camarilla


tc = input(false, title="Show Next Camarilla (Use 15 min TF)")
tcr = input(title="Next Cam resolution", defval="D", options=["D", "W", "M",
"12M"])
tcopen = security(syminfo.tickerid, tpr, open, barmerge.gaps_off,
barmerge.lookahead_on)
tchigh = security(syminfo.tickerid, tpr, high, barmerge.gaps_off,
barmerge.lookahead_on)
tclow = security(syminfo.tickerid, tpr, low, barmerge.gaps_off,
barmerge.lookahead_on)
tcclose = security(syminfo.tickerid, tpr, close, barmerge.gaps_off,
barmerge.lookahead_on)

tdh5 = (tchigh/tclow) * tcclose


tdh4 = tcclose + (tchigh - tclow) * 1.1 / 2.0
tdh3 = tcclose + (tchigh - tclow) * 1.1 / 4.0
tdl3 = tcclose - (tchigh - tclow) * 1.1 / 4.0
tdl4 = tcclose - (tchigh - tclow) * 1.1 / 2.0
tdl5 = tcclose - (tdh5 - tcclose)

plot(tc and tdh5 and (timeframe.isintraday) ? tdh5 : na, title="Next H5",


color=color.red, linewidth=2, style=plot.style_cross,offset=25, transp=0)
plot(tc and tdh4 and (timeframe.isintraday) ? tdh4 : na, title="Next H4",
color=color.green, linewidth=2, style=plot.style_cross,offset=25, transp=0)
plot(tc and tdh3 and (timeframe.isintraday) ? tdh3 : na, title="Next H3",
color=color.red, linewidth=2, style=plot.style_cross, offset=25, transp=0)
plot(tc and tdl3 and (timeframe.isintraday) ? tdl3 : na, title="Next L3",
color=color.green, linewidth=2, style=plot.style_cross, offset=25, transp=0)
plot(tc and tdl4 and (timeframe.isintraday) ? tdl4 : na, title="Next L4",
color=color.red, linewidth=2, style=plot.style_cross,offset=25, transp=0)
plot(tc and tdl5 and (timeframe.isintraday) ? tdl5 : na, title="Next L5",
color=color.green, linewidth=2, style=plot.style_cross,offset=25, transp=0)

p = input(false, title="Show PEMA")


//PEMA
FastMA=input(defval=8)
MiddleMA=input(defval=13)
SlowMA=input(defval=21)
ema8=ema(hlc3,FastMA)
ema13=ema(hlc3,MiddleMA)
ema21=ema(hlc3,SlowMA)
p11=plot(p and ema8 ? ema8:na,color=hlc3[1] > ema8 and hlc3 > ema8 ? color.green :
color.red, linewidth=1)
p22=plot(p and ema13 ? ema13:na,color=#bdb76b,linewidth=1)
p33=plot(p and ema21 ? ema21:na,color=hlc3[1] < ema21 and hlc3 < ema21 ?
color.red : color.green, linewidth=1)
fill(p11, p33, color=ema8>ema21 ? color.green:color.red, transp=90, editable=true )

// Money Zone Levels


// ||-- Inputs:
mz = input(false, title="Show Money Zone Levels")
session_timeframe = input("D" , options = ["D" , "W" , "M"])
percent_of_tpo = input(0.70)
tf_high = high
tf_low = low
tf_close = close
// ||-- Bars since session started:
session_bar_counter = bar_index - valuewhen(change(time(session_timeframe)) != 0,
bar_index, 0)
//plot(session_bar_counter)
// ||-- session high, low, range:
session_high = tf_high
session_low = tf_low
session_range = tf_high - tf_low

session_high := nz(session_high[1], tf_high)


session_low := nz(session_low[1], tf_low)
session_range := nz(session_high - session_low, 0.0)

// ||-- recalculate session high, low and range:


if session_bar_counter == 0
session_high := tf_high
session_low := tf_low
session_range := tf_high - tf_low
session_range
if tf_high > session_high[1]
session_high := tf_high
session_range := session_high - session_low
session_range
if tf_low < session_low[1]
session_low := tf_low
session_range := session_high - session_low
session_range
//plot(series=session_high, title='Session High', color=blue)
//plot(series=session_low, title='Session Low', color=blue)
//plot(series=session_range, title='Session Range', color=black)
// ||-- define tpo section range:
tpo_section_range = session_range / 21
// ||-- function to get the frequency a specified range is visited:
f_frequency_of_range(_src, _upper_range, _lower_range, _length) =>
_adjusted_length = _length < 1 ? 1 : _length
_frequency = 0
for _i = 0 to _adjusted_length - 1 by 1
if _src[_i] >= _lower_range and _src[_i] <= _upper_range
_frequency := _frequency + 1
_frequency
_return = nz(_frequency, 0) // _adjusted_length
_return
// ||-- frequency the tpo range is visited:
tpo_00 = f_frequency_of_range(tf_close, session_high, session_high -
tpo_section_range * 1, session_bar_counter)
tpo_01 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 1,
session_high - tpo_section_range * 2, session_bar_counter)
tpo_02 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 2,
session_high - tpo_section_range * 3, session_bar_counter)
tpo_03 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 3,
session_high - tpo_section_range * 4, session_bar_counter)
tpo_04 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 4,
session_high - tpo_section_range * 5, session_bar_counter)
tpo_05 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 5,
session_high - tpo_section_range * 6, session_bar_counter)
tpo_06 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 6,
session_high - tpo_section_range * 7, session_bar_counter)
tpo_07 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 7,
session_high - tpo_section_range * 8, session_bar_counter)
tpo_08 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 8,
session_high - tpo_section_range * 9, session_bar_counter)
tpo_09 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 9,
session_high - tpo_section_range * 10, session_bar_counter)
tpo_10 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 10,
session_high - tpo_section_range * 11, session_bar_counter)
tpo_11 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 11,
session_high - tpo_section_range * 12, session_bar_counter)
tpo_12 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 12,
session_high - tpo_section_range * 13, session_bar_counter)
tpo_13 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 13,
session_high - tpo_section_range * 14, session_bar_counter)
tpo_14 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 14,
session_high - tpo_section_range * 15, session_bar_counter)
tpo_15 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 15,
session_high - tpo_section_range * 16, session_bar_counter)
tpo_16 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 16,
session_high - tpo_section_range * 17, session_bar_counter)
tpo_17 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 17,
session_high - tpo_section_range * 18, session_bar_counter)
tpo_18 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 18,
session_high - tpo_section_range * 19, session_bar_counter)
tpo_19 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 19,
session_high - tpo_section_range * 20, session_bar_counter)
tpo_20 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 20,
session_high - tpo_section_range * 21, session_bar_counter)
// ||-- function to retrieve a specific tpo value
f_get_tpo_count_1(_value) =>
_return = 0.0
if _value == 0
_return := tpo_00
_return
if _value == 1
_return := tpo_01
_return
if _value == 2
_return := tpo_02
_return
if _value == 3
_return := tpo_03
_return
if _value == 4
_return := tpo_04
_return
if _value == 5
_return := tpo_05
_return
if _value == 6
_return := tpo_06
_return
if _value == 7
_return := tpo_07
_return
if _value == 8
_return := tpo_08
_return
if _value == 9
_return := tpo_09
_return
if _value == 10
_return := tpo_10
_return
if _value == 11
_return := tpo_11
_return
if _value == 12
_return := tpo_12
_return
if _value == 13
_return := tpo_13
_return
if _value == 14
_return := tpo_14
_return
if _value == 15
_return := tpo_15
_return
if _value == 16
_return := tpo_16
_return
if _value == 17
_return := tpo_17
_return
if _value == 18
_return := tpo_18
_return
if _value == 19
_return := tpo_19
_return
if _value == 20
_return := tpo_20
_return
_return
f_get_tpo_count_2(_value) =>
_return = 0.0
if _value == 0
_return := tpo_00
_return
if _value == 1
_return := tpo_01
_return
if _value == 2
_return := tpo_02
_return
if _value == 3
_return := tpo_03
_return
if _value == 4
_return := tpo_04
_return
if _value == 5
_return := tpo_05
_return
if _value == 6
_return := tpo_06
_return
if _value == 7
_return := tpo_07
_return
if _value == 8
_return := tpo_08
_return
if _value == 9
_return := tpo_09
_return
if _value == 10
_return := tpo_10
_return
if _value == 11
_return := tpo_11
_return
if _value == 12
_return := tpo_12
_return
if _value == 13
_return := tpo_13
_return
if _value == 14
_return := tpo_14
_return
if _value == 15
_return := tpo_15
_return
if _value == 16
_return := tpo_16
_return
if _value == 17
_return := tpo_17
_return
if _value == 18
_return := tpo_18
_return
if _value == 19
_return := tpo_19
_return
if _value == 20
_return := tpo_20
_return
_return

tpo_sum = 0.0
current_poc_position = 0.0
//Modified by Naga Chaitanya:)
current_poc_value = 0.0
for _i = 0 to 20 by 1
_get_tpo_value = f_get_tpo_count_1(_i)
tpo_sum := tpo_sum + _get_tpo_value
if _get_tpo_value > current_poc_value
current_poc_position := _i
current_poc_value := _get_tpo_value
current_poc_value
//plot(series=tpo_sum, title='tpo_sum', color=red)
poc_upper = session_high - tpo_section_range * current_poc_position
poc_lower = session_high - tpo_section_range * (current_poc_position + 1)
//plot(series=poc_upper, title='POC Upper', color=black)
//plot(series=poc_lower, title='POC Lower', color=black)
//plot(series=current_poc_position, title='current_poc_position', color=blue)
//plot(series=current_poc_value, title='current_poc_value', color=blue)

// ||-- get value area high/low


vah_position = current_poc_position
val_position = current_poc_position
current_sum = current_poc_value

for _i = 0 to 20 by 1
if current_sum < tpo_sum * percent_of_tpo
vah_position := max(0, vah_position - 1)
current_sum := current_sum + f_get_tpo_count_2(round(vah_position))
current_sum
if current_sum < tpo_sum * percent_of_tpo
val_position := min(20, val_position + 1)
current_sum := current_sum + f_get_tpo_count_2(round(val_position))
current_sum

vah_value = session_high - tpo_section_range * vah_position


val_value = session_high - tpo_section_range * (val_position + 1)

//plot(series=vah_value, title='VAH', color=color.navy)


//plot(series=val_value, title='VAL', color=color.navy)
//plot(series=current_sum, title='SUM', color=color.red)
//plot(series=valuewhen(session_bar_counter == 0, vah_value[1], 0), title='VAH',
color=color.navy, trackprice=true, offset=1, show_last=1)
//plot(series=valuewhen(session_bar_counter == 0, val_value[1], 0), title='VAL',
color=color.navy, trackprice=true, offset=1, show_last=1)

f_gapper(_return_value) =>
_return = _return_value
if session_bar_counter == 0
_return := na
_return
_return

series1=f_gapper(valuewhen(session_bar_counter == 0, vah_value[1], 0))


series2=f_gapper(valuewhen(session_bar_counter == 0, val_value[1], 0))
series3=f_gapper(valuewhen(session_bar_counter == 0, poc_upper[1], 0))
series4=f_gapper(valuewhen(session_bar_counter == 0, poc_lower[1], 0))
plot(mz and series1 ? series1:na, title='MZ: VAH', color=color.yellow, linewidth=2,
style=plot.style_linebr, transp=0)
plot(mz and series2 ? series2:na, title='MZ: VAL', color=color.yellow, linewidth=2,
style=plot.style_linebr, transp=0)
plot(mz and series3 ? series3:na, title='MZ: POC Upper', color=color.black,
linewidth=2, style=plot.style_linebr, transp=0)
plot(mz and series4 ? series4:na, title='MZ: POC Lower', color=color.black,
linewidth=2, style=plot.style_linebr, transp=0)

// Analysis

openabove = f_gapper(valuewhen(session_bar_counter == 0, vah_value[1], 0)) <


valuewhen(session_bar_counter == 0, open, 0)
openbelow = f_gapper(valuewhen(session_bar_counter == 0, val_value[1], 0)) >
valuewhen(session_bar_counter == 0, open, 0)
openbetween = (f_gapper(valuewhen(session_bar_counter == 0, vah_value[1], 0)) >
valuewhen(session_bar_counter == 0, open, 0)) and
(f_gapper(valuewhen(session_bar_counter == 0, val_value[1], 0)) <
valuewhen(session_bar_counter == 0, open, 0))

//Table {
var table info = table.new(position.top_center , 1, 1)
//var table logo = table.new(position.bottom_left, 1, 1)
if barstate.islast
// table.cell(logo, 0, 0, "☮" , text_size = size.large,
text_color = color.orange)
table.cell(info, 0, 0, "t.me/Pivott_Boss", text_size = size.normal , text_color
= color.black)
//////////////////

You might also like