Moving Average Convergence/Divergence Formula
The moving average convergence/divergence (MACD) formula compares a short period moving average and a long period moving average of prices. MACD is used with a 9-day exponential moving average as a signal that identifies buying or selling moments.
Formula Details
Syntax
Chart.DataManipulator.FinancialFormula(
FinancialFormula.MACD,
"ShortPeriod,LongPeriod",
"Volume",
"Result")
Parameters
This formula takes two optional parameters.
ShortPeriod
Period for calculating the short period moving average. The default value is 12.LongPeriod
Period for calculating the long period moving average. The default value is 26.
Input Values
This formula takes one input Y value.
- Price
The price to be calculated by the formula.
Output Value
This formula outputs one Y value.
- MACDIndicator
Distance between the short and long exponential moving averages.
Remarks
The Line chart type is a convenient chart type to display the formula output.
Example
The following code applies the MACD formula on Series1's third Y values (Series1:Y3) and outputs it to Series3's first Y values (Series3:Y). It also specifies a short period of 15 days and a long period of 30 days.
Chart1.DataManipulator.FinancialFormula (FinancialFormula.MACD, "15,30", "Series1:Y3","Series3:Y")
Chart1.DataManipulator.FinancialFormula (FinancialFormula.MACD, "15,30", "Series1:Y3", "Series3:Y");
See Also
Reference
System.Windows.Forms.DataVisualization.Charting
System.Web.UI.DataVisualization.Charting