The Commodity Channel Index (CCI) is a versatile technical indicator used to identify new trends or warn of extreme conditions in the market. It measures the variation of a security’s price from its statistical mean, helping traders to assess the strength of price movements.
CCI[N](price)
The function takes two parameters:
The CCI is calculated using the following formula:
CCI = (Price - MM) / (0.015 * D)
The CCI indicator is primarily used to spot overbought and oversold conditions in the market:
myCCI = CCI[20](close)
SIGNAL = 0
IF myCCI < -100 THEN SIGNAL = -1 ENDIF IF myCCI > 100 THEN
SIGNAL = 1
ENDIF
RETURN SIGNAL
This example calculates the CCI over 20 periods using the closing price. It then sets a signal based on the CCI value: -1 for oversold conditions and +1 for overbought conditions.
The CCI is a useful tool for traders to gauge the momentum and potential reversal points in the market, based on how far prices have deviated from their moving average.