Home Login  |   Contact  |   About Us       Tuesday, October 15, 2024   

Pj0182295- Back to Home
   Skip Navigation LinksHOME ›  AREAS OF EXPERTISE  #2 ›   Curve Fitting  ›  ~ Weighted Moving Avg



Skip Navigation Links.



"Curve Fitting Solutions"
Weighted Moving Average Method
WMA =


DATA ARRAY

{ , , , , , , , , ,
, , , , , , , , , }



[ 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 } ]

Time Frame:

                                       

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());
              }



Other Implementations...


Object-Oriented Implementation
Graphics and Animation
Sample Applications
Ore Extraction Optimization
Vectors and Matrices
Complex Numbers and Functions
Ordinary Differential Equations - Euler Method
Ordinary Differential Equations 2nd-Order Runge-Kutta
Ordinary Differential Equations 4th-Order Runge-Kutta
Higher Order Differential Equations
Nonlinear Systems
Numerical Integration
Numerical Differentiation
Function Evaluation


   Quotes

Consulting Services - Back to Home


Home

Home Math, Analysis,
  expertise..."

EIGENVALUE
SOLUTIONS...


> Rayleigh-Quotient Method

> Cubic Spline Method

 

Applied Mathematical Algorithms

Home

ComplexFunctions

Home

NonLinear
Home

Differentiation
Home

Integration
About Us


KMP Software Engineering is an independent multidisciplinary engineering consulting company specializing in mathematical algorithms.

      (About Us) →
Areas of
Expertise


SpecialFunctions
VectorsMatrices
OptimizationMethods
ComplexNumbers
Interpolation
CurveFitting
NonLinearSystems
LinearEquations
DistributionFunctions
NumericalDifferentiation
NumericalIntegration
DifferentialEquations
Smalltalk
FiniteBoundary
Eigenvalue
Graphics
Understanding
Mining


MiningMastery
MineralNews
MineralCommodities
MineralForum
Crystallography
Services


NumericalModeling
WebServices
MainframeServices
OutsourceServices

LINKED IN
MINE REVIEW(by G.Pacheco)
Brand





Home

Login

Contact
Since 2006 All Rights Reserved  © KMP Software Engineering LINKS | PRIVACY POLICY | LEGAL NOTICE