ComponentOne FinancialChart for WinForms
Commodity Channel Index
Analytics > Indicators > Commodity Channel Index

Commodity Channel Index (CCI) indicator is an oscillator that measures an asset's current price level relative to an average price level over a specified period of time. It is used to determine a new trend or to warn about extreme conditions.

In FinancialChart, you need to use a CCI object to work with Commodity Channel Index. FinancialChart also enables you to fetch the calculated CCI values at run-time using GetValues() method. This can help in creating alerts in application or maintaining logs while working with dynamic data.

The following code snippet demonstrates how you can use CCI indicator. The below example uses data from a class DataService. To see the detailed code for DataService class, refer Average True Range indicator.

Dim cci As New CCI() With
{
    .Name = "CCI"
}

Dim dataService__1 = DataService.GetService()
Dim data = dataService__1.GetSymbolData("box")

FinancialChart1.BeginUpdate()
FinancialChart1.BindingX = "date"
FinancialChart1.Binding = "close"
FinancialChart1.Series.Add(New FinancialSeries())
FinancialChart1.ChartType = C1.Chart.Finance.FinancialChartType.Line
FinancialChart1.DataSource = data
FinancialChart1.Rendered += Function(s, a)
                                financialChart2.AxisX.Min = FinancialChart1.AxisX.ActualMin
                                financialChart2.AxisX.Max = FinancialChart1.AxisX.ActualMax

                            End Function
FinancialChart1.EndUpdate()

financialChart2.BeginUpdate()
financialChart2.ChartType = C1.Chart.Finance.FinancialChartType.Line
financialChart2.BindingX = "date"
financialChart2.Binding = "high,low,close"
financialChart2.Series.Add(cci)
financialChart2.Legend.Position = C1.Chart.Position.Bottom
financialChart2.DataSource = data
financialChart2.EndUpdate()
period.Value = cci.Period
CCI cci = new CCI() { Name = "CCI" };

var dataService = DataService.GetService();
var data = dataService.GetSymbolData("box");

financialChart1.BeginUpdate();
financialChart1.BindingX = "date";
financialChart1.Binding = "close";
financialChart1.Series.Add(new FinancialSeries());
financialChart1.ChartType = C1.Chart.Finance.FinancialChartType.Line;
financialChart1.DataSource = data;
financialChart1.Rendered += (s, a) =>
{
    financialChart2.AxisX.Min = financialChart1.AxisX.ActualMin;
    financialChart2.AxisX.Max = financialChart1.AxisX.ActualMax;
};
financialChart1.EndUpdate();

financialChart2.BeginUpdate();
financialChart2.ChartType = C1.Chart.Finance.FinancialChartType.Line;
financialChart2.BindingX = "date";
financialChart2.Binding = "high,low,close";
financialChart2.Series.Add(cci);
financialChart2.Legend.Position = C1.Chart.Position.Bottom;
financialChart2.DataSource = data;
financialChart2.EndUpdate();
period.Value = cci.Period;