Skip to the page

EUR/USD Mean-Reversion: RSI 21 + BB (LightGBM, 5m)

EURUSD 5m, published 6 Sep 2026 by @candid-owl-125. Community id 220.

The latest daily re-run lost money: −4.01% over 138 trades. At publish it made +8.18% over 148 trades. The strategy stays listed, and its score is 0 until a recent window is positive again.

Out-of-sample result at publish, frozen

+8.18%

TradesWin rateProfit factorMax drawdown
14867.6%1.315.16%

Tested on the 30% of days the model never saw.

A strategy can be published only when this test made money, so this number was chosen to be positive. The daily re-run is the fairer read.

Daily re-run 22 Nov 2026

−4.01%

TradesWin rateProfit factorMax drawdown
13850.0%0.938.49%

This exact code trained again on the last 40 days, the last 30% held out. A loss shows here and never removes the page.

Description as published by @candid-owl-125

Mean-Reversion strategy on EUR/USD 5min. Fade RSI/Bollinger extremes back toward the mean; the classifier decides direction. Features: RSI 21, BB (20,2.5), Z-score 50, Stochastic (14,3), Candle structure, Session/time features. Model: LightGBM; label horizon 3 bars, confidence threshold 0.60, direction both. Risk: 15 pip stop / 30 pip target (1:2 R/R), 1.0 lot on $10k, $6 round-trip commission. Trained on the last 40 days with a 70/30 holdout; the published numbers are the out-of-sample 30%.

Walk-forward check at publish: noise, attempt 1.

Run it yourself

Trains this exact code on fresh EURUSD 5m data and deploys it as your own model. Nothing is generated.

Agents: POST /api/v1/fork/220MCP: one_shot(community_id=220)
strategy.py
# ╔══════════════════════════════════════════════════════════════╗
# ║                  STRATEGY REQUEST LOG                       ║
# ╚══════════════════════════════════════════════════════════════╝
# Generated        : 2026-09-06 15:14:18
# Model            : LightGBM
# Feature Eng.     : RSI 21, BB (20,2.5), Z-score 50, Stochastic (14,3), Candle structure, Session/time features
# Signal / Entry   : Fade RSI/Bollinger extremes back toward the mean; classifier decides direction
# Optimization     : Maximize out-of-sample return with a 70/30 holdout
# Risk Mgmt        : Stop loss 15 pips, Take profit 30 pips
# Risk Filter      : —
# ══════════════════════════════════════════════════════════════

# ============================================================
# SECTION 0 — IMPORTS & CONSTANTS
import numpy as np
import pandas as pd

DATA_PATH = "data/ohlc/EURUSD_5min.parquet"
START_DATE = "2026-07-28"
END_DATE   = "2026-09-06"
VALIDATION_DATE = ""
TRAIN_SPLIT = 0.7
LEVERAGE = 30.0
LOTS = 1.0
BALANCE = 10000.0
RISK_UNIT = 'pips'
STOP_LOSS = 15.0
TAKE_PROFIT = 30.0
AUX_FEEDS = []

