Moving Average/Weighted

From testwiki
Jump to navigation Jump to search

Mathematical Definition: Weighted moving average

In technical analysis of financial data, a weighted moving average (WMA) has the specific meaning of weights that decrease in arithmetical progression.[1] In an n-day WMA the latest day has weight n, the second latest n − 1, etc., down to one. These weights create a discrete probability distribution with:

s(n):=n+(n1)++1=n(n+1)2 and pt(x)={n(tx)s(n)for 0tnxt,0for x<tn or x>t

The weighted moving average can be calculated for tn with the discrete probability mass function pt at time t0:={0,1,2,}, where t=0 is the initial day, when data collection of the financial data begins and C(0) the price/cost of a product at day t=0. C(x) the price/cost of a product at day x0 for an arbitrary day x.

WMA(t):=xT=0pt(x)C(x)=x=tn+1tpt(x)C(x)=nC(t)+(n1)C(t1)++2C(tn+2)+1C(tn+1)n+(n1)++2+1
WMA weights n = 15

The denominator is a triangle number equal to n(n+1)2 which creates a discrete probability distribution by:

1s(n)+2s(n)++ns(n)=1+2++ns(n)=s(n)s(n)=1

The graph at the right shows how the weights decrease, from highest weight at day t for the most recent datum points, down to zero at day t-n.

In the more general case with weights w0,,wn the denominator will always be the sum of the individual weights, i.e.:

s(n):=k=0nwk and w0 as weight for for the most recent datum points at day t and wn as weight for the day tn, which is n-th day before the most recent day t.

The discrete probability distribution pt is defined by:

pt(x)={wtxs(n)for 0tnxt,0for 0x<tn or x>t

The weighted moving average with arbitrary weights is calculated by:

WMA(t):=xT=0pt(x)C(x)=x=tntpt(x)C(x)=w0C(t)+w1C(t1)++wn1C(tn+1)+wnC(tn)w0++wn1+wn

This general approach can be compared to the weights in the exponential moving average in the following section.