ta.cci()
Commodity Channel Index
The CCI is calculated as the difference between the typical price and its simple moving average, divided by the mean absolute deviation, scaled by 0.015.
Syntax
ta.cci(source, length) → series floatArguments
| Parameter | Type | Description |
|---|---|---|
| source | series int/float | Price or value series to analyze (often hlc3 or close). |
| length | series int | Lookback length for mean deviation and averaging. |
Returns
Commodity channel index of source for length bars back.
Remarks
na values in the source series are ignored.
Code Examples
//@version=6
indicator("ta.cci")
plot(ta.cci(hlc3, 20))Trading Applications
Identify cyclical trends in price
Detect overbought (>100) and oversold (<-100) conditions
Spot divergences between price and CCI
Use zero-line crossovers for trend confirmation
Frequently Asked Questions
Generate ta.cci() Code with AI
Skip the manual coding. Use Pineify's AI Coding Agent to generate Pine Script code using ta.cci() and other built-in functions instantly.
Related Pine Script Functions
ta.rsi() - Relative Strength Index
Learn how to use ta.rsi() in Pine Script. Syntax, parameters, code examples for the RSI momentum oscillator.
ta.stoch() - Stochastic Oscillator
Learn how to use ta.stoch() in Pine Script. Syntax, parameters, code examples for the Stochastic Oscillator.
ta.cmo() - Chande Momentum Oscillator
Learn how to use ta.cmo() in Pine Script. Syntax, parameters, code examples for the Chande Momentum Oscillator.
ta.mom() - Momentum
Learn how to use ta.mom() in Pine Script. Syntax, parameters, code examples for the Momentum indicator.
ta.roc() - Rate of Change
Learn how to use ta.roc() in Pine Script. Syntax, parameters, code examples for the Rate of Change percentage indicator.