Page 1 of 1

A script for a divergence alert?

Posted: Fri Nov 06, 2020 12:37 am
by BKHXLTON
Has anyone coded a script to alert when price diverges from an oscillator (like a stoch)?

Re: A script for a divergence alert?

Posted: Wed Nov 11, 2020 1:17 am
by ocaptain
I haven't set an alert but I do have an indicator that shows me when RSI is divergent from the Trend...

You can look at my code here:

https://www.tradingview.com/script/i3AP ... h-Low-RSI/

and it would be easy enough to basically track the last 4 pivots with 4 variables to see if you are in an uptrend or downtrend (i.e. pivot 3 is > pivot 1 AND pivot 4 > pivot 2), and then use 2 variables for the RSI to see if you have divergence, (lastRSI and currentRSI) and if we are in an uptrend and currentRSI < prevRSI then you have divergence, and vice-versa.

Don't know if this is the type of divergence you are looking for (RSI v. Trend) but I hope it inspires you to move forward with whatever Oscillator you are looking for to give you the results you need.

Trade well!

-Anthony

Re: A script for a divergence alert?

Posted: Fri Jan 15, 2021 7:25 am
by Matthew
This is a great question and something high on my list of ideas to explore when I get time. I'll let you know if I ever come up with anything useful, I'll definitely share it on this forum.

In the meantime Anthony's work is definitely worth looking into and I'm sure you'll find some inspiring ideas there! Good luck with your search :)