Moving Average(MA)

In statistics, a moving average (rolling average or running average) is a calculation to analyze data points by creating a series of averages of different subsets of the full data set. It is also called a moving mean (MM)[1] or rolling mean and is a type of finite impulse response filter. Variations include: simple, and cumulative, or weighted forms (described below).

Given a series of numbers and a fixed subset size, the first element of the moving average is obtained by taking the average of the initial fixed subset of the number series. Then the subset is modified by "shifting forward"; that is, excluding the first number of the series and including the next value in the subset.

Simple Moving Average(SMA)

In financial applications, a simple moving average (SMA) is the unweighted mean of the previous n data-points. However, in science and engineering, the mean is normally taken from an equal number of data on either side of a central value. This ensures that variations in the mean are aligned with the variations in the data rather than being shifted in time. An example of a simple equally weighted running mean for a n-day sample of the closing price is the mean of the previous n days' closing prices. Let those prices be {\displaystyle p_{1},p_{2},\dots ,p_{n}}. Let the mean over the first k data-points be {\displaystyle {\overline {p}}_{k}}. Thus, the mean over all the data-points is calculated as: {\displaystyle {\begin{aligned}{\overline {p}}_{n}&={\frac {p_{1}+p_{2}+\cdots +p_{n}}{n}}\\&={\frac {1}{n}}\sum _{i=1}^{n}p_{i}\end{aligned}}}

This means that the moving average filter can be computed quite cheaply on real time data with a FIFO / circular buffer.

When calculating successive values, a new value comes into the sum, and the oldest value drops out. This means that a full summation each time is unnecessary. Thus, the new mean can be calculated as:{\displaystyle {\overline {p}}_{n}={\overline {p}}_{n-1}+{\frac {1}{n}}(p_{n}-{\overline {p}}_{n-1})}

The period selected depends on the type of movement of interest, such as short, intermediate, or long-term. In financial terms, moving-average levels can be interpreted as support in a falling market or resistance in a rising market.

Last updated

Was this helpful?