← Back to list

doge_higher_lows_strong_close VALIDATED PASS

Auto-discovered strategy

Symbol: DOGE | Exchange: Bitfinex | Role: momentum

3/6
Profitable Years
+80.5%
Total Return
28.0%
Avg Win Rate
-0.14
Avg Sharpe

Year-by-Year Results

Click a year to view chart

Year Return Win Rate Trades Max DD Sharpe
2020 +0.0% 0.0% 0 0.0% 0.00
2021 -10.0% 29.4% 17 25.4% -0.39
2022 +41.8% 23.8% 21 20.4% 0.54
2023 -39.5% 37.9% 29 34.6% -2.36
2024 +75.9% 38.5% 52 26.8% 0.98
2025 +12.3% 38.5% 26 20.1% 0.36

Performance Chart

Loading chart...

Walk-Forward Validation PASS

1/1 Windows Profitable
+6.0% OOS Return
0.00 Median Sharpe
0.000 Score
Window Train Period Val Period Val Return Val Test Period Test Return Status
WF-1 2024-01→2025-06 2025-07→2025-12 +6.0% OK 2026-01→ongoing +0.0% PASS

AI Review

Not yet reviewed. Run: ./review_strategy.sh doge_higher_lows_strong_close

Source Code

"""
Strategy: doge_higher_lows_strong_close
=======================================

Consecutive Higher Lows with Strong Close pattern for DOGE.

Entry: 3 consecutive 4h candles with higher lows, bullish close with 1%+ body,
       in upper half of range, above EMA50, with EMA50 > EMA200 regime filter.

Exit: Close below EMA50 OR 2 consecutive lower lows (trend break).
      5% stop loss for risk management.

Pattern Logic:
- Higher lows show buyers defending higher levels (accumulation)
- Strong close (upper half, good body) shows conviction
- Regime filter avoids bear markets
- Quick exit on trend breakdown preserves capital

TRAIN Performance (2024-01-01 to 2025-06-30):
- 2024: +75.9% | 52 trades | 38.5% WR | Sharpe 0.98 | Max DD 26.8%
- 2025 H1: +30.2% | 8 trades | 50% WR | Sharpe 1.09 | Max DD 5.0%
- Total: +106.1%
"""

import sys
sys.path.insert(0, '/root/trade_rules')
from lib import ema


def init_strategy():
    return {
        'name': 'doge_higher_lows_strong_close',
        'role': 'momentum',
        'warmup': 200,
        'subscriptions': [
            {'symbol': 'tDOGE:USD', 'exchange': 'bitfinex', 'timeframe': '4h'},
        ],
        'parameters': {}
    }


def process_time_step(ctx):
    key = ('tDOGE:USD', 'bitfinex')
    bars = ctx['bars'][key]
    i = ctx['i']
    positions = ctx['positions']

    # Pre-compute indicators
    closes = [b.close for b in bars]
    ema50 = ema(closes, 50)
    ema200 = ema(closes, 200)

    actions = []

    if key not in positions:
        # Entry logic
        if i < 5 or ema50[i] is None or ema200[i] is None:
            return []

        # REGIME FILTER: EMA50 > EMA200 (must be in uptrend)
        # This prevents trading in bear markets
        if ema50[i] <= ema200[i]:
            return []

        # Must be above EMA50
        if bars[i].close <= ema50[i]:
            return []

        bar1 = bars[i-2]
        bar2 = bars[i-1]
        bar3 = bars[i]

        # PATTERN: 3 consecutive HIGHER LOWS
        # This shows buyers defending increasingly higher price levels
        if not (bar2.low > bar1.low and bar3.low > bar2.low):
            return []

        # At least 2 of 3 bars must be bullish (green)
        bullish = sum(1 for b in [bar1, bar2, bar3] if b.close > b.open)
        if bullish < 2:
            return []

        # Last bar must be GREEN (bullish confirmation)
        if bar3.close <= bar3.open:
            return []

        # Last bar body at least 1% (strong conviction)
        body_pct = (bar3.close - bar3.open) / bar3.open
        if body_pct < 0.01:
            return []

        # Last bar must close in upper 50% of range (bullish close)
        bar_range = bar3.high - bar3.low
        if bar_range > 0:
            close_pos = (bar3.close - bar3.low) / bar_range
            if close_pos < 0.5:
                return []

        actions.append({
            'action': 'open_long',
            'symbol': 'tDOGE:USD',
            'exchange': 'bitfinex',
            'size': 1.0,
            'stop_loss_pct': 5.0,  # Tight stop for risk management
        })

    else:
        # Exit logic
        if ema50[i] is None or i < 2:
            return []

        # Exit 1: Close below EMA50 (trend reversal)
        if bars[i].close < ema50[i]:
            actions.append({
                'action': 'close_long',
                'symbol': 'tDOGE:USD',
                'exchange': 'bitfinex',
            })
            return actions

        # Exit 2: 2 consecutive lower lows (trend breaking)
        # This is the opposite of our entry pattern
        if bars[i].low < bars[i-1].low and bars[i-1].low < bars[i-2].low:
            actions.append({
                'action': 'close_long',
                'symbol': 'tDOGE:USD',
                'exchange': 'bitfinex',
            })

    return actions


if __name__ == '__main__':
    from strategy import backtest_strategy
    results, profitable, _ = backtest_strategy(init_strategy, process_time_step)