Investment Studio > Expressions > Functions > Indicator > CCI

float array[*][2] cci(float array[*][4] dhlc, integer days = 5)

Returns a two-column array containing dates (first column) and corresponding Commodity Channel Indicator (CCI) values (second column).

dhlc is a four-column array containing daily price quotes. Each row is structured as follows:

Column # Content
1 The quote date.
2 The day's high (highest traded price).
3 The day's low (lowest traded price).
4 The day's close (last traded price).

The array is assumed to be time-sorted, with earlier dates preceding later dates.

Automatic type conversion allows the use of date strings as arguments instead of explicit date values.

days is the length of the time window under consideration, i.e. the number of trading days contributing to the computation of each day's CCI. If the asset under study displays a cyclical pattern, the recommended value is 1/3 of the cycle length. If omitted, days defaults to 5.

Interpretation

CCI measures the deviation of a security's price from its mean over a recent period (days). Positive values imply that the price is higher than its recent average; negative values that it's lower.

There are two common uses of the CCI: as an overbought/oversold indicator and to validate price trends.

The CCI was designed to spend 70-80% of its time in the range -100 to 100. Values over 100 imply an overbought condition, values under -100 an oversold condition.

An overbought/oversold condition does not by itself imply an impending trend reversal. Strongly trending markets can remain overbought/oversold for extended periods of time. Donald Lambert, the CCI's inventor, therefore used the CCI crossing above 100 as a buy signal; the sell signal was triggered when the CCI crossed back below 100. The equivalent rule on the down side is to go short when the CCI crosses below -100 and to cover when the CCI crosses back above -100.

Critics of this system who think that it tends to step in too late prefer to buy when the CCI crosses above 0 and to go short when it crosses below 0.

-100 and 100 are not values set in stone; the choice of trigger levels may vary with the choice of security and of time frame.

A divergence between price and CCI, i.e. the price making new highs (lows) while the CCI is failing to take out its own previous highs (lows) is considered a warning of an impending trend reversal.

For a real life example, consider the NASDAQ Composite from June 1 to December 31, 2001:

The top chart shows the price in standard candlestick form. The bottom chart shows the 20 day CCI. The oversold (-100) level has been marked in red, the neutral (0) level in blue, the overbought (100) level in green.

Example

Assuming standard US date format settings,

=cci({{"1/1/1990", 100, 90, 98}, {"1/2/1990", 97, 84, 86}, {"1/3/1990", 95, 89, 91}}, 2)

returns {{32876, 25.3968253968254}}. 32876 is the date code for 1/3/1990; 25.39... is the 2 day CCI value for that date.

See also bol, rsi, sto.