Learn R Programming

TTR (version 0.13-1)

CCI: Commodity Channel Index

Description

The Commodity Channel Index (CCI) attempts to identify starting and ending trends.

Usage

CCI(HLC, ma = list("SMA", n=20), c=0.015)

Arguments

HLC
High-Low-Close price series to use. If only a univariate series is given, it will be used. See details.
ma
A list whose first component is a string containing the moving average function name; additional parameters may also be specified as named components.
c
Constant to apply to the mean deviation.

Value

  • A vector containing the CCI values.

concept

trend

Details

CCI relates the current price and the average of price over n periods. The CCI usually falls in a channel of -100 to 100. A basic CCI trading system is: Buy (sell) if CCI rises above 100 (falls below -100) and sell (buy) when it falls below 100 (rises above -100). CCI is usually calculated using the typical price, but if a univariate series (e.g. Close, Weighted Close, Median Price, etc.) is provided, it will be used instead.

References

The following site(s) were used to code/document this indicator: http://www.fmlabs.com/reference/CCI.htm http://www.equis.com/Customer/Resources/TAAZ/?c=3&p=42 http://www.linnsoft.com/tour/techind/cci.htm http://stockcharts.com/education/IndicatorAnalysis/indic_CCI.html

See Also

See EMA, SMA, etc. for moving average options; and note Warning section. See aroon, ADX, TDI, VHF for other indicators that measure trend direction/strength.

Examples

Run this code
data(ttrc)
  cci <- CCI(ttrc[,c("High","Low","Close")])

Run the code above in your browser using DataLab