Skip to content

Add RSI/MACD divergence detection with score penalty #339

@github-actions

Description

@github-actions

Auto-generated from Post-Mortem Analysis

Source Discussion: #336
Priority: medium
Risk: medium


Summary

All 4 buy trades showed RSI (+35) and MACD (-3 to -4) divergence that was completely ignored. When momentum (MACD) contradicts mean-reversion (RSI), apply a 30% score penalty.

Analysis

Trade RSI Score MACD Score Divergence
#235 +35 -3 RSI bullish, MACD bearish
#236 +35 -4 RSI bullish, MACD bearish
#237 +35 -3 RSI bullish, MACD bearish
#238 +35 -3 RSI bullish, MACD bearish

Implementation

In src/strategy/signal_scorer.py, after calculating rsi_score and macd_score (around line 765):

# Detect RSI/MACD divergence
rsi_macd_divergence = (
    (rsi_score >= 20 and macd_score <= -2) or  # RSI bullish, MACD bearish
    (rsi_score <= -20 and macd_score >= 2)      # RSI bearish, MACD bullish
)

if rsi_macd_divergence:
    metadata["_indicator_divergence"] = 1
    divergence_penalty = 0.3  # 30% score reduction
    original_score = total_score
    total_score = int(total_score * (1 - divergence_penalty))
    logger.info(
        "indicator_divergence_penalty",
        rsi_score=rsi_score,
        macd_score=macd_score,
        original_score=original_score,
        adjusted_score=total_score,
        penalty_percent=divergence_penalty * 100,
    )
else:
    metadata["_indicator_divergence"] = 0

Trade-offs

Context

From post-mortem analysis: [Post-Mortem] Paper Trade Analysis - 2026-01-09


This issue was automatically created from post-mortem analysis.
The auto-fix label will trigger automatic fix attempt.

Metadata

Metadata

Assignees

No one assigned

    Labels

    fix-in-progressFix is being processedpost-mortemIssue originated from post-mortem analysis

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions