21
THE MOVING AVERAGE INDICATOR Introduction: In statistics, a moving average, also called rolling average, moving mean, rolling mean, sliding temporal average, or running average, is a type of FIR filter used to analyze a set of data points by creating a series of averages of different subsets of the full data set. 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 number following the original subset in the series. This creates a new subset of numbers, which is averaged. This process is repeated over the entire data series. The plot line connecting all the (fixed) averages is the moving average. A moving average is a set of numbers, each of which is the average of the corresponding subset of a larger set of datum points. A moving average may also use unequal weights for each datum value in the subset to emphasize particular values in the subset. A moving average is commonly used with time series data to smooth out short-term fluctuations and highlight longer-term trends or cycles. The threshold between short-term and long-term depends on the application, and the parameters of the moving average will be set accordingly. For example, it is often used in technical analysis of financial data, like stock prices, returns or trading volumes. It is also used in economics to examine gross domestic product, employment or other macroeconomic time series. Mathematically, a moving average is a type of convolution and so it can be viewed as an example of alow-pass filter used in signal processing. When used with non-time series data, a moving average filters higher frequency components without any specific connection to time, 1

The Moving Average Indicator

Embed Size (px)

Citation preview

Page 1: The Moving Average Indicator

THE MOVING AVERAGE INDICATOR

Introduction:

In statistics, a moving average, also called rolling average, moving mean, rolling mean, sliding temporal average, or running average, is a type of FIR filter used to analyze a set of data points by creating a series of averages of different subsets of the full data set.

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 number following the original subset in the series. This creates a new subset of numbers, which is averaged. This process is repeated over the entire data series. The plot line connecting all the (fixed) averages is the moving average. A moving average is a set of numbers, each of which is the average of the corresponding subset of a larger set of datum points. A moving average may also use unequal weights for each datum value in the subset to emphasize particular values in the subset.

A moving average is commonly used with time series data to smooth out short-term fluctuations and highlight longer-term trends or cycles. The threshold between short-term and long-term depends on the application, and the parameters of the moving average will be set accordingly. For example, it is often used in technical analysis of financial data, like stock prices, returns or trading volumes. It is also used in economics to examine gross domestic product, employment or other macroeconomic time series. Mathematically, a moving average is a type of convolution and so it can be viewed as an example of alow-pass filter used in signal processing. When used with non-time series data, a moving average filters higher frequency components without any specific connection to time, although typically some kind of ordering is implied. Viewed simplistically it can be regarded as smoothing the data

The Moving Average Technical Indicator shows the mean instrument price value for a certain period of time. When one calculates the moving average, one averages out the instrument price for this time period. As the price changes, its moving average either increases, or decreases.

There are four different types of moving averages:

-  Simple (also referred to as Arithmetic)- Exponential - Smoothed - Linear Weighted

The only thing where moving averages of different types diverge considerably from each other, is when weight coefficients, which are assigned to the latest data, are different. In case we are talking of simple moving average, all prices of the time period in question, are

1

Page 2: The Moving Average Indicator

equal in value. Exponential and Linear Weighted Moving Averages attach more value to the latest prices.

The most common way to interpreting the price moving average is to compare its dynamics to the price action. When the instrument price rises above its moving average, a buy signal appears, if the price falls below its moving average, what we have is a sell signal.

This trading system, which is based on the moving average, is not designed to provide entrance into the market right in its lowest point, and its exit right on the peak. It allows to act according to the following trend: to buy soon after the prices reach the bottom, and to sell soon after the prices have reached their peak.

Moving averages may also be applied to indicators. That is where the interpretation of indicator moving averages is similar to the interpretation of price moving averages: if the indicator rises above its moving average, that means that the ascending indicator movement is likely to continue: if the indicator falls below its moving average, this means that it is likely to continue going downward.

1) SIMPLE MOVING AVERAGE (SMA)

In financial applications a simple moving average (SMA) is the unweighted mean of the previous n datum 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 closing price is the mean of the previous n days' closing prices. Simple, in other words, arithmetical moving average is calculated by summing up the prices of instrument closure over a certain number of single periods (for instance, 12 hours). This value is then divided by the number of such periods.Here are the simple moving averages on the chart:

2

Page 3: The Moving Average Indicator

Calculation:

Simple Moving Average (SMA) Simple, in other words, arithmetical moving average is calculated by summing up the prices of instrument closure over a certain number of single periods (for instance, 12 hours). This value is then divided by the number of such periods.

 If those prices are   then the formula is

When calculating successive values, a new value comes into the sum and an old value drops out, meaning a full summation each time is unnecessary for this simple case,

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 rising market, or resistance in a falling market.

If the data used are not centered around the mean, a simple moving average lags behind the latest datum point by half the sample width. An SMA can also be disproportionately influenced by old datum points dropping out or new data coming in. One characteristic of the SMA is that if the data have a periodic fluctuation, then applying an SMA of that period will eliminate that variation (the average always containing one complete cycle). But a perfectly regular cycle is rarely encountered.[1]

For a number of applications it is advantageous to avoid the shifting induced by using only 'past' data. Hence a central moving average can be computed, using data equally spaced either side of the point in the series where the mean is calculated. This requires using an odd number of datum points in the sample window.

Other formula is looks like:

SMA=SUM(CLOSE,N)/N

Where:N — is the number of calculation periods.

2) EXPONENTIAL MOVING AVERAGE (EMA)

An exponential moving average (EMA), also known as an exponentially weighted moving average (EWMA),is a type of infinite impulse response filter that applies weighting factors which decrease exponentially. The weighting for each older datum point decreases exponentially, never reaching zero. The graph at right shows an example of the weight decrease.

3

Page 4: The Moving Average Indicator

Here are the exponential moving averages on the chart:

Calculation:

Exponential Moving Average (EMA):

    Exponentially smoothed moving average is calculated by adding the moving average of a certain share of the current closing price to the previous value. With exponentially smoothed moving averages, the latest prices are of more value. P-percent exponential moving average will look like:

   EMA=(CLOSE(i)*P)+(EMA(i-1)*(100-P))

    Where:CLOSE(i)—the price of the current period closure;EMA(i-1) — Exponentially Moving Average of the previous period closure;P — the percentage of using the price value.

The EMA for a series Y may be calculated recursively:

for 

Where:

The coefficient α represents the degree of weighting decrease, a constant smoothing factor between 0 and 1. A higher α discounts older observations faster. Alternatively, α may be expressed in terms of N time periods, where α = 2/(N+1). For example, if N = 19 is equivalent to α = 0.1, the half-life of the weights (the

4

Page 5: The Moving Average Indicator

interval over which the weights decrease by a factor of two) is approximately N/2.8854 (within 1% if N > 5).

Yt is the value at a time period t. St is the value of the EMA at any time period t.

S1 is undefined. S1 may be initialized in a number of different ways, most commonly by setting S1 to Y1, though other techniques exist, such as setting S1 to an average of the first 4 or 5 observations. The prominence of the S1 initialization's effect on the resultant moving average depends on α; smaller α values make the choice of S1 relatively more important than larger αvalues, since a higher α discounts older observations faster.

This formulation is according to Hunter (1986). By repeated application of this formula for different times, we can eventually write St as a weighted sum of the datum points Yt, as:

for any suitable k = 0, 1, 2, ... The weight of the general datum point   

is  .

An alternate approach by Roberts (1959) uses Yt in lieu of Yt−1 :

This formula can also be expressed in technical analysis terms as follows, showing how the EMA steps towards the latest datum point, but only by a proportion of the difference (each time):

Expanding out  each time results in the following power series, showing how the weighting factor on each datum point p1, p2, etc., decreases exponentially:

Where:

 is 

 is  and so on

,

since  .

This is an infinite sum with decreasing terms.

The N periods in an N-day EMA only specify the α factor. N is not a stopping point for the calculation in the way it is in an SMA or WMA. For sufficiently large N, The first N datum points in an EMA represent about 86% of the total weight in the calculation:

5

Page 6: The Moving Average Indicator

i.e.   simplified, tends to  .

The above discussion requires a bit of clarification. The sum of the weights of all the terms (i.e., infinite number of terms) in an exponential moving average is 1. The sum of the weights

of  terms is  . Both of these sums can be derived by using the formula for the sum of a geometric series. The weight omitted after   terms is given by subtracting this

from 1, and you get   (this is essentially the formula given below for the weight omitted). Note that there is no "accepted" value that should be chosen for   although there are some recommended values based on the application. In the above discussion, we have substituted a commonly used value

for   in the formula for the weight of   terms. This value for   comes from setting the average age of the data from a SMA equal to the average age of the data from an EWA and solving for  . Again, it is just a recommendation -- not a requirement. If you

make this substitution, and you make use of  , then you get the 0.864 approximation. Intuitively, what this is telling us is that the weight after   terms of an `` -period" exponential moving average converges to 0.864.

The power formula above gives a starting value for a particular day, after which the successive days formula shown first can be applied. The question of how far back to go for an initial value depends, in the worst case, on the data. Large price values in old data will affect on the total even if their weighting is very small. If prices have small variations then just the weighting can be considered. The weight omitted by stopping after k terms is

which is

i.e. a fraction

out of the total weight.

For example, to have 99.9% of the weight, set above ratio equal to 0.1% and solve for k:

terms should be used. Since   approaches   as N increases, this simplifies to approximately for this example (99.9% weight).

6

Page 7: The Moving Average Indicator

EMA weights N=15

3) Smoothed Moving Average (SMMA):

