f2r2HsHT
f2r2HsHT
bullishPrice = low
oscMins = d > d[1] and d[1] < d[2] // this line identifies bottoms in the PPO
BottomPointsInPPO = oscMins
bearishPrice = high
oscMax = d < d[1] and d[1] > d[2] // this line identifies tops in the PPO
TopPointsInPPO = oscMax
// only take tops/bottoms in price when tops/bottoms are less than 5 bars away
filter = ta.barssince(priceMins) < 5 ? ta.lowest(currenttrough6, 4) : na
filter2 = ta.barssince(priceMax) < 5 ? ta.highest(currenttrough7, 4) : na
// only take tops/bottoms in price when tops/bottoms are less than 5 bars away,
since 2nd most recent top/bottom in osc
y2 = ta.valuewhen(oscMax, filter2, 1) // identifies the highest high in the tops of
price with 5 bar lookback period SINCE the SECOND most recent top in PPO
y6 = ta.valuewhen(oscMins, filter, 1) // identifies the lowest low in the bottoms
of price with 5 bar lookback period SINCE the SECOND most recent bottom in PPO
y9 = ta.valuewhen(oscMins, currenttrough6, 0)
y10 = ta.valuewhen(oscMax, currenttrough7, 0)
plot(d, color=color.white)
plot(bulldiv, title="Tops", color=color.aqua, style=plot.style_circles,
linewidth=4, offset=-1)
plot(beardiv, title="Bottoms", color=color.red, style=plot.style_circles,
linewidth=4, offset=-1)
plot(y10 > y2 and oscMax and y3 < y4 ? d : na, title="Bearish Divergence2",
color=color.orange, style=plot.style_circles, linewidth=4)
plot(y9 < y8 ? d : na, title="Bullish Divergence2", color=color.purple,
style=plot.style_circles, linewidth=4)
plot(delayedlow < y8 ? d : na, title="Bullish Divergence2", color=color.purple,
style=plot.style_circles, linewidth=4)
plot(delayedhigh > y2 and y3 < y4 ? d : na, title="Bearish Divergence2",
color=color.orange, style=plot.style_circles, linewidth=4)