Smoothing time series using simple moving averages. Methods without a seasonal component

Smoothing time series using simple moving averages. Methods without a seasonal component

One of the simplest ways to solve this problem is to use the moving averages method.

The moving average method allows the trader to smooth out and quickly determine the direction of the current trend.

Types of moving averages

There are three different types of moving averages, which differ in their calculation algorithms, but they are all interpreted the same. The difference in the calculations lies in the weight given to the prices. In one case, all prices may have equal weight; in another, more recent data has more weight.

The three most common types of moving averages are:

  1. simple
  2. linear weighted
  3. exponential

Simple Moving Average (SMA, Simple Moving Average)

This is the most common method for calculating moving average prices. You just need to take the sum of the closing prices for a certain period and divide by the number of prices used for the calculation. That is, this is the calculation of a simple arithmetic mean.

For example, for a ten-day simple moving average, we would take the closing prices of the last 10 days, add them together and divide by 10.

As you can see in the picture below, a trader can make moving averages smoother by simply increasing the number of days (hours, minutes) used for calculation. A long period for calculating a moving average is usually used to show a long-term trend.

Many people question the wisdom of using simple moving average prices because each point has the same meaning. Critics of this calculation method believe that more recent data should carry more weight. It is arguments like this that led to the creation of other types of moving averages.

Weighted moving average (WMA, Linear Weighted Average)

This version of the moving average price is the least used indicator of the three. Initially, it was supposed to combat the shortcomings of calculating a simple moving average. To build a weighted moving average, you need to take the sum of closing prices for a certain period, multiplied by a serial number, and divide the resulting number by the number of factors.

For example, to calculate a five-day weighted moving average, you would take today's closing price and multiply it by five, then take yesterday's closing price and multiply it by four, and continue until the end of the period. Then these values ​​must be added and divided by the sum of the factors.

Exponential Moving Average (EMA)

This type of moving average represents a "smoothed" version of the WMA, where more weight is given to recent data. This formula is considered more effective than the one used to calculate the weighted moving average.

You don't need to fully understand how all types of moving averages are calculated. Any modern trading terminal will build you this indicator with any settings.

The formula for calculating the exponential moving average is as follows:

