ComponentOne FinancialChart for WinForms
Analytics / Moving Average
In This Topic
    Moving Average
    In This Topic

    Moving Average is a moving average trendline used in financial charts. It analyzes data points by creating series of averages of various subsets of the complete data set.

    In FinancialChart, you can create an instance of the MovingAverage class, and set the Type property to any of the following values from the MovingAverageType enumeration:

    You can set the ChartType property to specify the chart type for the moving average. The property accepts values from the FinancialChartType enumeration. For more details on chart types, refer to Financial Chart Types.

    In addition, you can use the DataSource and the Period property to specify the data source and the period of the moving average respectively. Once you have set the properties, add the moving average to the Series collection.

    ' create an instance of the MovingAverage class
    Dim ma As New C1.Win.Chart.Finance.MovingAverage()
    
    ' set the moving average data source
    ma.DataSource = dt
    
    ' set the moving average type
    ma.Type = C1.Chart.MovingAverageType.Exponential
    
    ' set the moving average chart type
    ma.ChartType = C1.Chart.Finance.FinancialChartType.Line
    
    ' set the moving average period
    ma.Period = 3
    
    ' add the moving average to the Financial Chart Series collection
    FinancialChart1.Series.Add(ma)
    
    // create an instance of the MovingAverage class
    C1.Win.Chart.Finance.MovingAverage ma = new C1.Win.Chart.Finance.MovingAverage();
    
    // set the moving average data source
    ma.DataSource = dt;
    
    // set the moving average type
    ma.Type = C1.Chart.MovingAverageType.Exponential;
    
    // set the moving average chart type
    ma.ChartType = C1.Chart.Finance.FinancialChartType.Line;
    
    // set the moving average period
    ma.Period = 3;
    
    // add the moving average to the Financial Chart Series collection
    financialChart1.Series.Add(ma);