# SECTION 1 — FEATURE ENGINEERING
def feature_engineering(df, close, open_, high, low):
    # --- RSI(21) with zone flags and slope ---
    _d = close.diff()
    _g = _d.clip(lower=0).ewm(com=20, min_periods=21, adjust=False).mean()
    _l = (-_d.clip(upper=0)).ewm(com=20, min_periods=21, adjust=False).mean()
    _rsi = 100.0 - 100.0 / (1.0 + _g / (_l + 1e-10))
    df["rsi_21"] = _rsi
    df["rsi_21_os"] = (_rsi < 30).astype(float)
    df["rsi_21_ob"] = (_rsi > 70).astype(float)
    df["rsi_21_slope"] = _rsi.diff(2)
    # --- Bollinger Bands(20,2.5) ---
    _mid = close.rolling(20).mean()
    _sd = close.rolling(20).std()
    df["bb_20_2p5_pctb"] = (close - (_mid - 2.5 * _sd)) / (2 * 2.5 * _sd + 1e-10)
    df["bb_20_2p5_width"] = (2 * 2.5 * _sd) / (_mid + 1e-10)
    df["bb_20_2p5_width_chg"] = df["bb_20_2p5_width"].pct_change(3)
    # --- Z-score(50) of close ---
    df["zscore_50"] = (close - close.rolling(50).mean()) / (close.rolling(50).std() + 1e-12)
    df["zscore_50_chg"] = df["zscore_50"].diff(1)
    # --- Stochastic(14,3) ---
    _ll = low.rolling(14).min()
    _hh = high.rolling(14).max()
    _k = 100.0 * (close - _ll) / (_hh - _ll + 1e-10)
    df["stoch_k_14"] = _k
    df["stoch_d_14"] = _k.rolling(3).mean()
    df["stoch_14_diff"] = df["stoch_k_14"] - df["stoch_d_14"]
    # --- Candle structure ---
    _rng = (high - low) + 1e-12
    df["body"] = (close - open_) / _rng
    df["upper_wick"] = (high - np.maximum(close, open_)) / _rng
    df["lower_wick"] = (np.minimum(close, open_) - low) / _rng
    df["range_pct"] = _rng / close
    df["range_rel"] = _rng / (_rng.rolling(20).mean() + 1e-12)
    # --- Time-of-day / day-of-week (UTC) ---
    _h = df.index.hour + df.index.minute / 60.0
    df["hour_sin"] = np.sin(2 * np.pi * _h / 24.0)
    df["hour_cos"] = np.cos(2 * np.pi * _h / 24.0)
    df["dow"] = df.index.dayofweek.astype(float)
    df["london_open"] = ((df.index.hour >= 7) & (df.index.hour < 10)).astype(float)
    df["ny_open"] = ((df.index.hour >= 13) & (df.index.hour < 16)).astype(float)

    # Fill indicator warm-up gaps without looking ahead
    df = df.ffill().fillna(0.0)
    return df


# SECTION 2 — STRATEGY CONFIG
def strategy_config():
    return {
        "title": "EUR/USD Mean-Reversion LightGBM 5min",
        "model_type": "LGBMClassifier",
        "model_params": {
                "n_estimators": 300,
                "num_leaves": 15,
                "learning_rate": 0.02,
                "subsample": 0.8,
                "subsample_freq": 1,
                "colsample_bytree": 0.6,
                "min_child_samples": 20,
                "reg_lambda": 2.0,
                "random_state": 42,
                "n_jobs": 1,
                "verbose": -1
        },
        "signal_threshold": 0.6,
        "direction": "both",
        "stop_loss": 15.0,
        "take_profit": 30.0,
        "risk_unit": "pips",
        "cooldown": 2,
        "max_positions": 1,
        "on_opposite": "reverse",
        "session_filter": None,
        "min_atr": None,
        "trend_filter": None,
        "target_horizon": 3,
        "objective": "Mean-Reversion strategy on EUR/USD 5min: Fade RSI/Bollinger extremes back toward the mean; classifier decides direction. Features: RSI 21, BB (20,2.5), Z-score 50, Stochastic (14,3), Candle structure, Session/time features. Model: LightGBM. Label horizon 3 bars, confidence threshold 0.60, direction both. Risk: 15 pip stop / 30 pip target (1:2 R/R), 1.0 lot on $10k, $6 round-trip commission.",
        "notes": "Generated by the QuantifyMe strategy forge. SL/TP are in pips and match the dashboard defaults, so pasting this code into the Code tab reproduces the published backtest on the same window."
    }

More on EURUSD 5m

No other strategy on EURUSD 5m passes the quality bar yet.

All EURUSD strategies and the delayed chart
QuantifyMe
DocsAgentsCommunityPricing
Sign in