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.
We need to determine the initial S and the coefficient .
In the case exponential smoothing, I'll remind you, the following approach is used:
and 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:
, that is, the simple average for n periods
calculated in the following voluntarist manner
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.
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.