|
"Curve Fitting Solutions" |
|
Weighted Moving Average Method |
|
WMA = |
|
{
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
}
[ Initial Data Array(top): { 45.375, 45.500, 45.000, 43.625, 43.375, 43.125, 43.125, 44.250, 43.500, 44.375 } ]
[ Initial Data Array(bot): { 45.875, 46.750, 47.625, 48.000, 49.125, 48.750, 46.125, 46.750, 46.625, 46.000 } ]
Please0 enter only numbers
Please1 enter only numbers
Please2 enter only numbers
Please3 enter only numbers
Please4 enter only numbers
Please5 enter only numbers
Please6 enter only numbers
Please7 enter only numbers
Please8 enter only numbers
Please9 enter only numbers
Please10 enter only numbers
Please enter only numbers
Please enter only numbers
Please enter only numbers
Please enter only numbers
Please enter only numbers
Please enter only numbers
Please enter only numbers
Please enter only numbers
Please enter only numbers
|
IMPLEMENTATION
Curve Fitting Weighted Moving Average
A weighted average is any average that has multiplying factors that give different weights to different data points.
In technical analysis, a weighted moving average specifically means weights which decrease arithmetically. In an
n-day weighted moving average the lastest day has weight n,
the second latest n-1, etc., down to zero:
WMA = [np0 + (n -1)p-1 + ... + 2p-n+2) + p-n+1] / [n + (n -1) + ... + 2 + 1]
|
2/ n(n + 1) ∑i=0 (n - i) p-i
|
Testing the Weighted Average Moving Method
Using the algorithm developed under (see) Simple Moving Average, it is
possible to implement the weighted moving average method.
In this method, each period's price is multiplied by a given weight. The products of the calculation are summed and divided by
the total of the weights.
As a sample we provide the input data points using one double array using data of a stock for 20 days
(Data Array), we use the same closing data of stock for 20 days that was used under
Simple Moving Average
use to calculate a 5-day time frame n weighted moving average.
Running this application produces the results WMA shown above.
The user can manipulate all values and try variations on the arrays themselves by
specifying new estimate values. For comparison purposes, the user can plot the data, the 5-day weighted, and simple average. It
will show that the weighted moving average is closer to data than the simple moving average is.
In order to test the Weighted Average Moving Method as defined above, a new WeightedAverageMovingMethod()
static method has been added and executed. Supporting code and methods are not shown.
static void WeightedAverageMovingMethod();
{
ListBox1.Items.Clear();
double[] xarray = new double[] {t1, t2, t3, t4, t5, t6, t7, t8,
t9, t10, t11, t12, t13, t14, t15, t16,
t17, t18, t19, t20};
VectorR wma = CurveFitting.WeightedMovingAverage(data, t21);
ListBox1.Items.Add(" " + wma.ToString());
}
|
|
|
|