CCI

Modified on 2008/04/14 09:52 by Administrator — Categorized as: Standard Indicators

Syntax

public CCI(WealthLab.Bars bars, int period, string description)
public static WealthLab.Indicators.CCI Series(WealthLab.Bars bars, int period)

Parameter Description

bars The Bars object
period Indicator calculation period

Description

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.

Interpretation





Calculation

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 )

where,

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.

Example

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;

namespace WealthLab.Strategies { 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 );

} } } }