pekipek

Pekipek's PPO Divergence BETA

18609 görüntülenme
3784
18609 49
Beta divergence indicator, you can exchange the Price Percentage Oscillator ( PPO ) for any oscillator. You can play around with the look-back period if you want to use long term divergences.
WARNING:
Because its impossible to make the look-back period of the lowest/highest functions dynamic, the indicator can plot divergences sometimes at places where there are none, however in my experience this does not occur so much. Also it is impossible to plot isolated lines, so its hard to visually see which divergence(s) exactly is(are) being signaled. Once these features become possible I can really refine the indicator.
Favori Komutlardan Çıkart Favori Komutlara Ekle
study(title = "Pekipek's PPO Divergence BETA", shorttitle = "PP's_PPO_DIV")
source = close
long_term_div = input(true, title="Use long term Divergences?")
div_lookback_period = input(55, minval=1, title="Lookback Period")
fastLength = input(12, minval=1), slowLength=input(26,minval=1)
signalLength=input(9,minval=1)
smoother = input(2,minval=1)
fastMA = ema(source, fastLength)
slowMA = ema(source, slowLength)
macd = fastMA - slowMA
macd2=(macd/slowMA)*100
d = sma(macd2, smoother) // smoothing PPO

bullishPrice = low 

priceMins = bullishPrice > bullishPrice[1] and bullishPrice[1] < bullishPrice[2] or 
            low[1] == low[2] and low[1] < low and low[1] < low[3] or
            low[1] == low[2] and low[1] == low[3] and low[1] < low and low[1] < low[4] or
            low[1] == low[2] and low[1] == low[3] and low[1] and low[1] == low[4] and low[1] < low and low[1] < low[5] // this line identifies bottoms and plateaus in the price
oscMins= d > d[1] and d[1] < d[2] // this line identifies bottoms in the PPO


BottomPointsInPPO = oscMins

bearishPrice = high
priceMax = bearishPrice < bearishPrice[1] and bearishPrice[1] > bearishPrice[2] or 
            high[1] == high[2] and high[1] > high and high[1] > high[3] or
            high[1] == high[2] and high[1] == high[3] and high[1] > high and high[1] > high[4] or
            high[1] == high[2] and high[1] == high[3] and high[1] and high[1] == high[4] and high[1] > high and high[1] > high[5]  // this line identifies tops in the price
oscMax = d < d[1] and d[1] > d[2]   // this line identifies tops in the PPO

TopPointsInPPO = oscMax



currenttrough4=valuewhen (oscMins, d[1], 0) // identifies the value of PPO at the most recent BOTTOM in the PPO
lasttrough4=valuewhen (oscMins, d[1], 1) // NOT USED identifies the value of PPO at the second most recent BOTTOM in the PPO
currenttrough5=valuewhen (oscMax, d[1], 0) // identifies the value of PPO at the most recent TOP in the PPO
lasttrough5=valuewhen (oscMax, d[1], 1) // NOT USED identifies the value of PPO at the second most recent TOP in the PPO

currenttrough6=valuewhen (priceMins, low[1], 0) // this line identifies the low (price) at the most recent bottom in the Price
lasttrough6=valuewhen (priceMins, low[1], 1) // NOT USED this line identifies the low (price) at the second most recent bottom in the Price
currenttrough7=valuewhen (priceMax, high[1], 0) // this line identifies the high (price) at the most recent top in the Price
lasttrough7=valuewhen (priceMax, high[1], 1) // NOT USED this line identifies the high (price) at the second most recent top in the Price


delayedlow = priceMins and barssince(oscMins) < 3 ? low[1] : na
delayedhigh = priceMax and barssince(oscMax) < 3 ? high[1] : na

// only take tops/bottoms in price when tops/bottoms are less than 5 bars away
filter = barssince(priceMins) < 5 ? lowest(currenttrough6, 4) : na
filter2 = barssince(priceMax) < 5 ? highest(currenttrough7, 4) : na

//delayedbottom/top when oscillator bottom/top is earlier than price bottom/top
y11 = valuewhen(oscMins, delayedlow, 0)
y12 = valuewhen(oscMax, delayedhigh, 0)

// only take tops/bottoms in price when tops/bottoms are less than 5 bars away, since 2nd most recent top/bottom in osc
y2=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=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

long_term_bull_filt = valuewhen(priceMins, lowest(div_lookback_period), 1)
long_term_bear_filt = valuewhen(priceMax, highest(div_lookback_period), 1)

y3=valuewhen(oscMax, currenttrough5, 0) // identifies the value of PPO in the most recent top of PPO 
y4=valuewhen(oscMax, currenttrough5, 1) // identifies the value of PPO in the second most recent top of PPO 




y7=valuewhen(oscMins, currenttrough4, 0) // identifies the value of PPO in the most recent bottom of PPO
y8=valuewhen(oscMins, currenttrough4, 1) // identifies the value of PPO in the SECOND most recent bottom of PPO

