Dual Moving Average

← strategies

Strategy

Methodology

This strategy is backtested on daily OHLCV price data across major US equity indices and ETFs. Entry and exit signals are generated from the strategy's indicators with no lookahead bias — trades execute at the open of the bar following the signal.

Performance metrics are computed per symbol and shown individually. The parameter optimization section (where available) runs a grid search over the strategy's key parameters, optimizing for Sharpe ratio. Transaction costs and slippage are not modeled.

The signal logic and indicator code for this strategy is shown in the methodology code section below.

Methodology

Requires price to be above both a short and long moving average before entering. This dual confirmation reduces false signals in sideways markets. Exits when price drops below the short MA.

Implementation

class DualMA(Strategy):
    n_short = 20
    n_long = 50

    def init(self):
        close = self.data.Close
        self.ma_short = self.I(_sma, close, self.n_short)
        self.ma_long = self.I(_sma, close, self.n_long)

    def next(self):
        if self.data.Close[-1] > self.ma_short[-1] and self.data.Close[-1] > self.ma_long[-1]:
            if not self.position:
                self.buy()
        elif self.data.Close[-1] < self.ma_short[-1] and self.position:
            self.position.close()

Performance metrics

Total return+62.47%
Net profit$624,735
Gross profit$826,897
Gross loss$609,815
CAGR+3.79%
Annualized return+3.79%
Monthly average return+0.32%
Median monthly return-0.95%
Best month return+5.05%
Worst month return-6.34%
Rolling 1-month return+10.97%
Return per trade+0.19
Log return CAGR+6.16%
Compounded vs simple return difference-63.02%

Equity curves

Chart for symbol:

Charts & distributions

2025-04 → 2026-04 · 5-year daily data

Equity curve vs ^GSPC — buy/sell signals

Strategy equityIndex (normalized)▲ Buy▼ Sell

36 trades · green dashes = buy entries · red dashes = sell exits

Drawdown (underwater)

Rolling 1-month Sharpe

Rolling 1-month return (%)

Period return (≈ monthly)

Return distribution (bar returns)

MAE vs MFE (trades)

Rolling 12m Beta

Rolling 12m correlation

Monthly returns (run)

Performance Matrix

Total return+22.47%
Net profit$224,680
Gross profit$608,571
Gross loss$373,173
CAGR+6.33%
Annualized return+6.33%
Monthly average return+0.55%
Median monthly return+1.09%
Best month return+2.48%
Worst month return-8.92%
Rolling 1-month return+3.80%
Return per trade+0.57
Log return CAGR-3.70%
Compounded vs simple return difference-23.94%

Risk & trade diagnostics

Drawdown and rolling Sharpe for one symbol at a time appear in the equity charts above. This section adds strategy-specific views: how each index run for dual-ma sits in risk–return space, engine stop / take-profit settings when present, and per-trade MAE/MFE when OHLC trade stats exist in the JSON. Older static portfolio PNGs aggregated every strategy; these plots are scoped to this strategy only.

Stop loss / take-profit (this run)

These rules were applied when opening positions: fixed stop and take-profit prices from entry (backtesting.py sl / tp), plus an optional maximum hold in bars. They change realized outcomes versus signal-only exits; curves and metrics on this page already reflect them.

Stop loss
5%
Take profit
10%
Max hold

SL/TP combinations (this strategy)

These are strategy-specific SL/TP combinations from the sensitivity sweep. The best Sharpe combination is highlighted.

Best Sharpe combo: SL 3% / TP 0% (0.44)

SLTPSharpeReturnMax DDWin %
3%0%0.4428.30%17.61%42.42%
3%15%0.4427.97%17.61%44.12%
3%5%0.4327.30%17.70%46.51%
3%10%0.4327.19%17.61%44.44%
5%0%0.3723.42%20.71%42.42%
5%15%0.3623.10%20.71%44.12%
7%5%0.3622.97%20.50%46.51%
0%0%0.3623.10%20.98%42.42%
7%0%0.3623.10%20.98%42.42%
5%5%0.3622.57%20.80%46.51%
0%15%0.3522.68%20.98%44.12%
7%15%0.3522.68%20.98%44.12%
5%10%0.3522.47%20.71%44.44%
0%5%0.3522.11%21.06%46.51%
0%10%0.3522.00%20.98%44.44%
7%10%0.3522.00%20.98%44.44%

Performance with these rules (symbol by symbol)

Each row is one run for dual-ma. Values already include the stop / target / max-hold settings shown in the row.

