backtrader.indicators.cci module

CCI Indicator Module - Commodity Channel Index.

This module provides the CCI (Commodity Channel Index) indicator introduced by Donald Lambert in 1980 for identifying cyclical trends.

Classes:

CommodityChannelIndex: CCI indicator (alias: CCI).

示例

class MyStrategy(bt.Strategy):
def __init__(self):

self.cci = bt.indicators.CCI(self.data, period=20)

def next(self):
if self.cci[0] > 100:

self.sell()

elif self.cci[0] < -100:

self.buy()

class backtrader.indicators.cci.CommodityChannelIndex[源代码]

基类:Indicator

Introduced by Donald Lambert in 1980 to measure variations of the "typical price" (see below) from its mean to identify extremes and reversals

Formula:
  • tp = typical_price = (high + low + close) / 3

  • tpmean = MovingAverage(tp, period)

  • deviation = tp - tpmean

  • meandev = MeanDeviation(tp)

  • cci = deviation / (meandeviation * factor)

See:
alias = ('CCI',)
__init__(*args, **kwargs)
frompackages = ()
packages = ()