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

The MACD line (fast EMA minus slow EMA) crossing above its signal line (EMA of MACD) triggers a long entry. The crossover below the signal triggers an exit. Combines trend-following with momentum.

Implementation

class MACDStrategy(Strategy):
    fast = 12
    slow = 26
    signal = 9

    def init(self):
        close = pd.Series(self.data.Close)
        macd = _macd_line(close, self.fast, self.slow)
        self.macd_line = self.I(lambda: macd, name="MACD")
        self.macd_sig = self.I(_macd_signal, macd, self.signal)

    def next(self):
        if crossover(self.macd_line, self.macd_sig) and not self.position:
            self.buy()
        elif crossover(self.macd_sig, self.macd_line) and self.position:
            self.position.close()

Performance metrics

Total return+12.794%
Net profit$127,943
Gross profit$662,092
Gross loss$556,884
CAGR+0.580%
Annualized return+0.580%
Monthly average return+0.112%
Median monthly return-0.425%
Best month return+6.310%
Worst month return-9.512%
Rolling 1-month return+12.749%
Return per trade+0.103
Log return CAGR+34.202%
Compounded vs simple return difference-12.451%

Equity curves

Chart for symbol:

Charts & distributions

2024-07 → 2026-04 · 5-year daily data

Equity curve vs ^GSPC — buy/sell signals

Strategy equityIndex (normalized)▲ Buy▼ Sell

37 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+31.485%
Net profit$314,850
Gross profit$671,220
Gross loss$359,100
CAGR+8.580%
Annualized return+8.580%
Monthly average return+0.728%
Median monthly return-1.552%
Best month return+7.177%
Worst month return-8.003%
Rolling 1-month return+15.594%
Return per trade+0.745
Log return CAGR-5.337%
Compounded vs simple return difference-33.638%