Adaptive Dual-Engine Strategy - Momentum + Mean Reversion [BT] by patelanishp
By patelanishp
Performance Metrics
- Author: patelanishp
- Symbol: NASDAQ:META
- Timeframe: 1 day
- Win Rate: 66.7%
- Profit Factor: 1.214
Description
Adaptive Dual-Engine Strategy - Momentum and Mean Reversion [Backtest]An executable backtesting strategy that contains two trading engines plus an automatic switch that picks the right one for the chart timeframe. For educational and research purposes only.OverviewEMA MACD momentum - trend and momentum scoring (EMA stack, MACD, RSI, ADX/DMI, volume, optional higher-timeframe trend). Intended for trending stocks and daily charts.Mean Reversion - fades over-extended moves back toward a moving-average mean. Intended for choppy index ETFs (SPY/QQQ) and low intraday charts.Leave the entry mode on "Auto (by timeframe)" and the strategy self-selects the engine. No EMA lines are plotted - use the companion indicators for that.How to useAdd the script to a chart, then open Settings and (after any update) use Defaults > Reset settings so the current defaults apply.Open the Strategy Tester tab to view results.Change ticker or timeframe and results update automatically. On Auto, the engine changes with the timeframe - no manual switching.Entry modesAuto (by timeframe) (default) - Mean Reversion on charts 15-min and below, EMA-MACD momentum above 15-min.EMA MACD Only - momentum: enter when the EMA-MACD score hits Strong.Both Agree - enter only when both momentum scores hit Strong (most selective).Either Signal - enter when either momentum score hits Strong (more trades).BuySell Only - use only the oscillator score.Mean Reversion - force the mean-reversion engine on any timeframe.How the Auto switch decidesThe strategy reads the chart timeframe live and selects the engine, so you do not change any setting when you switch charts. 1 to 15-minute charts use Mean Reversion; 30-minute, 1-hour and daily use EMA-MACD momentum. It only auto-switches while Entry Mode shows "Auto (by timeframe)".How trades trigger - momentum engine (above 15-min)Entry needs the score to reach the Strong threshold and pass quality gates: trend alignment (longs above the 200-EMA and higher-timeframe trend), an ADX chop filter, a no-chase filter (not over-extended from the fast EMA) and an RSI guard.EMA MACD score range -10 to +10, Strong at +/-5. BuySell score range -12 to +12, Strong at +/-6.Stop-loss is ATR-based; take-profit is a configurable fraction of the stop distance.How trades trigger - mean-reversion engine (15-min and below)Buy (dip): price stretches below the mean EMA by the ATR threshold while a short-period RSI is oversold and the regime allows longs; target is a return to the moving mean.Short (rip): price stretches above the mean EMA by the ATR threshold while the short RSI is overbought and the regime allows shorts; target is a return to the moving mean.Defaults: mean EMA 40, RSI(2) below 15 for buys, 0.5x ATR stretch, 2.0x ATR stop, target tracks the mean, plus a short time cap.Risk and exit logic (shared)ATR-based stop and targetBar-count time-stop for short-term holding (on a daily chart 5 bars is about one week; intraday mean-reversion is automatically given more room)Position sizing default 25% of equityLong-only by default; an optional short toggle with a 200-EMA regime filterOptional scale-out, breakeven and ATR trailing for the momentum engine (off by default)Optional exit on an opposite signal or a neutral score (skipped automatically in Mean Reversion mode)Robustness on intraday chartsThe score is a sum of conditions; if any input is empty (for example volume on symbols that have none, or a daily higher-timeframe value that cannot resolve intraday) the whole score could become empty and produce no trades. Every score input and the trend-alignment gate are na-safe, so the strategy populates on intraday and on volume-less symbols. If a backtest is still empty, lower the entry score threshold or turn off the ADX / 200-EMA filters and allow warm-up bars.Timeframe guidanceLower intraday (5 to 10-min) and the daily chart are the intended timeframes.30-minute and 1-hour are not recommended for this strategy.No single parameter set is optimal across all timeframes - each timeframe should be validated on its own.Cost noteIntraday targets are small, so commission and slippage matter a lot. The script ships configured for a commission-free broker; set commission and slippage in the Properties tab to match your own broker. If you pay per-trade fees, intraday is generally not suitable - use the daily chart instead.Win rate vs profitA tighter profit target raises the share of winning trades but can reduce overall profitability, because rare stop-losses are larger than the many small wins. Evaluate the strategy by profit factor and net result, not by win rate alone.Inputs you can tuneEntry mode and score thresholdsATR stop multiplier and reward/risk target (momentum)Mean-reversion EMA length, RSI level, stretch and stopMax hold bars (time-stop) and the trend / ADX / no-chase filtersPosition sizing, commission and slippage (Properties tab)Reading the Strategy TesterOverview shows win rate, profit factor (above 1.0 = profitable), net profit, max drawdown and total trades. Performance Summary breaks out long vs short. List of Trades shows every entry and exit. Judge intraday by profit factor, not win rate.Notes / disclaimerThis is a backtesting and educational tool, not financial advice and not a guarantee of future results. Backtest results do not guarantee future performance. Always set commission and slippage to match your broker and validate on your own symbol and timeframe before any live use.