Skip to content

Strengthen EMA trend detection threshold sensitivity #353

@github-actions

Description

@github-actions

Auto-generated from Post-Mortem Analysis

Source Discussion: #349
Priority: medium
Risk: low


Summary

The current EMA trend classification uses a 1.0% gap threshold, which may be too wide for detecting meaningful trend signals. The post-mortem noted that EMA showed -0.18% gap (bearish) but trend_filter was 0 because it fell within the neutral zone.

Implementation

1. Add configuration parameter to config/settings.py:

ema_trend_threshold_percent: float = Field(
    default=0.5,
    ge=0.1,
    le=2.0,
    description="Minimum EMA gap percentage to classify as bullish/bearish trend (lower = more sensitive)"
)

2. Update .env.example:

# EMA trend detection sensitivity (v1.XX)
# Lower values make trend detection more sensitive
EMA_TREND_THRESHOLD_PERCENT=0.5

3. Modify src/indicators/ema.py to accept configurable threshold:

  • Update get_ema_trend() to accept optional threshold_percent parameter
  • Default to module constant _TREND_THRESHOLD_PERCENT for backward compatibility

4. Pass setting through SignalScorer to EMA indicator calls

Analysis

Current threshold: 1.0%
Proposed threshold: 0.5%

With -0.18% gap:

  • Current (1.0%): Returns "neutral" (abs(0.18) < 1.0)
  • Proposed (0.5%): Still returns "neutral" (abs(0.18) < 0.5)

However, making this configurable allows tuning for different market conditions. A 0.5% threshold would catch gaps between 0.5% and 1.0% that are currently missed.

Testing

  • Unit test: verify trend classification at various thresholds
  • Integration test: compare signal quality with different thresholds

Context

From post-mortem analysis of trades #243-#244 (2026-01-12). This is a lower-priority enhancement that provides more granular control over trend detection sensitivity.


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