Overview
A Weighted Moving Average is an average of data calculated over a period of time, where greater weight is attached to the most recent data. The Weighted Moving Average can be used with any price including the Hi, Low, Open, or Close price, and can be applied to other indicators as well. The Weighted Moving Average smoothens a data series, which is important in a volatile market, as it helps to identify trends much more easily. Weighting is calculated from a sum of days.
Dundas Chart for Windows Forms has four types of moving averages including Simple, Exponential, Triangular, and Weighted. The most important difference between the above moving averages is how they weight their datapoints.
Note |
---|
We recommend that you read Using Financial Formulas before proceeding any further. Using Financial Formulas provides a detailed explanation on how to use formulas, and also explains the various options available to you when applying a formula. |
Figure 1: A 20 day Weighted Moving Average, and High, Low and Closeprices as a stock chart. |
Applying a Weighted Moving Average
All formulas are calculated using the FormulaFinancial method, which accepts the following arguments: a formula name; input value(s); output value(s), and parameter(s) that are specific to the type of formula being applied.
Before applying the FormulaFinancial method, make sure that all data points have their XValue property set, and that their series' XValueIndexed property is set to false.
The following table indicates what sort of FormulaFinancial method arguments to use when calculating a Weighted Moving Average, and also supplies a description of what these parameters mean:
Parameter |
Value/Description |
Example |
Formula Name: |
WeightedMovingAverage
|
FormulaFinancial(FinancialFormula.WeightedMovingAverage,"20","Series1:Y2","Series2:Y") |
Input Value: | The value for which the Weighted moving average has to be calculated. It could be a price (e.g. Hi, Low, Open and Close). The most used price is Close. |
FormulaFinancial(FinancialFormula.WeightedMovingAverage,"20"," Series1:Y2","Series2:Y") |
Output Value: (optional) |
The Weighted Moving average. If not specified output is stored in the first input value. |
FormulaFinancial(FinancialFormula.WeightedMovingAverage,"20","Series1:Y2"," Series2:Y") |
Parameter: |
Period property, used to determine a time period that is used in the Weighted moving average. |
FormulaFinancial(FinancialFormula.WeightedMovingAverage,"20","Series1:Y2","Series2:Y") |
A line chart is a good choice when displaying a weighted moving average.
Financial Interpretation: The Weighted moving average is used to compare a value with it's Weighted moving average, and gives more influence for recent data and less influence for past data.
The most important element used in calculating the moving average is a time period, which should be equal to the observed market cycle.
The Weighted moving average is lagging indicator, and will always be behind the price.
When the price is following a trend the Weighted moving average is very close to the price. When a price is increasing the Weighted moving average most likely will stay down because of the influence of the historical data.
Calculation: The Weighted moving average is calculated using a sum of indexes of time periods (data points).
Weight for every period is calculated as "index / (Number of data points)".
The following table demonstrates how to calculate a 5 days weighted moving average:
Day |
1 |
2 |
3 |
4 |
5 |
Weight |
1/15 |
2/15 |
3/15 |
4/15 |
5/15 |
Price |
32 |
21 |
24 |
11 |
16 |
Weighted Value |
2.133 |
2.8 |
4.8 |
2.933 |
5.333 |
5 Day Weighted Moving Average |
|
|
|
|
18 |
Example
This example demonstrates how to calculate a 20 day Weighted Moving average using the Formula method.
Visual Basic | Copy Code |
---|---|
|
C# | Copy Code |
---|---|
|