ComponentOne FinancialChart for UWP
Analytics / Trendlines
In This Topic
    Trendlines
    In This Topic

    Trendlines are a crucial tool in technical analysis for identifying and confirming trends. A straight line connecting two or more price points, a trendline can act as a line of resistance or support in future. Basically, trendlines are used to depict trends in data and to examine problems of prediction. Commonly used with financial charts, these lines can be used with diversified technical analysis charts, for instance MACD (moving average convergence/divergence) that is a trading indicator used in technical analysis of stock prices, or RSI (relative strength index) that is a technical indicator used in the analysis of financial markets.

    The supported FitTypes can be set using the FitType property that accepts the following values from the FitType enumeration. Each trend type is drawn based on the calculation formula of its type.

    Type

    Description

    Average X Calculates the average value of X from the chart data and draws a trendline.

    Average Y Calculates the average value of Y from the chart data and draws a trendline.
    Exponential A curved line that is convenient to use when data values rise or fall at increasingly higher rates. You cannot create an exponential trendline if your data contains zero or negative values.
    Fourier A way to display a wave like function as a combination of simple sine waves. It is created by using the fourier series formula.
    Linear A linear trendline is a best-fit straight light. Your data is linear if the data point pattern resembles a line, and a linear trendline is a good fit if the R-squared value is at or near 1.
    Logarithmic A best fit curved line used for better visualization of data. Used when the rate of change in the data increases or decreases quickly and then levels out. It can also use positive and negative values.
    Max X Takes the maximum value of X from the chart and draws a trendline using it.
    Max Y Takes the maximum value of Y from the chart and draws a trendline using it.
    Min X Takes the minimum value of X from the chart and draws a trendline using it.
    Min Y Takes the minimum value of Y from the chart and draws a trendline using it
    Polynomial A twisted line that is used when data oscillates. It is useful for analyzing gains and losses over a large data set.
    Power A curved line that is best used with data sets that compare calculation that increase at a peculiar rate. For example, the acceleration of a vehicle at one-second intervals.

    Create a TrendLine instance, and set properties, such as FitType, Order, and SampleCount of the TrendLine class. Add the trendline instance to the Series collection.

    <Chart:C1FinancialChart Binding="Sales"
                            BindingX="Date" 
                            x:Name="financialChart" 
                            ChartType="LineSymbols" 
                            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>
        <FlexChart:TrendLine FitType="Fourier" 
                             Order="10" 
                             SampleCount="150" 
                             x:Name="trendLine" />
    </Chart:C1FinancialChart>
    
    Visual Basic
    Copy Code
    ' create a Trendline instance
    Dim trendline As New C1.Xaml.Chart.TrendLine()
    
    ' set the properties of the Trendline instance
    trendline.FitType = C1.Chart.FitType.Fourier
    trendline.SampleCount = 150
    trendline.Order = 10
    
    ' add the Trendline instance to the Series collection
    

    C#
    Copy Code
    // create a Trendline instance
    C1.Xaml.Chart.TrendLine trendline = new C1.Xaml.Chart.TrendLine();
    
    // set the properties of the Trendline instance
    trendline.FitType = C1.Chart.FitType.Fourier;
    trendline.SampleCount = 150;
    trendline.Order = 10;
    
    // add the Trendline instance to the Series collection
    financialChart.Series.Add(trendline);