Applying Formulas in Chart Controls
You can perform statistical analysis and financial analysis on data series using the formulas provided by the Chart control in the Chart.DataManipulator property.
To use statistical formulas in a Chart object to perform statistical analysis on one or more Series objects, use the methods in the Chart.DataManipulator.Statistics property methods. For more information on each formula, see Charting.StatisticFormula or Charting.StatisticFormula.
All statistical methods that use one or more data series for their input data cannot use indexed data points. Before using a statistical formula method, do the following:
Set the XValue property of all data points explicitly.
Make sure that each series' XValueIndexed property is set to False.
To perform financial analysis on one or more Series objects, use the Chart.DataManipulator.FinancialFormula method. For more information on each formula, see Financial Formulas.
Perform all necessary data filtering or grouping. Use the Filter and Group methods in the DataManipulator object.
For formulas involving moving averages, set the DataManipulator object's StartFromFirst property to the preferred value.
Use the FinancialFormula method in the DataManipulator class to apply the formula of your choice.
Each formula has a specific set of requirements is implemented differently. See the respective topic for detailed information on each formula.
After applying certain formulas, the output data series does not have the same size as the input data series. To plot the two data series in the same chart, you may want to perform additional data filtering to make sure that each input data point has a corresponding output data point.
Since the moving average of a specified period cannot be calculated for the first numeric data points, the DataManipulator.StartFromFirst property determines how these first data points are dealt with.
By default, StartFromFirst is set to False. When you use a formula that involves moving averages, the formula ignores the starting data points until it has enough data points to calculate the moving average. For example, if you want to calculate a 20-day moving average, the formula ignores the first 19 data points since there are not enough data points to calculate a 20-day moving average until the 20th day. However, if StartFromFirst is set to True, the formula calculates the moving average for the beginning points even though there are not enough data points yet. This gives you the advantage of having one moving average for each input data point in the series.