RSI divergence
Price makes a lower low while RSI makes a higher low; at default settings it never fires.
RSIDivergence looks for bullish divergence between the close and an RSI of the close. It finds local lows in both series over the last lookback bars, where a low sits strictly below every bar within min_separation bars on each side. It fires when the two most recent price lows form a lower low, the nearest RSI lows form a higher low, and the newer price low sits in the last 5 bars.
How to read it
- Markers sit on the candle where the pattern is confirmed, never on the low itself.
- A marker means price printed a lower low while momentum printed a higher low, so selling pressure is fading.
- On SPY one-minute bars with default settings it drew no markers in a month; lower min_separation to make it fire.
What it outputs
- Divergence strength
- Fires on the candle where a bullish divergence is confirmed. The value is the percent price drop between the two lows plus ten times the RSI rise.
When it fires
The newest of the two price lows falls in the last 5 bars, price made a lower low, and RSI made a higher low at the matching bars. This is a bullish divergence: the down move is losing momentum, a hint of a bounce rather than a confirmed reversal.
Settings
- lookback
- Bars searched for the swing lows. Raising it lets the two lows sit further apart, so longer divergences are found. Lowering it limits the search to tight swings and can leave too few lows to compare.
- min_separation
- Bars on each side a low must stay below. Raising it keeps only major swing lows. Lowering it accepts small wiggles. At 5 or more the newest low can never be recent enough, so it never fires at any lookback.
Pitfalls
- At default settings it never fires: the newest low must sit in the last 5 bars, but a low needs min_separation bars after it, so 5 or more cannot qualify. The 5-bar gate is fixed in code.
- Only the two most recent price lows are compared, and each is paired with the nearest RSI low by bar distance, which can be a far-off swing.
- The value mixes a percent price drop with ten times the RSI rise, so strength ranks markers only loosely. The loosened presets were not backtested here and may still be rare.