Commodity Channel Index

← 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

Commodity Channel Index measures deviation of price from its statistical mean. Enters long when CCI drops below -100 (oversold), exits when CCI rises above +100 (overbought). Works as both a trend and mean-reversion signal.

Implementation

class CCIStrategy(Strategy):
    n = 20

    def init(self):
        self.cci = self.I(_cci, self.data.High, self.data.Low, self.data.Close, self.n)

    def next(self):
        if self.cci[-1] < -100 and not self.position:
            self.buy()
        elif self.cci[-1] > 100 and self.position:
            self.position.close()

Performance metrics

Total return+32.664%
Net profit$326,645
Gross profit$810,425
Gross loss$491,155
CAGR+8.208%
Annualized return+8.208%
Monthly average return+0.672%
Median monthly return-0.064%
Best month return+5.130%
Worst month return-6.152%
Rolling 1-month return+12.012%
Return per trade+1.097
Log return CAGR+3.916%
Compounded vs simple return difference-30.952%

Equity curves

Chart for symbol:

Charts & distributions

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

Equity curve vs ^GSPC — buy/sell signals

Strategy equityIndex (normalized)▲ Buy▼ Sell

23 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+24.205%
Net profit$242,050
Gross profit$738,840
Gross loss$468,400
CAGR+6.736%
Annualized return+6.736%
Monthly average return+0.568%
Median monthly return+0.750%
Best month return+8.105%
Worst month return-9.580%
Rolling 1-month return+14.387%
Return per trade+0.950
Log return CAGR-4.360%
Compounded vs simple return difference-25.959%