Here is an alpha of the RSI Divergence tool. I would again like to warn:
1) I haven't coded anything for Ninja in years. Code is likely very inefficient or flat wrong.
2) I did not look at other divergence tools, my logic is likely wrong or undesirable.
3) It will continue to extend a line forward up to the max bars setting if divergence is still occurring, and depending on your setting this means it may stop drawing for several lines until the continued divergence pattern sets up.
4) Divergence tools don't work in strong trends, just like oscillators don't, so a divergence tool built on top of an oscillator tool really, really doesn't work well in strong trends.
I did not use enums or bools because I wanted to use an optimizer on this code in a strategy later.
Inputs:
DivAvgSupport = 0 (false) or 1 (true) - will require the 'Avg' plot to be above/below the DivThreshold before a divergence will plot
DivMaxBars = maximum number of bars from start to end of divergence
DivMinBars = minimum number of bars from start to end of divergence
DivThresh = 50 is default, which is the half way point "zeroline" on RSI. If you set it to 60 then it will be 60 for bearish div and 40 for bullish automatically.
MAType = 0..10, will plot the RSI line based on different moving averages. 0 is RSI default behavior
Period = Normal RSI period
Smooth = Normal RSI smooth
Keep it Elite only. Feel free to tell me it sucks or is awesome. The code has tons of bugs and doesn't work well, keep this in mind... you definitely should not download or use it.
Because of the way I coded it, it looks to the RSI plot to trigger divergence - and not the price plot. Other indicators that use price will probably use ZigZag and as such there will be a penalty (delay). Trade off of my way is inaccuracy. Because of this inaccuracy, it means that sometimes you will see divergence lines where it is clearly not a divergence. I chose this instead of repainting (deleting a line) or slower recognition (bar delay).