cci

Commodity Channel Index

cci(period)

Measures the deviation of typical price from its moving average. CCI identifies cyclical trends and overbought/oversold conditions.

Parameters

  • period (int): Number of periods for calculation
  • Common values: 20 (standard), 14, 30

Formula


CCI = (Typical Price - SMA(Typical Price)) / (0.015 * Mean Deviation)

Where:
- Typical Price = (High + Low + Close) / 3
- Mean Deviation = Average absolute deviation from SMA
- Constant 0.015 ensures ~70-80% of values fall between ±100

Examples


cci(20);  # Standard 20-period CCI
cci(14);  # 14-period CCI (more sensitive)
cci(20) > 100;  # Overbought condition
cci(20) < -100;  # Oversold condition

Returns

CCI value (typically ranges from -200 to +200, most values between ±100)

Notes

  • Values > +100 indicate overbought conditions
  • Values < -100 indicate oversold conditions
  • Returns 0 when mean deviation is 0 or NULL
  • Unbounded oscillator (can exceed ±100)