Eminaest

Eminaest Pivots V2

Simple Pivot Points plotting script.

You can choose to plot Daily, Weekly and Monthly Pivot Points. Separate or two of them or all together.
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?
study(title="Eminaest Pivots V2", shorttitle="EPiPo", overlay=true)
//timeframe = input("D", type=resolution)
da = input(true, title="Show Daily Pivots?")
we = input(true, title="Show Weekly Pivots?")
mo = input(true, title="Show Monthly Pivots?")
//l3 = input(false, title="Show R3 & S3?")

//Daily
sopen = security(tickerid, "D", open [1])
shigh = security(tickerid, "D", high [1])
slow = security(tickerid, "D", low [1])
sclose = security(tickerid, "D", close [1])

//weekly
wopen = security(tickerid, "W", open [1])
whigh = security(tickerid, "W", high [1])
wlow = security(tickerid, "W", low [1])
wclose = security(tickerid, "W", close [1])

//Monthly
mopen = security(tickerid, "M", open [1])
mhigh = security(tickerid, "M", high [1])
mlow = security(tickerid, "M", low [1])
mclose = security(tickerid, "M", close [1])

//Color
scolor=sopen != sopen[1] ? na : black
scolor1=sopen != sopen[1] ? na : red
scolor2=sopen != sopen[1] ? na : green

wcolor=wopen != wopen[1] ? na : black
wcolor1=wopen != wopen[1] ? na : red
wcolor2=wopen != wopen[1] ? na : green

mcolor=mopen != mopen[1] ? na : black
mcolor1=mopen != mopen[1] ? na : red
mcolor2=mopen != mopen[1] ? na : green

//Pivot Calculation
//Daily
pivot = (shigh + slow + sclose) / 3
r1 = (pivot + pivot) - slow
s1 = (pivot + pivot) - shigh 
r2 = pivot + (shigh - slow)
s2 = pivot - (shigh - slow)
r3 = r1 + (shigh - slow)
s3 = s1 - (shigh - slow)

//Weekly
wpivot = (whigh + wlow + wclose) / 3
wr1 = wpivot + (wpivot - wlow)
ws1 = wpivot - (whigh - wpivot) 
wr2 = wpivot + (whigh - wlow) 
ws2 = wpivot - (whigh - wlow) 
wr3 = wr1 + (whigh - wlow)
ws3 = ws1 - (whigh - wlow)

//Monthly
mpivot = (mhigh + mlow + mclose) / 3
mr1 = mpivot + (mpivot - mlow)
ms1 = mpivot - (mhigh - mpivot) 
mr2 = mpivot + (mhigh - mlow) 
ms2 = mpivot - (mhigh - mlow) 
mr3 = mr1 + (mhigh - mlow)
ms3 = ms1 - (mhigh - mlow)

//Plotting lines
//Daily
plot(da and pivot ? pivot : na, color=scolor, style=circles)
plot(da and s1 ? s1 : na, color=scolor1,style=circles)
plot(da and s2 ? s2 : na, color=scolor1,style=circles)
plot(da and s3 ? s3 : na, color=scolor1,style=circles)
plot(da and r1 ? r1 : na, color=scolor2,style=circles)
plot(da and r2 ? r2 : na, color=scolor2,style=circles)
plot(da and r3 ? r3 : na, color=scolor2,style=circles)

//Weekly
plot(we and wpivot ? wpivot : na, color=wcolor, linewidth=1)
plot(we and ws1 ? ws1 : na, color=wcolor1, linewidth=1)
plot(we and ws2 ? ws2 : na, color=wcolor1, linewidth=1)
plot(we and ws3 ? ws3 : na, color=wcolor1, linewidth=1)
plot(we and wr1 ? wr1 : na, color=wcolor2, linewidth=1)
plot(we and wr2 ? wr2 : na, color=wcolor2, linewidth=1)
plot(we and wr3 ? wr3 : na, color=wcolor2, linewidth=1)

//Monthly
plot(mo and mpivot ? mpivot : na, color=mcolor, linewidth=2)
plot(mo and ms1 ? ms1 : na, color=mcolor1, linewidth=2)
plot(mo and ms2 ? ms2 : na, color=mcolor1, linewidth=2)
plot(mo and ms3 ? ms3 : na, color=mcolor1, linewidth=2)
plot(mo and mr1 ? mr1 : na, color=mcolor2, linewidth=2)
plot(mo and mr2 ? mr2 : na, color=mcolor2, linewidth=2)
plot(mo and mr3 ? mr3 : na, color=mcolor2, linewidth=2)