ComponentOne FinancialChart for WPF
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 Period property to specify the period of the moving average. Once you have set the properties, add the moving average to the Series collection.

    <c1:C1FinancialChart Binding="Sales" 
                         BindingX="Date" 
                         x:Name="financialChart" 
                         ItemsSource="{Binding DataContext.Data}" 
                         HorizontalAlignment="Left" 
                         Height="321" 
                         VerticalAlignment="Top" 
                         Width="620" 
                         Margin="79,85,0,0">
        <c1:FinancialSeries ChartType="LineSymbols" 
                            AxisX="{x:Null}" 
                            AxisY="{x:Null}" 
                            Chart="{x:Null}" 
                            SeriesName="{x:Null}">
        </c1:FinancialSeries>
        <c1:MovingAverage x:Name="ma" 
                          Type="Weighted" 
                          ChartType="Line" 
                          Period="2"/>
    </c1:C1FinancialChart>
    
    Visual Basic
    Copy Code
    ' create an instance of the Moving Average class
    Dim ma As New C1.WPF.Chart.Finance.MovingAverage()
    
    ' set the properties for the Moving Average instance
    ma.Type = C1.Chart.MovingAverageType.Weighted
    ma.ChartType = C1.Chart.Finance.FinancialChartType.Line
    ma.Period = 2
    
    ' Add the Moving Average instance to the Series collection
    financialChart.Series.Add(ma)
    

    C#
    Copy Code
    // create an instance of the Moving Average class
    C1.WPF.Chart.Finance.MovingAverage ma = new C1.WPF.Chart.Finance.MovingAverage();
    
    // set the properties for the Moving Average instance
    ma.Type = C1.Chart.MovingAverageType.Weighted;
    ma.ChartType = C1.Chart.Finance.FinancialChartType.Line;
    ma.Period = 2;
    
    // Add the Moving Average instance to the Series collection
    financialChart.Series.Add(ma);