A Smoothed Moving Average is sort of a blend between a Simple Moving Average and an Exponential Moving Average, only with a longer period applied (approximately, half the EMA period: e.g. a 20-period SMMA is almost equal to a 40-period EMA).Here are the smoothed moving averages on the chart:

Calculation:

Smoothed Moving Average (SMMA):

7

Page 8: The Moving Average Indicator

The first value of this smoothed moving average is calculated as the simple moving average (SMA):

PREVSUM = SMMA(i-1) *N

The second and succeeding moving averages are calculated according to this formula:SMMA(i) = (PREVSUM-SMMA(i-1)+CLOSE(i))/N  Where:SUM1 — is the total sum of closing prices for N periods;SMMA1 — is the smoothed moving average of the first bar;SMMA(i) — is the smoothed moving average of the current bar (except for the first one);CLOSE(i) — is the current closing price;N — is the smoothing period.

4) Linear Weighted Moving Average (LWMA )

In the case of weighted moving average, the latest data is of more value than more early data. Weighted moving average is calculated by multiplying each one of the closing prices within the considered series, by a certain weight coefficient. A weighted average is any average that has multiplying factors to give different weights to data at different positions in the sample window. Mathematically, the moving average is the convolution of the datum points with a fixed weighting function.

Here are the linear weighted moving averages on the chart:

Calculation:

Linear Weighted Moving Average (LWMA)

8

Page 9: The Moving Average Indicator

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

The denominator is a triangle number equal to   In the more general case the denominator will always be the sum of the individual weights.

When calculating the WMA across successive values, the difference between the numerators of WMAM+1 and WMAM isnpM+1 − pM − ⋅⋅⋅ − pM−n+1. If we denote the sum pM + ⋅⋅⋅ + pM−n+1 by TotalM, then

The graph shows how the weights decrease, from highest weight for the most recent datum points, down to zero. It can be compared to the weights in the exponential moving average which follows.

WMA weights n = 15

Weighted moving average is calculated by multiplying each one of the closing prices within the considered series, by a certain weight coefficient.

LWMA = SUM(Close(i)*i, N)/SUM(i, N)Where: SUM(i, N) — is the total sum of weight coefficients.

9

Page 10: The Moving Average Indicator

Here are the all types of moving averages on the chart:

Simple Moving Average (SMA) Exponential Moving Average (EMA) Smoothed Moving Average (SMMA) Linear Weighted Moving Average (LWMA)

Uses:

Some of the primary functions of a moving average are to identify trends and reversals, measure the strength of an asset's momentum and determine potential areas where an asset will find support or resistance. In this section we will point out how different time periods can monitor momentum and how moving averages can be beneficial in setting stop-losses. Furthermore, we will address some of the capabilities and limitations of moving averages that one should consider when using them as part of a trading routine. 

Trend Identifying trends is one of the key functions of moving averages, which are used by most traders who seek to "make the trend their friend". Moving averages are lagging indicators, which means that they do not predict new trends, but confirm trends once they have been established. As you can see in Figure 1, a stock is deemed to be in an uptrend when the price is above a moving average and the average is sloping upward. Conversely, a trader will use a price below a downward sloping average to confirm a downtrend. Many traders will only consider holding a long position in an asset when the price is trading above a moving average. This simple rule can help ensure that the trend works in the traders' favor. 

10

Page 11: The Moving Average Indicator

Momentum

One of the best methods to determine the strength and direction of an asset's momentum is to place three moving averages onto a chart and then pay close attention to how they stack up in relation to one another. The three moving averages that are generally used have varying time frames in an attempt to represent short-term, medium-term and long-term price movements. In Figure 2, strong upward momentum is seen when shorter-term averages are located above longer-term averages and the two averages are diverging. Conversely, when the shorter-term averages are located below the longer-term averages, the momentum is in the downward direction. 

Support 

Another common use of moving averages is in determining potential price supports. It does not take much experience in dealing with moving averages to notice that the falling price of an asset will often stop and reverse direction at the same level as an important average. For example, in Figure 3 you can see that the 200-day moving average was able to prop up the price of the stock after it fell from its high near $32. Many traders will anticipate a bounce off of major moving averages and will use other technical indicators as confirmation of the expected move. 

11

Page 12: The Moving Average Indicator

Resistance 

Once the price of an asset falls below an influential level of support, such as the 200-day moving average, it is not uncommon to see the average act as a strong barrier that prevents investors from pushing the price back above that average. As you can see from the chart below, this resistance is often used by traders as a sign to take profits or to close out any existing long positions. Many short sellers will also use these averages as entry points because the price often bounces off the resistance and continues its move lower. If you are an investor who is holding a long position in an asset that is trading below major moving averages, it may be in your best interest to watch these levels closely because they can greatly affect the value of your investment. 

Stop-Losses :

