The Commodity Channel Index (CCI) compares the current mean price with the average mean price over a typical window of 20 periods.
\[CCI = \frac{( P - A )}{( 0.015 * D )}\]
where
\[\bullet\; P = Pivot = \frac{(High_{n-period} + Low_{n-period} + Close_{current\;close})}{3}\]
\[\bullet\; High_{n-period} = Highest\;price\;over\;n-periods\]
\[\bullet\; Low_{n-period} = Lowest\;price\;over\;n-periods\]
\[\bullet\; Close_{current\;close} = Current\;close\;price\]
\[\bullet\; A = n\text{-}period\;moving\;average\;of\;the\;pivot\;value\;P \]
\[\bullet\; D = mean\;deviation\;of\;the\;absolute\;value\;of\;the\;difference\;between\;the\;mean\;price\;and\;the\;moving\;average\;of\;the\;mean\;price, P-A \]