A weighted average has multiplying factors that give different weights to different data points. Mathematically, the moving average is the convolution of the data points with a moving average function. In technical analysis, a weighted moving average (WMA) has the specific meaning of weights that decrease arithmetically. In an n-day WMA, the most recent data point has weight n, the second most recent data point has weight (n - 1), and so on, until the weight is zero.
Where n is the number of old values to be considered for calculating the new weighted moving average:
TotalM+1 = TotalM + PM+1 - PM-n+1 NumeratorM+1 = NumeratorM + n*pM+1 - TotalM WMAVGM+1 = NumeratorM+1/(n(n+1)/2)