Jump to content

Moving Average/Weighted

From Wikiversity

Mathematical Definition: Weighted moving average

[edit | edit source]

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+(n−1)+⋯+1=n⋅(n+1)2 and pt(x)={n−(t−x)s(n)for 0≤t−n≤x≤t,0for x<t−n or x>t

The weighted moving average can be calculated for t≥n with the discrete probability mass function pt at time t∈ℕ0:={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 x∈ℕ0 for an arbitrary day x.

WMA(t):=∑x∈T=ℕ0pt(x)⋅C(x)=∑x=t−n+1tpt(x)⋅C(x)=n⋅C(t)+(n−1)⋅C(t−1)+⋯+2⋅C(t−n+2)+1⋅C(t−n+1)n+(n−1)+⋯+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 t−n, which is n-th day before the most recent day t.

The discrete probability distribution pt is defined by:

pt(x)={wt−xs(n)for 0≤t−n≤x≤t,0for 0≤x<t−n or x>t

The weighted moving average with arbitrary weights is calculated by:

WMA(t):=∑x∈T=ℕ0pt(x)⋅C(x)=∑x=t−ntpt(x)⋅C(x)=w0⋅C(t)+w1⋅C(t−1)+⋯+wn−1⋅C(t−n+1)+wn⋅C(t−n)w0+⋯+wn−1+wn

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

  1. ↑ "Weighted Moving Averages: The Basics". Investopedia.