SymbolStop lossTake profitMax holdTotal returnSharpeMax DD
^AXJO (S&P/ASX 200)5%10%-22.72%-1.3029.42%
^BSESN (BSE Sensex)5%10%24.84%0.5310.67%
^BVSP (Bovespa)5%10%16.55%0.3020.63%
^DJI (Dow Jones Industrial Average)5%10%7.70%0.1816.09%
^FCHI (CAC 40)5%10%-24.25%-0.8229.62%
^FTSE (FTSE 100)5%10%4.42%0.1914.66%
^GDAXI (DAX)5%10%-11.99%-0.2719.97%
^GSPC (S&P 500)5%10%22.47%0.4120.71%
^GSPTSE (TSX Composite)5%10%19.68%0.5710.86%
^HSI (Hang Seng)5%10%-5.28%-0.0827.70%
^IXIC (NASDAQ Composite)5%10%54.65%0.6520.95%
^KS11 (KOSPI)5%10%42.68%0.5518.05%
^MERV (Merval)5%10%1121.37%1.4619.73%
^N100 (Euronext 100)5%10%-7.15%-0.2423.67%
^N225 (Nikkei 225)5%10%7.47%0.1224.53%
^NSEI (Nifty 50)5%10%24.94%0.519.76%
^RUT (Russell 2000)5%10%-32.56%-0.7541.53%
^SSMI (Swiss Market)5%10%-9.53%-0.4319.93%
^STOXX50E (Euro Stoxx 50)5%10%-25.45%-0.7831.56%
^TWII (Taiwan Weighted)5%10%41.64%0.6514.58%

Cross-symbol risk: Sharpe vs max drawdown (this strategy)

One point per index run. X = worst drawdown magnitude (%), Y = Sharpe ratio. Compare how stable the edge is across regions — unlike the site-wide risk report PNGs, this uses only runs for dual-ma.

Trade path: MAE vs MFE

Symbol:
Avg MAE: -1.56%Avg MFE: 3.34%MFE / MAE: 2.14

Each point is one trade: MAE = worst unrealized loss vs entry during the trade; MFE = best unrealized gain. Sample capped in JSON for payload size. With SL/TP enabled, many trades stop out before reaching prior MFE extremes — compare to metrics in the table above.

Parameter optimization

Parameter optimization

Dual Moving Average on ^GSPC. Objective: Sharpe Ratio. 16 runs. Color =

Results by region

Index Performance Statistics

Performance metrics for each index symbol tested with this strategy.

IndexCountryReturn %SharpeSortinoMax DD %Win Rate %TradesProfit FactorVolatility %
MervalArgentina+1121.37%1.464.07+19.73%+47.97%1232.29+27.09%
S&P/ASX 200Australia-22.72%-1.30-1.40+29.42%+25.64%390.37+8.26%
BovespaBrazil+16.55%0.300.45+20.63%+31.15%611.38+10.05%
TSX CompositeCanada+19.68%0.570.98+10.86%+34.21%381.70+9.33%
Euro Stoxx 50Europe-25.45%-0.78-1.08+31.56%+18.75%480.58+13.46%
Euronext 100Europe-7.15%-0.24-0.36+23.67%+20.93%430.88+10.35%
CAC 40France-24.25%-0.82-1.16+29.62%+20.93%430.52+11.82%
DAXGermany-11.99%-0.27-0.43+19.97%+18.75%480.88+16.07%
Hang SengHong Kong-5.28%-0.08-0.12+27.70%+25.86%580.99+14.14%
BSE SensexIndia+24.84%0.530.76+10.67%+34.62%521.63+8.39%
Nifty 50India+24.94%0.510.73+9.76%+29.41%511.60+8.61%
Nikkei 225Japan+7.47%0.120.17+24.53%+31.25%641.15+12.52%
KOSPISouth Korea+42.68%0.550.86+18.05%+39.29%561.66+12.77%
Swiss MarketSwitzerland-9.53%-0.43-0.54+19.93%+25.81%310.70+8.16%
Taiwan WeightedTaiwan+41.64%0.651.00+14.58%+32.79%611.64+10.73%
FTSE 100UK+4.42%0.190.29+14.66%+25.00%441.17+7.74%
Dow Jones Industrial AverageUS+7.70%0.180.29+16.09%+34.29%351.26+12.28%
NASDAQ CompositeUS+54.65%0.651.06+20.95%+45.45%332.25+18.86%
Russell 2000US-32.56%-0.75-0.80+41.53%+23.91%460.57+16.69%
S&P 500US+22.47%0.410.72+20.71%+44.44%361.63+14.33%