TradingView
JohnBartlesAccount
١٩ حزيران يونيو ٢٠٢٢ ٠٣:٥٦

Realtime Divergence for Any Indicator 

SPDR S&P 500 ETF TRUSTArca

الوصف

This indicator is an addon to any oscillating indicator. It shows divergences. It shows realtime divergences too. Realtime divergences are potential divergences because the actual pivot is not fully formed.

It shows:
  • Regular Bullish Divergences
  • Hidden Bullish Divergences
  • Regular Bearish Divergences
  • Hidden Bearish Divergences




Reatime divergence lines are dashed lines while non-reatime are solid.


This script also offers a fair bit of control over what you can accept as a legitimate divergence.


Also note that functions tend to not work properly in conditional and loop structures so I couldn't use a lot of functions and consequently my script is really big. Sorry.

ملاحظات الأخبار

I've added support for price chart divergence lines.
I've added a flags/labels option to help quickly recognize the different types of divergences.



To use this script with the price chart you must do 2 things: check the Overlay Chart setting, and choose the desired oscillator input from Source Input

NOTE: This script currently is designed to use ANY different sized pairing of divergence lines between the price and oscillator. So, even if the price has a super small divergence line and the oscillator has a huge one - that will currently still be used as a legit divergence. The effect is that you'll get some divergence signals that may not be desirable. Sorry.
I'm going to figure out a reasonable way to allow varying length divergence pairings between price and oscillator while somehow filtering out the undesirable divergences. One idea is to filter out any pairing where one divergence is X amount too much bigger than the other divergence.

ملاحظات الأخبار

I removed "Minimum Pivot Height" option because it's not very useful. At least not in it's current state. The "Pivot Look Back" option mostly achieves the same idea. The more bars that make up the pivot - the bigger the pivot.

I partially fixed the bug that caused the PlotShape labels to increase when the "Allowance for Misalignment Between Price and Oscillator" option increased. There was only supposed to be one label per line.

I'm still casually trying to figure out a reasonable way to allow for varying length divergence lines between price and oscillator but only the acceptable ones. I think most Divergence scripts only give exact same length divergence lines.

ملاحظات الأخبار

I refactored a little bit, or at least I tried.

I added no new features.

ملاحظات الأخبار

I added alerts for the realtime (i.e. potential) divergences.
I added labels for realtime divergence lines. I haven't investigated but it looks like divergence lines won't get rendered until AFTER their alert, if set, is completed. If so, I'll possibly fix eventually.

ملاحظات الأخبار

Just a few minor changes.
التعليقات
JohnBartlesAccount
FYI, I have created an improved less buggy and more accurate version of this script. It has a few more features too. It has a VERY similar title : "Realtime Divergence for Any Indicator - By John Bartle"
frantzvertilus7
Bueno
exception_06
thank you for adding this.
Can you show us an example on how to add this to RSI? I tried adding it but RSI line disappeared.
Emporio
so the real one would disappear after how many bars if unvalid?
Slick_SiD
@JohnBartlesAccount, I really like this one I think ppl are sleeping on it. I’m finding it more accurate than other divergence indicators that allow you to chose the your own source. (Btw I’m using Lonesome’s Cumulative Delta as a source on the 1min). My only issue is that even though it paints dashed lines as potential divergences form, it doesn’t paint the label and alert until a few candles after the pivot which can be the entire trade on the 1min. I was wondering if you could add alerts for the dashes lines? Even though they repaint I think it would be worth it because they’d alert to the general area of the divergence pivot and give you time to set up the trade and wait for an engulfing candle. Dash line alerts would be awesome. Great work!
JohnBartlesAccount
@Slick_SiD, I could look at the code again and try to figure something out. Pine Script and probably most scripting languages used for market charts have got a lot of issues that make coding things ridiculously more difficult than it should be. I tried writing my code to accommodate realtime divergences and also be fast enough to hopefully be comfortable to use. Changing the code to plot labels for the dashed lines would be a bit tricky. I haven't checked yet but alerts might be pretty easy to add. I'll tinker and look.
JohnBartlesAccount
@Slick_SiD, I added alerts for the realtime divergences and also labels. I couldn't reasonably use the function called "plotshape()" to create the labels/flags so I used a different function. plotshape() allows for unlimited labels but the function I'm using has a small limit. Also, the text on the labels/flags I used is too small. That's one reason why I didn't use them originally. Also, I don't really trade so I don't have a paid account and without the fast playback feature I couldn't easily test my code. So, it might be really buggy. If you see any problems let me know.
intelligentBoa1976
Hello can a feautre be added to be able input more indicator for identifying divergences?
For example 3 or 4
thanks
JohnBartlesAccount
@intelligentBoa1976, I don't entirely know what you mean. Please explain more.
eshwoor
Excellent work and looking forward on the upcoming updates. Massive Thanks
المزيد