ta.cci()Commodity Channel Index
CCI is (source - SMA(source, length)) divided by (0.015 × mean absolute deviation). Typical price (hlc3) is a common source; ta.cci uses the supplied series.
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
Monitor values above +100 or below -100 in context; they do not imply an imminent reversal
Spot divergences between price and CCI
Use zero-line crossovers for trend confirmation
Frequently Asked Questions
Generate ta.cci() Code with AI
Draft Pine Script using ta.cci() with Pineify's AI Coding Agent, then review the arguments and test the result on your chart. Usage depends on your plan and available credits.
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.