Skip to content

Conversation

@gauravarora
Copy link

Summary

Implements RSI(14) divergence detection to identify potential reversal and continuation signals as requested in issue #172.

Changes

1. New detect_rsi_divergence() function in Pktalib.py

Detects four types of divergences:

  • Regular Bullish: Price makes lower lows while RSI makes higher lows (bullish reversal signal)
  • Regular Bearish: Price makes higher highs while RSI makes lower highs (bearish reversal signal)
  • Hidden Bullish: Price makes higher lows while RSI makes lower lows (bullish continuation signal)
  • Hidden Bearish: Price makes lower highs while RSI makes higher highs (bearish continuation signal)

The implementation uses swing detection algorithm similar to the AutoTrader reference provided in the issue.

2. New findRSIDivergence() screening method in ScreeningStatistics.py

  • Integrates divergence detection into the screening workflow
  • Allows filtering by divergence type: 'bullish', 'bearish', 'hidden_bullish', 'hidden_bearish', or 'any'
  • Checks recent 5 bars for divergence signals
  • Stores divergence information in screening dictionaries for output

3. Comprehensive unit tests in PKTaLib_test.py

  • Tests normal divergence detection with realistic data patterns
  • Tests edge cases with insufficient data
  • Validates output structure and data types

Configuration

Configurable parameters:

  • rsi_period: RSI calculation period (default: 14)
  • swing_order: Number of points on each side for swing detection (default: 5)
  • tolerance: Tolerance window for matching price and indicator swings (default: 2)

Implement RSI divergence detection to identify potential reversal and continuation signals.

Features:
- Add detect_rsi_divergence() function in Pktalib for detecting 4 types of divergences:
  * Regular Bullish: Price LL while RSI HL (bullish reversal)
  * Regular Bearish: Price HH while RSI LH (bearish reversal)
  * Hidden Bullish: Price HL while RSI LL (bullish continuation)
  * Hidden Bearish: Price LH while RSI HH (bearish continuation)
- Add findRSIDivergence() screening method in ScreeningStatistics
- Add comprehensive unit tests for divergence detection
- Configurable parameters: RSI period (default 14), swing order, tolerance

Resolves issue pkjmesra#172
@github-actions
Copy link
Contributor

This PR is marked as Stale due to Inactivity.

@github-actions github-actions bot added the Stale label Oct 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant