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. See the following code snippet that demonstrates how you can use CCI indicator. The code snippet uses a class DataService.cs whose code can be seen by referring to Average True Tange.
Partial Public Class Indicators Inherits UserControl Private dataService As DataService = dataService.GetService() Private cci As New CCI() With { Key.SeriesName = "CCI" } Public Sub New() InitializeComponent() End Sub Public ReadOnly Property Data() As List(Of Quote) Get Return dataService.GetSymbolData("box") End Get End Property Public ReadOnly Property IndicatorType() As List(Of String) Get Return New List(Of String)() From { "Commodity Channel Index" } End Get End Property Private Sub OnIndicatorTypeSelectionChanged(sender As Object, e As SelectionChangedEventArgs) Dim ser As FinancialSeries = Nothing If cbIndicatorType.SelectedIndex = 0 Then ser = cci End If If ser IsNot Nothing AndAlso Not indicatorChart.Series.Contains(ser) Then indicatorChart.BeginUpdate() indicatorChart.Series.Clear() indicatorChart.Series.Add(ser) indicatorChart.EndUpdate() End If End Sub Private Sub OnFinancialChartRendered(sender As Object, e As C1.WPF.Chart.RenderEventArgs) If indicatorChart IsNot Nothing Then indicatorChart.AxisX.Min = DirectCast(financialChart.AxisX, IAxis).GetMin() indicatorChart.AxisX.Max = DirectCast(financialChart.AxisX, IAxis).GetMax() End If End Sub End Class
public partial class Indicators : UserControl { DataService dataService = DataService.GetService(); CCI cci = new CCI() { SeriesName = "CCI" }; public Indicators() { InitializeComponent(); } public List<Quote> Data { get { return dataService.GetSymbolData("box"); } } public List<string> IndicatorType { get { return new List<string>() { "Commodity Channel Index", }; } } void OnIndicatorTypeSelectionChanged(object sender, SelectionChangedEventArgs e) { FinancialSeries ser = null; if (cbIndicatorType.SelectedIndex == 0) ser = cci; if (ser != null && !indicatorChart.Series.Contains(ser)) { indicatorChart.BeginUpdate(); indicatorChart.Series.Clear(); indicatorChart.Series.Add(ser); indicatorChart.EndUpdate(); } } void OnFinancialChartRendered(object sender, C1.WPF.Chart.RenderEventArgs e) { if (indicatorChart != null) { indicatorChart.AxisX.Min = ((IAxis)financialChart.AxisX).GetMin(); indicatorChart.AxisX.Max = ((IAxis)financialChart.AxisX).GetMax(); } } }