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