//@version=3
study(title="The Golden Pivots", shorttitle="TGP", overlay=true)
pivottimeframe = input(title = "Pivot Resolution", defval="D",
options=["D","W","M"])
dp = input(true, title="Show Floor Pivots")
cp = input(true, title="Show Camarilla Pivots")
hl = input(true, title="Show M, W, D Highs/Lows")
tp = input(false, title="Show Tomorrow Pivots")
//dp in the prefix implies daily pivot calculation
dpopen = security(tickerid, pivottimeframe, open[1], barmerge.gaps_off,
barmerge.lookahead_on)
dphigh = security(tickerid, pivottimeframe, high[1], barmerge.gaps_off,
barmerge.lookahead_on)
dplow = security(tickerid, pivottimeframe, low[1], barmerge.gaps_off,
barmerge.lookahead_on)
dpclose = security(tickerid, pivottimeframe, close[1], barmerge.gaps_off,
barmerge.lookahead_on)
dprange = dphigh - dplow
//Expanded Floor Pivots Formula
pivot = (dphigh + dplow + dpclose ) / 3.0
bc = (dphigh + dplow ) / 2.0
tc = (pivot - bc) + pivot
r1 = (pivot * 2) - dplow
r2 = pivot + (dphigh - dplow)
r3 = r1 + (dphigh - dplow)
r4 = r3 + (r2 - r1)
s1 = (pivot * 2) - dphigh
s2 = pivot - (dphigh - dplow)
s3 = s1 - (dphigh - dplow)
s4 = s3 - (s1 - s2)
//Expanded Camarilla Pivots Formula
h1=dpclose + dprange*(1.1/12)
h2=dpclose + dprange*(1.1/6)
h3=dpclose + dprange*(1.1/4)
h4=dpclose + dprange*(1.1/2)
h5=(dphigh/dplow)*dpclose
l1=dpclose - dprange*(1.1/12)
l2=dpclose - dprange*(1.1/6)
l3=dpclose - dprange*(1.1/4)
l4=dpclose - dprange*(1.1/2)
l5=dpclose - (h5-dpclose)
//Tomorrow's Pivot Calculation
tpopen = security(tickerid, pivottimeframe, open, barmerge.gaps_off,
barmerge.lookahead_on)
tphigh = security(tickerid, pivottimeframe, high, barmerge.gaps_off,
barmerge.lookahead_on)
tplow = security(tickerid, pivottimeframe, low, barmerge.gaps_off,
barmerge.lookahead_on)
tpclose = security(tickerid, pivottimeframe, close, barmerge.gaps_off,
barmerge.lookahead_on)
tprange = tphigh - tplow
tppivot = (tphigh + tplow + tpclose ) / 3.0
tpbc = (tphigh + tplow ) / 2.0
tptc = (tppivot - tpbc) + tppivot
tpr1 = (tppivot * 2) - tplow
tps1 = (tppivot * 2) - tphigh
tph3 = tpclose + tprange*(1.1/4)
tpl3 = tpclose - tprange*(1.1/4)
//m,w,d in the prefix implies monthly, weekly and daily
mhigh = security(tickerid, "M", high[1], lookahead=barmerge.lookahead_on)
mlow = security(tickerid, "M", low[1], lookahead=barmerge.lookahead_on)
whigh = security(tickerid, "W", high[1], lookahead=barmerge.lookahead_on)
wlow = security(tickerid, "W", low[1], lookahead=barmerge.lookahead_on)
dhigh = security(tickerid, "D", high[1], lookahead=barmerge.lookahead_on)
dlow = security(tickerid, "D", low[1], lookahead=barmerge.lookahead_on)
//dclose = security(tickerid, "D", close[1], lookahead=barmerge.lookahead_on)
//Plotting
plot(dp and pivot ? pivot : na, title="Pivot",color= #FF007F, style=cross,
transp=0)
plot(dp and bc ? bc : na, title="BC",color= blue, style=cross, transp=0)
plot(dp and tc ? tc : na, title="TC",color= blue, style=cross, transp=0)
plot(dp and r1 ? r1 : na, title="R1",color= green, style=cross, transp=0)
plot(dp and r2 ? r2 : na, title="R2",color= green, style=cross, transp=0)
plot(dp and r3 ? r3 : na, title="R3",color= green, style=cross, transp=0)
plot(dp and r4 ? r4 : na, title="R4",color= green, style=cross, transp=0)
plot(dp and s1 ? s1 : na, title="S1",color= red, style=cross, transp=0)
plot(dp and s2 ? s2 : na, title="S2",color= red, style=cross, transp=0)
plot(dp and s3 ? s3 : na, title="S3",color= red, style=cross, transp=0)
plot(dp and s4 ? s4 : na, title="S4",color= red, style=cross, transp=0)
plot(cp and h5 ? h5 : na, title="H5",color= h5 != h5[1] ? na : black, transp=0)
plot(cp and h4 ? h4 : na, title="H4",color= h4 != h4[1] ? na : black, transp=0)
plot(cp and h3 ? h3 : na, title="H3",color= h3 != h3[1] ? na : black, transp=0)
plot(cp and h2 ? h2 : na, title="H2",color= h2 != h2[1] ? na : black, transp=0)
plot(cp and h1 ? h1 : na, title="H1",color= h1 != h1[1] ? na : black, transp=0)
plot(cp and l1 ? l1 : na, title="L1",color= l1 != l1[1] ? na : black, transp=0)
plot(cp and l2 ? l2 : na, title="L2",color= l2 != l2[1] ? na : black, transp=0)
plot(cp and l3 ? l3 : na, title="L3",color= l3 != l3[1] ? na : black, transp=0)
plot(cp and l4 ? l4 : na, title="L4",color= l4 != l4[1] ? na : black, transp=0)
plot(cp and l5 ? l5 : na, title="L5",color= l5 != l5[1] ? na : black, transp=0)
plot((isintraday or isdaily or isweekly) and hl ? mhigh : na, title="Monthly
High",style=circles, color=#FF7F00, transp=0)
plot((isintraday or isdaily or isweekly) and hl ? mlow : na, title="Monthly
Low",style=circles, color=#FF7F00, transp=0)
plot((isintraday or isdaily) and hl ? whigh : na, title="Weekly
High",style=circles, color=#FF7F00, transp=0)
plot((isintraday or isdaily) and hl ? wlow : na, title="Weekly
Low",style=circles,color=#FF7F00, transp=0)
plot(isintraday and hl ? dhigh : na, title="Daily High",style=circles,
color=#FF7F00, transp=0)
plot(isintraday and hl ? dlow : na, title="Daily Low",style=circles, color=#FF7F00,
transp=0)
//plot(isintraday and hl ? dclose : na, title="Daily Close",style=circles,
color=#FF7F00, transp=0)
plot(tp and tppivot ? tppivot : na, title="Pivot",color= blue, style=cross,
transp=0)
plot(tp and tpbc ? tpbc : na, title="BC",color= blue, style=cross, transp=0)
plot(tp and tptc ? tptc : na, title="TC",color= blue, style=cross, transp=0)
plot(tp and tpr1 ? tpr1 : na, title="R1",color= green, style=cross, transp=0)
plot(tp and tps1 ? tps1 : na, title="S1",color= red, style=cross, transp=0)
plot(tp and tph3 ? tph3 : na, title="H3",color= tph3 != tph3[1] ? na : black,
transp=0)
plot(tp and tpl3 ? tpl3 : na, title="L3",color= tpl3 != tpl3[1] ? na : black,
transp=0)
plot(isintraday and tp ? tphigh : na, title="High",style=circles, color=#FF7F00,
transp=0)
plot(isintraday and tp ? tplow : na, title="Low",style=circles, color=#FF7F00,
transp=0)
//Candle Stick Patterns
DJ1= abs(open - close) < (high - low) * 0.1 and high-low > atr(14)
plotshape(DJ1, title="Doji", location=location.abovebar, color=blue,
style=shape.xcross)
OR1 = (open[1] > close[1] and open < close and (low[1] > low) and close > high[1]
and (high-low) > atr(14)*1.25) // or close[1] > open
plotshape(OR1, title="Bullish Engulfing", style=shape.arrowup, color = green,
location=location.belowbar)
OR2 = (open[1] < close[1] and open > close and (high[1] < high) and close < low[1]
and (high-low) > atr(14)*1.25) // or close[1] < open
plotshape(OR2, title="Bearish Engulfing", style=shape.arrowdown, color = red)
WR1 = (low < low[1] and abs(low - min(open,close)) > abs(open-close) * 2 and
abs(high-close) < (high - low) * 0.35 and high-low > atr(14))
plotshape(WR1, title="Hammer", location=location.belowbar, color=green,
style=shape.arrowup)
WR2 = (high > high[1] and high - max(open,close) > abs(open-close) * 2 and
abs(close-low) < (high - low) * 0.35 and high-low > atr(14))
plotshape(WR2, title="Shooting Star", color=red, style=shape.arrowdown)
ER1 = (high[1]-low[1]) > atr(14)*2 and abs(open[1] - close[1]) > (high[1]-low[1]) *
0.5 and open[1] > close[1] and open < close //and abs(open[1] - close[1]) <
(high[1]-low[1]) * 0.85
plotshape(ER1, title="Bullish E.Reversal", location=location.belowbar, color=green,
style=shape.arrowup)// E denotes Extreme
ER2 = (high[1]-low[1]) > atr(14)*2 and abs(open[1] - close[1]) > (high[1]-low[1]) *
0.5 and open[1] < close[1] and open > close //and abs(open[1] - close[1]) <
(high[1]-low[1]) * 0.85
plotshape(ER2, title="Bearish E.Reversal", location=location.abovebar, color=red,
style=shape.arrowdown)