How can I programmatically detect bullish and bearish RSI divergences?
A bullish divergence occurs when the underlying security makes a lower low and RSI forms a higher low. RSI does not confirm the lower low and this shows strengthening momentum.
A bearish divergence forms when the security records a higher high and RSI forms a lower high. RSI does not confirm the new high and this shows weakening momentum.