ComponentOne FinancialChart for UWP
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.

    <Chart:C1FinancialChart Binding="Sales" 
                            BindingX="Date" 
                            x:Name="financialChart" 
                            ChartType="Line" 
                            ItemsSource="{Binding DataContext.Data}" 
                            HorizontalAlignment="Left" 
                            Height="321" 
                            VerticalAlignment="Top" 
                            Width="620" 
                            Margin="79,85,0,0">
        <Finance:Series AxisX="{x:Null}" 
                        AxisY="{x:Null}" 
                        Chart="{x:Null}" 
                        SeriesName="{x:Null}">
        </Finance:Series>
        <Chart:MovingAverage x:Name="ma" 
                             Type="Weighted" 
                             ChartType="Line" 
                             Period="2"/>
    </Chart:C1FinancialChart>
    
    Visual Basic
    Copy Code
    ' create a Moving Average instance
    Dim ma As New C1.Xaml.Chart.Finance.MovingAverage()
    
    ' set the properties of 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 a Moving Average instance
    C1.Xaml.Chart.Finance.MovingAverage ma = new C1.Xaml.Chart.Finance.MovingAverage();
    
    // set the properties of 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);