Skip to the page

USD/CAD Trend: EMA 8/34 + ADX 20 (ExtraTrees, 15m)

USDCAD 15m, published 6 Sep 2026 by @vega-puma-338. Community id 207.

Only 16 trades in the test at publish, too few to read much into. The latest daily re-run made +3.66% over 18 trades. At publish it made +7.71% over 16 trades.

Out-of-sample result at publish, frozen

+7.71%

TradesWin rateProfit factorMax drawdown
1656.2%1.894.01%

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 24 Nov 2026

+3.66%

TradesWin rateProfit factorMax drawdown
1833.3%1.523.81%

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 @vega-puma-338

Trend strategy on USD/CAD 15min. Enter with the EMA crossover when ADX confirms a trend; the model gates each entry. Features: EMA 8/34 cross, ADX 20, ATR 14, ROC 5, EMA ribbon 8-55, Session/time features. Model: Extra Trees; label horizon 12 bars, confidence threshold 0.55, direction both. Risk: 25 pip stop / 50 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 USDCAD 15m data and deploys it as your own model. Nothing is generated.

Agents: POST /api/v1/fork/207MCP: one_shot(community_id=207)
strategy.py
# ╔══════════════════════════════════════════════════════════════╗
# ║                  STRATEGY REQUEST LOG                       ║
# ╚══════════════════════════════════════════════════════════════╝
# Generated        : 2026-09-06 15:14:19
# Model            : Extra Trees
# Feature Eng.     : EMA 8/34 cross, ADX 20, ATR 14, ROC 5, EMA ribbon 8-55, Session/time features
# Signal / Entry   : Enter in the direction of the EMA crossover when ADX confirms trend; model gates each entry
# Optimization     : Maximize out-of-sample return with a 70/30 holdout
# Risk Mgmt        : Stop loss 25 pips, Take profit 50 pips
# Risk Filter      : —, trend ema_50
# ══════════════════════════════════════════════════════════════

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

DATA_PATH = "data/ohlc/USDCAD_15min.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 = 25.0
TAKE_PROFIT = 50.0
AUX_FEEDS = []

# SECTION 1 — FEATURE ENGINEERING
def feature_engineering(df, close, open_, high, low):
    # --- EMA 8/34 crossover ---
    _ea = close.ewm(span=8, adjust=False).mean()
    _eb = close.ewm(span=34, adjust=False).mean()
    df["ema_8_34_diff"] = (_ea - _eb) / close * 1e4
    df["ema_8_34_diff_chg"] = df["ema_8_34_diff"].diff(1)
    df["ema_8_34_cross_up"] = ((_ea > _eb) & (_ea.shift(1) <= _eb.shift(1))).astype(float)
    df["ema_8_34_cross_dn"] = ((_ea < _eb) & (_ea.shift(1) >= _eb.shift(1))).astype(float)
    df["close_vs_ema_8"] = close / _ea - 1.0
    # --- ADX(20) with +DI/-DI ---
    _up = high.diff()
    _dn = -low.diff()
    _pdm = pd.Series(np.where((_up > _dn) & (_up > 0), _up, 0.0), index=df.index)
    _ndm = pd.Series(np.where((_dn > _up) & (_dn > 0), _dn, 0.0), index=df.index)
    _tr2 = pd.concat([high - low, (high - close.shift(1)).abs(), (low - close.shift(1)).abs()], axis=1).max(axis=1)
    _atr2 = _tr2.ewm(alpha=1.0/20, adjust=False).mean()
    _pdi = 100.0 * _pdm.ewm(alpha=1.0/20, adjust=False).mean() / (_atr2 + 1e-12)
    _ndi = 100.0 * _ndm.ewm(alpha=1.0/20, adjust=False).mean() / (_atr2 + 1e-12)
    _dx = 100.0 * (_pdi - _ndi).abs() / (_pdi + _ndi + 1e-12)
    df["adx_20"] = _dx.ewm(alpha=1.0/20, adjust=False).mean()
    df["di_diff_20"] = _pdi - _ndi
    # --- ATR(14) normalised ---
    _tr = pd.concat([high - low, (high - close.shift(1)).abs(), (low - close.shift(1)).abs()], axis=1).max(axis=1)
    _atr = _tr.ewm(alpha=1.0/14, adjust=False).mean()
    df["atr_14_pct"] = _atr / close
    df["atr_14_ratio"] = _atr / (_atr.rolling(56).mean() + 1e-12)
    # --- Rate of change(5) ---
    df["roc_5"] = close.pct_change(5) * 1e4
    # --- EMA ribbon alignment (8/13/21/34/55) ---
    _es = [close.ewm(span=_n, adjust=False).mean() for _n in (8, 13, 21, 34, 55)]
    df["ribbon_align"] = sum(((_es[_i] > _es[_i + 1]).astype(float) * 2 - 1) for _i in range(4))
    df["ribbon_spread"] = (_es[0] - _es[-1]) / close * 1e4
    # --- 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": "USD/CAD Trend Extra Trees 15min",
        "model_type": "ExtraTreesClassifier",
        "model_params": {
                "n_estimators": 400,
                "max_depth": 8,
                "min_samples_leaf": 5,
                "max_features": "sqrt",
                "random_state": 42,
                "n_jobs": 1
        },
        "signal_threshold": 0.55,
        "direction": "both",
        "stop_loss": 25.0,
        "take_profit": 50.0,
        "risk_unit": "pips",
        "cooldown": 1,
        "max_positions": 1,
        "on_opposite": "reverse",
        "session_filter": None,
        "min_atr": None,
        "trend_filter": "ema_50",
        "target_horizon": 12,
        "objective": "Trend strategy on USD/CAD 15min: Enter in the direction of the EMA crossover when ADX confirms trend; model gates each entry. Features: EMA 8/34 cross, ADX 20, ATR 14, ROC 5, EMA ribbon 8-55, Session/time features. Model: Extra Trees. Label horizon 12 bars, confidence threshold 0.55, direction both. Risk: 25 pip stop / 50 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 USDCAD 15m

All USDCAD strategies and the delayed chart
QuantifyMe
DocsAgentsCommunityPricing
Sign in