# Moving Average/Weighted

## 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. 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)+\dots +1={\frac {n\cdot (n+1)}{2}}$ and $p_{t}(x)={\begin{cases}{\frac {n-(t-x)}{s(n)}}&\mathrm {for} \ 0\leq t-n\leq x\leq t,\\[8pt]0&\mathrm {for} \ xt\end{cases}}$ The weighted moving average can be calculated for $t\geq n$ with the discrete probability mass function $p_{t}$ at time $t\in \mathbb {N} _{0}:=\{0,1,2\dots ,\}$ , 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\in \mathbb {N} _{0}$ for an arbitrary day x.

${\text{WMA}}(t):=\sum _{x\in T=\mathbb {N} _{0}}p_{t}(x)\cdot C(x)=\sum _{x=t-n+1}^{t}p_{t}(x)\cdot C(x)={\frac {n\cdot C(t)+(n-1)\cdot C(t-1)+\cdots +2\cdot C(t-n+2)+1\cdot C(t-n+1)}{n+(n-1)+\cdots +2+1}}$ The denominator is a triangle number equal to ${\frac {n(n+1)}{2}}$ which creates a discrete probability distribution by:

${\frac {1}{s(n)}}+{\frac {2}{s(n)}}+\ldots +{\frac {n}{s(n)}}={\frac {1+2+\ldots +n}{s(n)}}={\frac {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 $w_{0},\ldots ,w_{n}$ the denominator will always be the sum of the individual weights, i.e.:

$s(n):=\sum _{k=0}^{n}w_{k}$ and $w_{0}$ as weight for for the most recent datum points at day t and $w_{n}$ as weight for the day $t-n$ , which is n-th day before the most recent day $t$ .

The discrete probability distribution $p_{t}$ is defined by:

$p_{t}(x)={\begin{cases}{\frac {w_{t-x}}{s(n)}}&\mathrm {for} \ 0\leq t-n\leq x\leq t,\\[8pt]0&\mathrm {for} \ 0\leq xt\end{cases}}$ The weighted moving average with arbitrary weights is calculated by:

${\text{WMA}}(t):=\sum _{x\in T=\mathbb {N} _{0}}p_{t}(x)\cdot C(x)=\sum _{x=t-n}^{t}p_{t}(x)\cdot C(x)={\frac {w_{0}\cdot C(t)+w_{1}\cdot C(t-1)+\cdots +w_{n-1}\cdot C(t-n+1)+w_{n}\cdot C(t-n)}{w_{0}+\cdots +w_{n-1}+w_{n}}}$ 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.