CommodityChannelIndex

Calculates the Commodity Channel Index indicator.

Accepts the following parameters:

Parameter NameTypeDefault ValueNotes
applyToSeries<Number>
typical
-
periodNumber14-

Returns: Series<Number>

CommodityChannelIndex is a built-in function - you can use it directly. Below is an example implementation:

1 function CommodityChannelIndex(applyTo = typical, period = 14):
2 divider = (0.015 * MeanDev(applyTo, period))
3 ((applyTo - SMA(applyTo, period)) / divider) if divider != 0 else 0