# Commodity Channel Index

Introduced by Donald Lambert, the Commodity Channel Index (CCI) was designed to identify cyclical turns in commodities but is now commonly applied to stock analysis. Its premise is that stocks move in cycles, with highs and lows forming at visually identifiable (yet ever changing) periodic intervals. It is generally advised that one-third of the cycle length be used as a period for CCI. The CCI calculation can be applied to any indicator to determine the direction and strength of its trend.

One way to determine the cycle length on a particular stock is to find two highs two lows and count the number of days (bars) between them. Divide that by 3 to determine the Period for the CCI.

CCI oscillates around zero. When CCI crosses up through +100 the indicator being analyzed is considered to be in a uptrend; when it crosses down through -100 the indicator is considered to be in a strong downtrend.

Read more about the Commodity Channel Index at Investopedia.

Function Version |
`CCI(x, z)` |
`x` =Period, `z` =Offset |

Indicator Version |
`CCIx.z` |

Where `x`

is the period which must be an integer.

Where `z`

is the offset. An offset of 1 would be for one bar ago.

The 14 period Commodity Channel Index for the current bar can be written as follows.

`CCI14.0`

But you can leave off the offset parameter because it is zero and that is the default.

`CCI14`

To get the value for the previous bar, you would add the offset parameter back into the formula.

`CCI14.1`