EMA = (closing price – EMA (previous period) * multiplier + EMA (previous period)

The most important thing you should know about the exponential moving average is that it is more responsive to new data compared to the simple moving average. This is a key factor why exponential calculation is more popular and is used by most traders today.

As you can see in the image below, an EMA with a period of 15 reacts faster to price changes than an SMA with the same period. At first glance, the difference does not seem significant, but this impression is deceptive. This difference can play a key role during real trading.

Determining the trend using moving averages

Moving averages are used to determine the current trend and when it will reverse, as well as to find resistance and support levels.

Moving averages allow you to very quickly understand which direction the trend is currently directed.

Look at the image below. Obviously, when the moving average moves below the price chart, we can confidently say that the trend is upward. Conversely, when the moving average is above the price chart, the trend is considered downward.

Another way to determine the trend direction is to use two moving averages with different periods for the calculation. When the short-term average is above the long-term average, the trend is considered upward. Conversely, when the short-term average is below the long-term average, the trend is considered downward.

Determining trend reversal using moving averages

Trend reversals using moving averages are determined in two ways.

The first is when the average crosses the price chart. For example, when a 50-period moving average crosses the price chart, as in the image below, it often means the trend has changed from up to down.

Another option for receiving signals about possible trend reversals is to monitor the intersection of moving averages, short-term and long-term.

For example, in the image below you can see how the moving average with a calculation period of 15 crosses the moving average with a period of 50 from the bottom up, which signals the beginning of an uptrend.

If the periods used to calculate the averages are relatively short (for example, 15 and 35), then their intersections will signal short-term trend reversals. On the other hand, to track long-term trends, much longer periods are used, such as 50 and 200.

Moving averages as support and resistance levels

Another fairly common way to use moving averages is to determine support and resistance levels. For this, moving averages with long periods are usually used.

When the price approaches the support or resistance line, the probability of it “bouncing” from this level is quite high, as can be seen in the image below. If the price breaks the long-term moving average, then there is a high probability that the price will continue to move in the same direction.

Conclusion

Moving averages in technical analysis are one of the most powerful and at the same time simple tools for market analysis. They allow the trader to quickly determine the direction of long-term and short-term trends, as well as support and resistance levels.

Each trader uses his own settings to calculate moving averages. Much here depends on the style of trading and on what financial market they are used in (market, currency exchange, etc.).

Moving averages help technical analysts remove the so-called “noise” of daily price fluctuations from the chart. Traditionally, moving averages are called trend indicators.


Average lines are graphical constructions on a chart that are based on average price values ​​over a certain period of time. Moving Average is built into the MT4 trading platform; it can be used to smooth moving averages, which is what we will talk about in this article.

Moving Average Smoothing

Moving Average allows you to smooth moving averages. What are the benefits of this feature? This is because a simple exponential average (SMA) uses prices of equal importance, while exponential moving averages rely more on recent quotes. The latter are built according to a certain formula, where recent events in the market play a big role, and not the changes that occurred earlier.

Varieties of midlines

In total, Moving Average offers the construction of four lines, which are built according to a certain principle.

  • Simple – simple moving average. This is the simplest line, which is constructed according to a formula where all prices have equivalent values. 2. Exponential – exponential moving average, which is built according to a formula in which the last bar plays the main role. It is suitable for short-term trading.
  • Smoothed – smoothed moving average. This moving average is used for long-term trading. In order for it to change its direction, a significant leap is required.
  • Linear Weighted is a weighted moving average that pays more attention to newer changes in the market.

Which is better: a simple moving average or a smoothed one?

By increasing the period of the moving average, more value values ​​will take part in the calculation. The longer the period, the less sensitive the moving average and vice versa. But which is better: a simple moving average or a smoothed one?

For example, let's take a period value of 15. To construct lines, the values ​​of bars from 1 to 15 will be taken into account; as soon as bar 16 appears, bars in the range of 2-16 will be taken into account in the calculations. At the same time, when constructing a regular moving average, prices will have the same values, while in a smoothed one everything will depend on the last bar.

Each moving average has its own pros and cons, which should definitely be taken into account when choosing the most suitable type for trading. The choice of moving average directly depends on the currency pair used, time frame and trading strategy. All sliding lines have one common drawback, which is a slight lag.

Application of moving averages

The simplest way to use this tool is to build two moving averages with different periods. A line with a short period will be more mobile. At the moment when the prevailing trend changes in the market, the fast moving line crosses the slow one, which, in turn, is a signal to create an order.

In the picture below you can see how the above situation looks on a currency chart.

Hello, dear friends!

In this article, as its title suggests, we will look at the principle of operation of one of the most common technical analysis indicators - moving average (movingaverage or MA), in the jargon of traders it is also called simply “moving average” or “mashka”.

A moving average is a way to smooth out price fluctuations over time. In other words, a moving average calculates the average price of a price over a certain period of time. The moving average is a trend indicator in its purest form. With its help, you can track the beginning of a new trend and the end of the current one; by the angle of inclination you can judge the strength of the trend.

Although the moving average is a primitive indicator, I consider it a basic indicator of technical analysis; it is the basis for many trading strategies and various indicators, so every trader must know the “device” and principle of operation of this indicator.

There are several methods for constructing a moving average:

  1. Simple.
  2. Linear-Weighted.
  3. Exponential.
  4. Smoothed.

All methods are based on the same principles; only the formulas by which they are calculated differ. Naturally, each method has its pros and cons. Let's look at each method in more detail.

SIMPLE moving average (SMA)

Most often, when talking about the moving average, this is the construction method that is meant. This is one of the simplest and most primitive indicators of technical analysis.

It is calculated using a very simple formula:

Where, Pi — price (most often calculated based on the closing prices of the candle, but can also be applied to the maximum minimum, opening price, average price, etc.).

N — period of the moving average. This is the main parameter when constructing, it is also called the smoothing length.

Let's look at an example.

Let's say we want to build a moving average with a period of 8 based on closing prices. To get the midpoint for the current formed bar, you need to take the closing prices of the previous 8 bars (in the figure below they are indicated by numbers 1−8), add their closing prices and divide by the total number of periods (8). As a result, we will get the average value for the currently formed bar:


Accordingly, if we need to construct a moving average with a period of 60, then we will calculate the average based on the closing prices of 60 previous bars.

As you can see, nothing complicated. Constructing a simple moving average is a common example of calculating the arithmetic mean from the school mathematics curriculum.

In the figure below you can see how a simple moving average with different periods “smoothes” the price:


The main disadvantage This method is that the calculation is based on data for a fixed period of time, and not all prices, and each price value in history is assigned equal importance. But would you agree that the price that took place 30 days ago is not as important as the price that was 5 days ago?

Also, speaking about the disadvantages of a simple average, it is worth mentioning the significant lag of this indicator, so when trading, the trader will not be able to take most of the trend movement.

To the advantages It can be attributed to the fact that SMA has low sensitivity compared to other types and will give fewer false signals, but you will have to “pay” for this with a later signal to enter the position.

LINEAR WEIGHTED MOVING AVERAGE (Linear-Weighted)

As I wrote above, the simple MA has a significant drawback in that when calculated, it gives the same “weight” to the price, no matter how close or far it is from the present moment. This drawback has been eliminated in this method of constructing a moving average.

The formula for calculating the weighted moving average is as follows:

Where, Pi — price value for i-periods ago; Wi — weight for the price i-periods ago.

The essence of this method is that when constructing a weighted moving average, a certain weight is assigned to the price, so that the near prices of nearby bars have a greater share than the prices of past bars.

Let's try to calculate a linear weighted moving average with a period of 5.

It will look like this:

That is, we took five closing prices of the last 5 bars. Our closest bar is the most significant and we assigned the maximum weight to it (in our case it will be 5) and with each closing price of the subsequent bar. The result obtained was divided by the sum of all specific gravity. As a result, we received a weighted point for a specific bar. Of course, we will not need to make these calculations, since the technical program. the analysis will do everything itself.

Below in the figure you can see a comparison of simple and weighted moving averages, both have a period of 60:


The disadvantages of a linear-weighted moving average include:

  • It gives fairly late signals to enter and exit a trend, but due to the weight it adds, it reacts much faster to price changes than a simple moving average.
  • When trading in a flat it gives many false signals.

EXPONENTIAL (Exponential) AND SMOOTHED (Smoothed) MOVING AVERAGES

The principle of calculating the exponential MA is that it takes into account all the prices that are on the chart and assigns them a certain weight (the importance of the latter is higher than the previous ones).

Calculation formula exponential moving average It’s quite complicated and I won’t focus on it. It is important for us as traders to know that the exponential moving average is very sensitive to price changes and provides more “interesting” entry points into a trade, but it can also fail during strong price fluctuations.

Look at the figure below, it shows a comparison of two MAs with the same period (60):


Smoothed moving average is perhaps the most difficult to calculate and has the lowest sensitivity. This type of moving average is very rarely used by traders and only on charts with a very large amplitude of price fluctuations.

Let's see how simple and smoothed moving averages with the same period behave:


Notice how much this MA smooths the price compared to the simple moving average!

Previously, I compared each method of constructing a moving average with a simple MA. Now let’s plot all 4 moving averages on the price chart at once:


Now we have come to the end of the article. Let's summarize.

Moving average is a trend indicator that shows itself perfectly when there is a trend in the market and is absolutely useless when the market is moving sideways. Although this is a trend-following indicator, due to the fact that it is calculated based on past data, it gives quite late entry points. To correct this drawback, other methods of calculating MA using “scales” were used.

In this article, we did not touch on exactly how to trade using moving averages, how to look for entry and exit points, or how to filter signals. We will discuss all these and many other questions in the next article.

That's all I have for today. Good luck in trading!

PS Be sure to read the continuation of this article by following this link. From it you will learn about the practical application of moving averages.

Moving average method a method of studying the main trend in the development of a phenomenon in dynamics.

The essence of the moving average method is that the average level is calculated from a certain number of the first in order levels of the series, then  the average level from the same number of levels, starting from the second, then  starting from the third, etc. Thus, when calculating middle level seem to “slide” along series of dynamics from its beginning to its end, each time discarding one level at the beginning and adding the next one.

The average of an odd number of levels refers to the middle of the interval. If the smoothing interval is even, then assigning the average to a specific time is impossible; it refers to the middle between dates. In order to correctly assign the average of an even number of levels, centering is used, i.e., finding the average of the average, which is already assigned to a specific date.

Let's demonstrate the use of the moving average using the following example. Example 3.1. Based on data on the yield of grain crops on the farm for 1989–2003. Let's smooth the series using the moving average method.

Dynamics of grain crop yields on the farm for 1989–2003. and calculation of moving averages

1 . Let's calculate three-year rolling amounts. We find the sum of the yield for 1989–1991: 19.5  23.4  25.0  67.9 and write this value in 1991. Then from this sum we subtract the value of the indicator for 1989 and add the indicator for 1992 .: 67.9 – 19.5  22.4  70.8 and we write this value in 1992, etc.

2 . Let's determine three-year moving averages using the simple arithmetic average formula:

We write the resulting value in 1990. Then we take the next three-year moving sum and find the three-year moving average: 70.8: 3  23.6, write the resulting value in 1991, etc.

Four-year rolling amounts are calculated in a similar manner. Their values ​​are presented in column 4 of the table in this example.

Four-year moving averages are determined using the simple arithmetic average formula:

This value will be assigned between two years - 1990 and 1991, i.e. in the middle of the smoothing interval. In order to find four-year centered moving averages, you need to find the average of two adjacent moving averages:

This average will be referenced to 1991. The remaining centered averages are calculated in a similar manner; their values ​​are recorded in column 6 of the table in this example.

4. Analytical alignment method

The equation of the straight line for analytical alignment of the dynamics series has the following form:

Where - leveled (average) level of dynamic series; a 0 , a 1 - parameters of the desired line;t- designation of time.

The least squares method gives a system of two normal equations for finding parameters a 0 and a 1:

Where at initial level series of dynamics ; n number of members of the series.

The system of equations is simplified if the values t choose so that their sum is equal to zero, i.e. move the beginning of time to the middle of the period under consideration.

If then

Study of the dynamics of social-economic. phenomena and the establishment of the main development trend provide the basis for forecasting (extrapolation)  determining the future size of the level of an economic phenomenon. The following extrapolation methods are used:

average absolute increase  s/indicator calculated to express the average rate of growth (decrease) of social-eco. process. Determined by the formula:

■ average growth rate;

extrapolation based on alignment according to any analytical formula. The method of analytical alignment is a method for studying the dynamics of social and economic. phenomena, allowing us to establish the main trends in their development.

Let's consider the use of the method of analytical straight line alignment to express the main trend onExampleE 4.1. Initial and calculated data for determining the parameters of the straight line equation:

Analytical alignment of time series levels does not give good forecasting results if the series levels have sharp periodic fluctuations. In these cases, to determine the development trend of the phenomenon, smoothing of the time series using the moving average method is used.

The essence of various smoothing techniques comes down to replacing actual levels of a time series with calculated levels, which are subject to fluctuations to a lesser extent. This contributes to a clearer manifestation of the development trend.

Smoothing methods can be divided into two classes, based on different approaches:

Analytical approach;

Algorithmic approach.

The analytical approach is based on the assumption that the researcher can specify the general form of a function that describes a regular, non-random component.

When using an algorithmic approach, the limitations inherent in the analytical approach are abandoned. Procedures of this class do not imply a description of the dynamics of a non-random component using a single function; they imply a description of the dynamics of a non-random component using a single function; they provide the researcher only with an algorithm for calculating the non-random component at any given point in time. Methods for smoothing time series using moving averages fall under this approach.

Sometimes moving averages are used as a preliminary step before modeling a trend using procedures related to the analytical approach.

Moving averages make it possible to smooth out both random and periodic fluctuations, to identify an existing trend in the development of a process, and therefore serve as an important tool for filtering components of a time series.

The smoothing algorithm using a simple moving average can be represented as the following algorithm.

1. Determine the length of the smoothing interval g, which includes g successive levels of the series (g

2. The entire observation period is divided into sections, with the smoothing interval sliding along the series with a step equal to 1.

3. Arithmetic averages are calculated from the levels of the series that form each section.

4. Replace the actual values ​​of the series located in the center of each section with the corresponding average value

In this case, it is convenient to take the length of the smoothing interval g in the form of an odd number g=2p+1, because in this case, the obtained moving average values ​​fall on the middle term of the interval.

The observations that are taken to calculate the average are called the active smoothing region.

For an odd value of g, all levels of the active site can be represented as:

and the moving average is determined by the formula

,

where is the actual value of the th level;

− the value of the moving average at the moment ;

− length of the smoothing interval.

The smoothing procedure leads to the complete elimination of periodic oscillations in a time series if the length of the smoothing interval is taken equal to or a multiple of the oscillation period.

To eliminate seasonal fluctuations, it is advisable to use a four- and twelve-term moving average.

If there is an even number of levels, it is customary to take the first and last observation in the active section with half the weights:

Then, to smooth out fluctuations when working with time series of quarterly or monthly dynamics, you can use the following moving averages:

,

.

Let's consider the use of a moving average based on the total area of ​​residential premises per inhabitant on average in the Khabarovsk Territory (Table 2.1.1).

Since the smoothing period cannot be justified, calculations begin with a 3-term moving average. We obtain the first smoothed level for 1993:

.

Consistently shifting the beginning of the sliding period by one year, we find smoothed levels for subsequent years.

For 1994 the moving average will be

,

for 1995 , etc.

Since the moving average refers to the middle of the interval for which it is calculated, the dynamic series of smoothed levels is reduced by a level with an odd sliding period and by levels with an even sliding period. Therefore, in our example, the smoothed series became shorter by two terms for a three-term average and by four terms for a five-term average (Table 2.1.1).

When calculating using even moving averages (in our example, a 4-term moving average), the calculations are performed as follows:

For 1994 ;

1995 ;

1996 .

Table 2.1.1 – Smoothing results using the moving average method

Years The total area of ​​residential premises, on average per 1 inhabitant.sq.m, Smoothed levels
Simple moving average
3-membered, 4-membered, 5-membered, 3-member 4-member 5-member
15,4 - - - - - -
16,1 16,0 - - 0,01 - -
16,5 16,4 16,3 16,3 0,01 0,026 0,040
16,6 16,7 16,6 16,6 0,004 0,001 0,000
16,9 16,8 16,8 16,8 0,004 0,006 0,006
17,0 17,0 17,1 17,1 0,003 0,010
17,1 17,3 17,4 17,4 0,05 0,083 0,102
17,9 17,7 17,7 17,7 0,03 0,026 0,026
18,2 18,2 18,2 18,2 0,00 0,000 0,000
18,5 18,7 18,7 18,7 0,03 0,031 0,032
19,3 19,1 19.1 19,0 0,04 0,056 0,068
19,5 19,5 19,4 19,4 0,006 0,014
19,7 19,7 - - - -
19,9 - - - - - -
Total 248,6 - - - 0,179 0,239 0,299

As can be seen from Table 2.1.1, the three-term moving average demonstrates an aligned dynamic series with a unidirectional tendency for the levels to move. Smoothing using a three-term moving average gave a smoother series, since for a three-term moving average the sum of squared deviations of the actual data () from the smoothed ones () ( = 0.179) was smaller (Table 2.1.1). In other words, a three-term moving average best represents the pattern of movement of the levels of a dynamic series.