SMA Crossover

← 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

Generates a buy signal when the fast SMA crosses above the slow SMA, and exits when the slow SMA crosses back above the fast. Captures sustained directional moves by filtering out short-term noise through two smoothed price averages.

Implementation

class SmaCross(Strategy):
    n_fast = 10
    n_slow = 20

    def init(self):
        close = self.data.Close
        self.sma_fast = self.I(_sma, close, self.n_fast)
        self.sma_slow = self.I(_sma, close, self.n_slow)

    def next(self):
        if crossover(self.sma_fast, self.sma_slow):
            self.buy()
        elif crossover(self.sma_slow, self.sma_fast):
            self.position.close()

Performance metrics

Total return+12.910%
Net profit$129,098
Gross profit$536,786
Gross loss$417,148
CAGR+1.836%
Annualized return+1.836%
Monthly average return+0.192%
Median monthly return+0.775%
Best month return+10.107%
Worst month return-9.487%
Rolling 1-month return+15.752%
Return per trade+0.341
Log return CAGR+29.535%
Compounded vs simple return difference-8.909%

Equity curves

Chart for symbol:

Charts & distributions

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

Equity curve vs ^GSPC — buy/sell signals

Strategy equityIndex (normalized)▲ Buy▼ Sell

18 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+13.144%
Net profit$131,440
Gross profit$490,020
Gross loss$339,940
CAGR+3.783%
Annualized return+3.783%
Monthly average return+0.339%
Median monthly return+3.319%
Best month return+10.982%
Worst month return-8.855%
Rolling 1-month return+17.369%
Return per trade+0.690
Log return CAGR+27.375%
Compounded vs simple return difference-3.066%