The support and resistance characteristics of moving averages make them a great tool for managing risk. The ability of moving averages to identify strategic places to set stop-loss orders allows traders to cut off losing positions before they can grow any larger. As you can see in Figure 5, traders who hold a long position in a stock and set their stop-loss orders below influential averages can save themselves a lot of money. Using moving averages to set stop-

12

Page 13: The Moving Average Indicator

loss orders is key to any successful trading strategy. 

Strategies

Different investors use moving averages for different reasons. Some use them as their primary analytical tool, while others simply use them as a confidence builder to back up their investment decisions.

Crossovers : A crossover is the most basic type of signal and is favored among many traders because it removes all emotion. The most basic type of crossover is when the price of an asset moves from one side of a moving average and closes on the other. Price crossovers are used by traders to identify shifts in momentum and can be used as a basic entry or exit strategy. As you can see in Figure 1, a cross below a moving average can signal the beginning of a downtrend and would likely be used by traders as a signal to close out any existing long positions. Conversely, a close above a moving average from below may suggest the beginning of a new uptrend. 

The second type of crossover occurs when a short-term average crosses through a long-term average. This signal is used by traders to identify that momentum is shifting in one direction and that a strong move is likely approaching. A buy signal is generated when the short-term average crosses above the long-term average, while a sell signal is triggered by a short-term average crossing below a long-term average. As you can see from the chart below,

13

Page 14: The Moving Average Indicator

this signal is very objective, which is why it's so popular. 

Triple Crossover and the Moving Average Ribbon: 

Additional moving averages may be added to the chart to increase the validity of the signal. Many traders will place the five-, 10-, and 20-day moving averages onto a chart and wait until the five-day average crosses up through the others – this is generally the primary buy sign. Waiting for the10-day average to cross above the 20-day average is often used as confirmation, a tactic that often reduces the number of false signals. Increasing the number of moving averages, as seen in the triple crossover method, is one of the best ways to gauge the strength of a trend and the likelihood that the trend will continue. 

This begs the question: What would happen if you kept adding moving averages? Some people argue that if one moving average is useful, then 10 or more must be even better. This leads us to a technique known as the moving average ribbon. As you can see from the chart below, many moving averages are placed onto the same chart and are used to judge the strength of the current trend. When all the moving averages are moving in the same direction, the trend is said to be strong. Reversals are confirmed when the averages cross over and head in the opposite direction. 

14

Page 15: The Moving Average Indicator

Responsiveness to changing conditions is accounted for by the number of time periods used in the moving averages. The shorter the time periods used in the calculations, the more sensitive the average is to slight price changes. One of the most common ribbons starts with a 50-day moving average and adds averages in 10-day increments up to the final average of 200. This type of average is good at identifying long-term trends/reversals. 

Filters : A filter is any technique used in technical analysis to increase one's confidence about a certain trade. For example, many investors may choose to wait until a security crosses above a moving average and is at least 10% above the average before placing an order. This is an attempt to make sure the crossover is valid and to reduce the number of false signals. The downside about relying on filters too much is that some of the gain is given up and it could lead to feeling like you've "missed the boat". These negative feelings will decrease over time as you constantly adjust the criteria used for your filter. There are no set rules or things to look out for when filtering; it's simply an additional tool that will allow you to invest with confidence. 

Moving Average Envelope  Another strategy that incorporates the use of moving averages is known as an envelope. This strategy involves plotting two bands around a moving average, staggered by a specific percentage rate. For example, in the chart below, a 5% envelope is placed around a 25-day moving average. Traders will watch these bands to see if they act as strong areas of support or resistance. Notice how the move often reverses direction after approaching one of the levels. A price move beyond the band can signal a period of exhaustion, and traders will watch for a reversal toward the center average. 

Figure 4

Conclusion:

Few technical indicators are as popular and widely followed as the  moving average.Moving averages come in various forms, but their underlying purpose remains the same: to help technical traders track the trend of financial assets by smoothing out the day-to-day price fluctuations, or noise. The simplest form of a moving average is appropriately known as a simple moving average(SMA). It is calculated by taking the arithmetic mean of a

15

Page 16: The Moving Average Indicator

given set of values.The exponential moving average (EMA) assigns a weighting to recent data because many traders regard this as the major downfall of the SMA.Some of the primary roles of a moving average include identifying trends and reversals, measuring the strength of an asset's momentum and determining potential areas where an asset will find support or resistance.A moving average can be a great risk management tool because of its ability to identify strategic areas to stop losses.Using moving averages can be very ineffective during periods where the asset is trending sideways.There are many different strategies involving moving averages. The most popular is the moving average crossover.Moving averages are used in the creation of a number of other very popular technical indicators such as the moving average convergence divergence (MACD) or Bollinger Bands®.Moving averages won't solve all your investing problems. However, when used judiciously, they can be valuable tools in planning your trading strategy. 

16