public CCI(WealthLab.Bars bars, int period, string description)
public static WealthLab.Indicators.CCI Series(WealthLab.Bars bars, int period)
||The Bars object
||Indicator calculation period
The Commodity Channel Index (CCI) developed by Lambert, is designed to identify and trade cyclical turns in commodities. It assumes the commodity or stock moves in cycles. Lambert recommends using 1/3 of the cycle as the calculation period. The cycle is considered an interval of low-to-low or high-to-high. Commodities can cycle around 60 days, thus the period would be 20 days. Signals are given when CCI moves into the +100 or -100 regions.
- When the CCI moves above +100, then a new strong uptrend is beginning, buy here, close the position on CCI falling below +100. Use trending indicators or other technical analysis methods to confirm.
- When the CCI moves below -100, then a new strong downtrend is beginning, sell here, close the position on CCI rising above -100. Use trending indicators or other technical analysis methods to confirm.
- If underlying prices make a new high or low that isn't confirmed by the CCI, this divergence can signal a price reversal. CSI divergences from price indicates very strong buy or sell signal.
- Look for oversold levels below -100 and overbought levels above +100. These normally occur before the underlying price chart forms a top or a bottom.
The Commodity Channel Index (CCI) is calculated by determining the difference between the mean price of a security and the average of the means over the period chosen. This difference is compared to the average difference over the time period. Comparing the differences of the averages allows for the commodities volatility. The result is multiplied by a constant to ensure that most values fall within the standard range of +/- 100.
CCI = ( AveP - SMA_of_AveP ) / ( 0.015 * Mean Deviation )
CCI = Commodity Channel Index
AveP = Average Price = (High + Low + Close) / 3
The 0.015 constant ensures 70 to 80 percent of CCI values fall within the +100 to -100 range.
public class MyStrategy : WealthScript
protected override void Execute()
// Color bars oversold/overbought based on CCI level
DataSeries cci = CCI.Series( Bars, 10 );
ChartPane CCIPane = CreatePane( 40, true, true );
PlotSeries( CCIPane, cci, Color.Purple, LineStyle.Histogram, 3 );
SetBarColors( Color.Silver, Color.Silver );
for(int bar = 10; bar < Bars.Count; bar++)
if( cci[bar] > 100 ) SetBarColor( bar, Color.Red ); else
if( cci[bar] < -100 ) SetBarColor( bar, Color.Green );