y9=valuewhen(oscMins, currenttrough6, 0)
y10=valuewhen(oscMax, currenttrough7, 0)

bulldiv= BottomPointsInPPO ? d[1] : na // plots dots at bottoms in the PPO
beardiv= TopPointsInPPO ? d[1]: na // plots dots at tops in the PPO


i = currenttrough5 < highest(d, div_lookback_period) // long term bearish oscilator divergence
i2 = y10 > long_term_bear_filt // long term bearish top divergence
i3 = delayedhigh > long_term_bear_filt // long term bearish delayedhigh divergence

i4 = currenttrough4 > lowest(d, div_lookback_period) // long term bullish osc divergence
i5 = y9 < long_term_bull_filt // long term bullish bottom div
i6 = delayedlow < long_term_bull_filt // long term bullish delayedbottom div



plot(d, color=white)
plot(bulldiv, title = "Tops", color=aqua, style=circles, linewidth=4, offset= -1)
plot(beardiv, title = "Bottoms", color=red, style=circles, linewidth=4, offset= -1)


plot(y10>y2 and oscMax and y3 < y4 ? d :na, title = "Bearish Divergence2", color=orange, style= circles, linewidth=4)
plot(y9<y6 and oscMins and y7 > y8 ? d :na, title = "Bullish Divergence2", color=purple, style=circles, linewidth=4)
plot(delayedlow<y6 and y7 > y8 ? d :na, title = "Bullish Divergence2", color=purple, style=circles, linewidth=4)
plot(delayedhigh>y2 and y3 < y4 ? d :na, title = "Bearish Divergence2", color=orange, style= circles, linewidth=4)

plot(long_term_div and oscMax and i and i2 ? d :na, title = "Bearish Divergence2", color=orange, style= circles, linewidth=4)
plot(long_term_div and oscMins and i4 and i5 ? d : na, title = "Bullish Divergence2", color=purple, style=circles, linewidth=4)
plot(long_term_div and i and i3 ? d :na, title = "Bearish Divergence2", color=orange, style= circles, linewidth=4)
plot(long_term_div and i4 and i6 ? d : na, title = "Bullish Divergence2", color=purple, style=circles, linewidth=4)
Hi. How to reduce false signals ???
+1 Cevap Gönder
Forsat11 Forsat11
@Forsat11, How to understand what will be the growth ???
Large or small ???
Cevap Gönder
Can you explain what the different color dots mean?
+6 Cevap Gönder
"Too good to be true", "hindsight is 20/20", "look ahead bias". Alas, all these apply to this indicator. See the earlier comment below about "repaint", which I had hoped was not true...but it is. A buy/sell colored circle signal for the most recent closed candle can continuously appear or disappear, depending on the performance of the SUBSEQUENT real time candle. No wonder it shows perfectly timed signals for every large move, gap and extended trend. Try a 1 minute timeframe if you want to see this behavior for yourself...it won't take long to see it. The white line is no more than the fast MACD line. Nothing useful here.
+3 Cevap Gönder
niknifty Villager1244
@Villager1244, what scripts have you published?
Ans. NONE
So, appreciate community work, take ideas to make it better or STFU!
Cevap Gönder
Anyone mananged to get alerts working off this? Can't figure out how to get them to work
Cevap Gönder
Its been a while since this script was release so I'm hoping that someone is monitoring this...how come the plotting of the top/bottom signal is offset by -1? To me that just seems like it is artificially making the signal look better since in real time you can't get those entries.
+1 Cevap Gönder
thanks
Cevap Gönder
Might have found a small bug in the script...


priceMins = bullishPrice > bullishPrice and bullishPrice < bullishPrice or
low == low and low < low and low < low or
low == low and low == low and low < low and low < low or
low == low and low == low and *****low****** and low == low and low < low and low < low // this line identifies bottoms and plateaus in the price

On the last line there is a stray "and low" highlighted with a lot of *** above.
The same thing appears in the high tests too.

Should have no impact though, unless low reaches 0 :-)
+4 Cevap Gönder
sir thanks for the wonderful script. can you pls give details of how this script working and what all conditions are use. and how can we attach this script in screener.
+5 Cevap Gönder
Ana Sayfa Hisse Senedi Takipçisi Forex Takipçisi Kripto Takipçisi Ekonomik Takvim Nasıl Çalışır Grafik Özellikleri Ücretlendirme Kurallarımız Moderatörler Web Sitesi & Aracı Kurum Çözümleri Görsel Bileşenler(Widget) Grafik Çözümleri Destek Merkezi Yeni Özellik Talebi Blog ve Haberler SSS Viki Twitter
Profil Profil Ayarları Hesap ve Ödemeler TradingView Koinleri Destek Kayıtlarım Destek Merkezi Yayınlanmış Fikirler Takip Edenler Takip Ediliyor Özel Mesajlar Sohbet Çıkış