Strategy
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.
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.
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()