Exponential Moving Average

Exponential Moving Average calculation by candles

Well, after a long break, let's continue to deal with technical indicators.

I recommend starting the reading from the first article of the series for those who still do not know the technical indicators, candles, and currency pairs Simple Moving Average. And we will cut to the chase.

By the way, the break was partly because I felt a pressing need to deal with the exponential smoothing, which resulted in the creation of three articles - Exponential smoothing, Double exponential smoothing and Triple exponential smoothing.

Now I feel quite savvy in theory, to tell, and, as usual, to calculate Exponential Moving Average.

Last time I wrote about Weighted moving average. It was devised, so the latest data has a great influence on the result of averaging. That is, so the indicator has been more sensitive to the unexpected reversals in the trend.

The exponential moving average also uses this principle. The exponential smoothing method itself was invented a long time ago (see articles above), and in the form of a simple exponential smoothing, it has turned into a technical indicator. The calculation, as usual, is carried out for the last n periods, hence the name moving.

The basic formula is taken from the exponential smoothing.

S_t = \alpha y_{t-1} + (1-\alpha)S_{t-1}

We need to determine the initial S and the coefficient \alpha.

In the case exponential smoothing, I'll remind you, the following approach is used:
S_1 - undefined
S_2 = y_1
and \alpha is selected so as to minimize the mean square error.

In the case of the exponential moving average, everything is very different. In those sources/articles/source code that I have seen, the following approach is used:
S_1 - undefined
...
S_{n-1} - undefined
S_n=\frac{\sum_{i=1}^{n}y_i}{n}, that is, the simple average for n periods

\alpha calculated in the following voluntarist manner
\alpha=\frac{2}{n+1}

It's clear that such alpha has nothing to do with such minimum mean square error, but it is fulfilling its goal - the influence of older data decreases faster than in the case of just weighted moving average.

To see this, compare the following charts.

PLANETCALC, Weights comparison with the weighted moving average and the exponential moving average

Weights comparison with the weighted moving average and the exponential moving average

Digits after the decimal point: 4
Current value
 
Value weight change with exponential smoothing
The file is very large. Browser slowdown may occur during loading and creation.

Here is the calculator itself. As usual, the default data used are USDJPY candles with a 15-minute compression. The exponential moving average is calculated, and for comparison, you can display simple and weighted moving averages on the graph.

PLANETCALC, Exponential Moving Average

Exponential Moving Average

Digits after the decimal point: 2
Moving average
The file is very large. Browser slowdown may occur during loading and creation.

Candles for USDJPY

Items per page:

URL copied to clipboard
PLANETCALC, Exponential Moving Average

Comments