# Commodity Channel Index

Commodity Channel Index is an indicator on [Vela](https://vela.luxalgo.com/chart), our next-generation charting platform, written in Pine Script®.

The Commodity Channel Index measures how far the typical price deviates from its simple moving average, scaled by mean absolute deviation, producing an unbounded oscillator that commonly ranges around +100 and -100. Defaults are a length of 20 computed on the hlc3 typical price. This is the standard raw implementation of Lambert's CCI.

- Indicator in the LuxAlgo Library, by LuxAlgo, published Apr 13, 2020.
- Access: free.
- Concepts: [CCI](https://www.luxalgo.com/library/concept/cci/) (primary)
- Open on Vela: https://vela.luxalgo.com/chart?pineScriptCodeId=t0ft4hw764gxgwydp9zo8eie
- Page: https://www.luxalgo.com/library/indicator/commodity-channel-index/

The **Commodity Channel Index** gauges how far the typical price has drifted from its own average. Donald Lambert's formula subtracts an n-period simple moving average from the source and divides by 0.015 times the mean absolute deviation, a scaling chosen so most readings land between +100 and -100. The oscillator itself is unbounded, and strong trends push it past those levels. Defaults are a length of 20 computed on the hlc3 typical price, and the build is the standard raw implementation of Lambert's CCI, plotted with upper, lower, and zero reference lines.

## How to Trade the Commodity Channel Index?

- **CCI crossing above the Upper Level (+100)**: unusual stretch above the average. Lambert's original reading joins it as strength, exiting when CCI drops back below the level.
- **CCI crossing below the Lower Level (-100)**: the downside equivalent: trend strength to momentum traders, oversold stretch to mean-reversion traders.
- **Fading extremes in ranges**: in demonstrably range-bound tape, excursions beyond the levels are commonly faded back toward zero.
Join-the-strength and fade-the-stretch point opposite ways on the same line, and CCI cannot arbitrate. Establish whether the market is trending or ranging first.

## Commodity Channel Index Settings

- **Length** (default 20): the window for both the moving average and the mean absolute deviation. Shorter lengths make level visits frequent and shallow; longer ones make them rarer and more meaningful.
- **Source** (default hlc3): the price series measured; the hlc3 typical price is Lambert's classic input.
- **Upper Level** (default 100): the overbought reference; pushing it higher isolates severe stretch.
- **Lower Level** (default -100): the oversold mirror.

## Alerts

Three alert conditions are included: **Cross Above +100** and **Cross Below -100**, firing at the configured upper and lower levels, plus **Zero Line Cross** for zero crossings in either direction.

## Frequently Asked Questions

### Is a CCI reading above +100 bullish or bearish?

Both traditions exist: Lambert's rules bought the cross above +100, while later practice often fades the same excursion as overbought. Extremes extend in trends and revert in ranges, so let a regime read decide.

### How does CCI differ from RSI?

RSI is bounded 0 to 100 and built from smoothed gains versus losses; CCI is unbounded, built from price's distance to its average normalized by typical deviation. One grades how unusual the stretch is; the other how one-sided closes have been.

### What length should I use for CCI?

The default of 20 is the common modern choice, with 14 a frequent faster alternative. Shorter windows produce more, noisier threshold events. Tune frequency to your holding period.

## Related indicators

- [Internal Candle Strength](https://www.luxalgo.com/library/indicator/internal-candle-strength/) (Balance of Power): markdown at https://www.luxalgo.com/library/indicator/internal-candle-strength.md
- [Pretty Good Oscillator](https://www.luxalgo.com/library/indicator/pretty-good-oscillator/) (Momentum & Oscillators): markdown at https://www.luxalgo.com/library/indicator/pretty-good-oscillator.md
- [Gator Oscillator](https://www.luxalgo.com/library/indicator/gator-oscillator/) (Momentum & Oscillators): markdown at https://www.luxalgo.com/library/indicator/gator-oscillator.md
- [Wave Trend Oscillator](https://www.luxalgo.com/library/indicator/wave-trend-oscillator/) (Momentum & Oscillators): markdown at https://www.luxalgo.com/library/indicator/wave-trend-oscillator.md
- [Traders Dynamic Index](https://www.luxalgo.com/library/indicator/traders-dynamic-index/) (Momentum & Oscillators): markdown at https://www.luxalgo.com/library/indicator/traders-dynamic-index.md
- [Center of Gravity](https://www.luxalgo.com/library/indicator/center-of-gravity/) (Momentum & Oscillators): markdown at https://www.luxalgo.com/library/indicator/center-of-gravity.md
- [QQE Weighted Oscillator](https://www.luxalgo.com/library/indicator/qqe-weighted-oscillator/) (QQE): markdown at https://www.luxalgo.com/library/indicator/qqe-weighted-oscillator.md
- [5/35 Oscillator](https://www.luxalgo.com/library/indicator/5-35-oscillator/) (Momentum & Oscillators): markdown at https://www.luxalgo.com/library/indicator/5-35-oscillator.md

---

Source: https://www.luxalgo.com/library/indicator/commodity-channel-index/ (LuxAlgo Library). Free to use with attribution: https://www.luxalgo.com/library/license/
