Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

MovingAverageIndicator Class

A simple moving average (SMA) indicator.

Namespace: DevExpress.Maui.Charts

Assembly: DevExpress.Maui.Charts.dll

NuGet Package: DevExpress.Maui.Charts

#Declaration

C#
public class MovingAverageIndicator :
    CalculatedSeries

#Remarks

This indicator looks as follows:

Simple Moving Average Indicator

To create a simple moving average envelope, use EnvelopeIndicator.

ChartView also supports the following Moving Average indicators:

#Add an Indicator to a Series

This example builds a simple moving average indicator for Close values of a stock series.

  1. Add the MovingAverageIndicator object to the chart’s collection of series (ChartView.Series).
  2. Set the indicator’s Data property to a CalculatedSeriesDataAdapter class instance. Use this object’s Series property to specify a series for which the indicator should be calculated.
  3. Use the ValueLevel and PointsCount properties to specify the price level of a financial series point and the number of data points used to calculate the indicator.
<dxc:ChartView x:Name="chart">
    <dxc:ChartView.Series>
        <dxc:StockSeries>
            <dxc:StockSeries.Data>
                <dxc:SeriesDataAdapter DataSource="{Binding StockPrices}" ArgumentDataMember="Date">
                    <dxc:ValueDataMember Type="High" Member="High" />
                    <dxc:ValueDataMember Type="Low" Member="Low" />
                    <dxc:ValueDataMember Type="Open" Member="Open" />
                    <dxc:ValueDataMember Type="Close" Member="Close" />
                </dxc:SeriesDataAdapter>
            </dxc:StockSeries.Data>
        </dxc:StockSeries>

        <dxc:MovingAverageIndicator> 
                ValueLevel="Close" 
                PointsCount="20" 
                DisplayName="SMA 20">
            <dxc:MovingAverageIndicator.Data>
                <dxc:CalculatedSeriesDataAdapter Series="{Binding Series[0], Source={x:Reference chart}}"/>
            </dxc:MovingAverageIndicator.Data>
        </dxc:MovingAverageIndicator>
    </dxc:ChartView.Series>
</dxc:ChartView>

#Customize Indicator Appearance

To change the indicator line appearance, set the MovingAverageIndicator.Style property to the LineIndicatorStyle object with the specified Stroke and StrokeThickness properties.

<dxc:MovingAverageIndicator>
    <dxc:MovingAverageIndicator.Style>
        <dxc:LineIndicatorStyle Stroke="#9859c9"/>
    </dxc:MovingAverageIndicator.Style>

    <!--Indicator Data-->
</dxc:MovingAverageIndicator>
See Also