Docs

ta.cci

Measure how far price sits from its average, in units of typical deviation.

itm
ta.cci(source, length)

Commodity Channel Index: (source - sma(source, length)) / (0.015 * ta.dev(source, length)), where ta.dev is the mean absolute deviation about that same average, not a standard deviation. The 0.015 is the original scaling constant.

Parameters

A series parameter takes a value on every bar. A constant parameter must be known before the first bar, such as a number or an input.

NameKindTypeDefaultRangeDescription
sourceSeriesnumber--Typically hlc3.
lengthConstantnumber201 to 10000Window in observed bars.

Output

NameType
valuenumber

Warm-up and missing values

Warm-up
length bars. Names in the warm-up are this operator’s parameters.
Missing values
Returns na until length consecutive non-na observations are in the window. An na resets the accumulation. na when the mean absolute deviation over the window is zero.

Example

itm
ta.cci(hlc3, 20)
itm
plot(ta.cci(hlc3, 20), "Channel index 20")