# MACD & Trading Systems | How To Build This Indicator and the EMA | Part 1

by Andrea Unger### Need More Help? Book Your FREE Strategy Session With Our Team Today!

We'll help you map out a plan to fix the problems in your trading and get you to the next level. Answer a few questions on our application and then choose a time that works for you.

BOOK YOUR FREE STRATEGY SESSION NOW >>The Moving Average Convergence Divergence (or more simply MACD) is a momentum indicator that lets you get entry signals using exponential moving averages.

In this video, one of our coaches explains step-by-step how to build and interpret the MACD, focusing on the concept of exponential moving average and explaining how to use this indicator to understand when to buy or sell.

Enjoy!

Hi everyone, today we talk about the Moving Average Convergence Divergence.

Welcome back, I'm one of the coaches of the Unger Academy and today I'll be showing you the characteristics of the Moving Average Convergence Divergence indicator, or more simply, the MACD. Like all indicators, the MACD is nothing more than a re-elaboration of the prices we find in the chart, because all the inputs necessary for the calculations are already contained in the price of the underlying asset we are considering. In order to fully understand the meaning and use of the MACD and - most importantly - if using it in our systems can give us an advantage or an edge on the markets, we will start, as always, from the origins of this indicator and then go through the various steps to calculating it.

But before we start, if you haven't done it yet, I invite you to subscribe to our channel and click on the bell to stay updated on the release of new content.

### Simple Moving Average

Let's begin immediately with what can be considered one of the simplest concepts in technical analysis, that is, the Simple Moving Average, or SMA.

As you know, the Simple Moving Average is nothing more than the sum of the prices (usually the Closes) divided by the number of the prices considered. So here we can see a Simple Moving Average at 10 periods considering 10 Closes (3, 6, 9, and 10 the last one), which corresponds to the sum of the Closes divided by the number of the Closes considered, which is 10. Of course, at the next bar, so at the next Close, the calculation will be repeated again. The last bar will no longer be considered while the next bar will be taken into account to find the new value of the Simple Moving Average.

I remind you that every Close, and so every bar, has the same weight. What does this mean? it means that, when calculating the simple moving average, the first Close, the last Close and all the other closes that stand in between them, have the same importance. In the lower part of the screen you can see the mathematical formula to calculate this average, which is actually very simple. As a convention, in this video we'll put the oldest Closes equal to 1 and the most recent Closes equal to “n”. So we'll talk about x1, x2, x3, x4... going up to 10 in this case, in order to consider the Closes from the farthest to the nearest, and we’ll use 'n' to indicate the last Close that was just created.

One last thing. I'd like to point out that, in this case, I'm building the Simple Moving Average with 10 prices, so 10 Closes, and the weight of each Close is equal to 1 divided by 10, so each Close weighs 10%, which means it is multiplied by 0.1. Here, above, you can see the weights of the closes.

### Exponential Moving Average

However, the MACD indicator is not built using the Simple Moving Average but using the Exponential Moving Average. So what is the Exponential Moving Average? And above all, what's the difference between the Simple and the Exponential Moving Averages? Let's take a look at it together.

We just said that in the Simple Moving Average all the Closes have the same weight. In the Simple Moving Average "W of n" (where W stands for 'weight') is equal to the weight of the previous bar, the weight of the bar “n-1”, and so on.

On the other hand, in the Exponential Moving Average the weights are not equal, as the more recent bars are more important than the older ones. How do we do this? By keeping the ratio between the weights constant. But let's check out an example: the weight of the bar 'n-1' divided by the weight of the bar 'W of n' is equal to the weight of bar 1 divided by the weight of bar 2. The farther we get from the last bar and the more the weight decreases means that the ratio will be less than 1, so the ratios of the more distant bars will be equal to a number between 0 and 1, and they will be identified by the Smoothing Factor, that is, this alpha value that we will later see in further detail.

For the moment, let's focus on the weights of the bars. In the simple moving average, all the bars weigh the same. In the exponential moving average, instead, their weights are different. The bar that was just closed is the one that weighs more. Then, the weight gradually decreases as we go backwards through the bars. If you think about it, this moving average has countless values, so all the bars are considered. Every bar contributes to the value of the exponential moving average because the value of the weights never reaches zero. So, there will always be a value other than zero attributed to a bar.

This makes it clear that, regardless of the number we associate with this kind of average - because we often hear people talk about exponential moving averages at 15 periods, 10 periods, or 20 periods - all the prices of the bars are considered. So what does it mean to calculate an exponential moving average using 20 periods? Here below you can see the mathematical formula to calculate the exponential moving average.

What I want you to know, at least for now, is that regardless of the number of periods on which an exponential moving average is calculated, we need to consider the whole historical series. In the simple moving average, the moving window is as large as the number of periods we consider. When calculating the exponential moving average, instead, if we assume that the historical series starts here, we use this window, independent from the number of the periods. When calculating the next exponential moving average, we consider this other window, and so on. So, as you can see, the window is getting bigger and bigger.

However, what's going to change is obviously the weight. So, if this bar had greater weight before, so at this point here we had this Close that weighed more than all the others, in this other case, the weight of this Close is the same as this, and the weight of this Close that has now become second will have decreased. So, the moving window becomes greater and greater and the weights change.

### SMA vs EMA

So let's see why we still associate a number with the exponential moving average. Let's assume that we identify alpha as 2 divided by '1+n', where 'n' corresponds to the calculation of a simple moving average. So in this case, we have a Simple Moving Average at 20 periods. This means that all the 20 prices considered weigh 0.05. Here instead we have the weights of an Exponential Moving Average at 20 periods, so with the alpha equal to 2 divided by 20+1. What happens? If we overlap the weight charts, we will find that the center of gravity of the weights is the same. What do I mean when I say that "the center of gravity is the same"? If we traced the center of gravity of the Simple Moving Average weights along the x-axis, we would end up exactly halfway, and if we considered the center of gravity of this exponential figure, we would end up exactly in the same point.

So in the Exponential Moving Average at 20 periods, we still consider all the bars of the time series. All the bars contribute but the center of gravity of the weights, which coincides with the center of gravity of a Simple Moving Average at 20 periods. That's why we call it an Exponential Moving Average at 20 periods. So not because we consider only 20 prices, so Closes, Highs, etc., but because the weights are somehow distributed around the same center of gravity.

Please note that here I put 42 bars on the chart for the Exponential Moving Average. You obviously know that the concept of Exponential Moving Average entails considering the whole historical series. Here I charted only 42 bars because it seemed like an acceptable number to show the bars. However, keep in mind that if our chart, so the consideration of values, goes beyond this number, we obviously need to consider them. And the center of gravity of this geometric figure coincides with that of the Simple Moving Average if, of course, this figure tends to infinity. If we stop, like in this case, at 42 bars, the change will be small. The weight will not be mathematically coincident but the variation will be an infinitesimal one that is not relevant in our context.

Let's finally look at another example. Here’s a comparison between the Exponential Moving Average and the Simple Moving Average at 20 periods. What would happen if this 'n' were equal to 5, for example? When we used 20 periods, the alpha was equal to 0.095. In this case, in which we assumed a number equal to 5, we would see that alpha is equal to 0.333, so the weight ratio would be 0.33. This means that this weight in blue is exactly two-thirds of the weight that precedes it. And the same goes for this other weight in blue. This weight is nothing more than 2/3 of this weight, and so on. As you can see, for this exponential figure as well, we get a center of gravity that coincides with that of a simple moving average at 5 periods.

But let's stop with these theoretical and mathematical explanations, which are certainly very useful for understanding the concepts but definitely impractical, and move on to a more conceptual analysis of this kind of moving average.

As you can see from the weight chart, the contribution of the most recent bars is much greater than the contribution of the past bars. This means that this kind of moving average is somehow more responsive to recent changes and, so, to what is going on today compared to what has happened over the past few days.

But let's make a graphic example. We considered 20 periods, now let’s consider the values of both the simple and the exponential moving averages at 20 periods on this graph. The dark blue line represents the exponential moving average, which compared to the simple moving average reacts more quickly to this sudden upward market change.

This difference depends on the difference in the weights considered, because this bar here, and also this bar, and then all the other bars, have greater weights in the exponential moving average compared to the simple moving average, in which this bar (or this one for example) will have the same weight, the same importance, as the bars on this spike.

### The MACD

Now we know everything we need to know to explain the MACD indicator. The MACD is nothing more than the plot of the difference between a 26-period exponential moving average and a 12-period exponential moving average. That's it. Nothing more or less than that. Then there is another number we can calculate. It is used as a trigger or signal line and is nothing more than an exponential moving average at 9 periods of this amount, which is the MACD.

As you can see, with these moving averages we are mixing the values of the chart many times. So, if on one hand, this indicator can help us better understand what's happening in the market, on the other hand, I suggest that you always keep in mind that indicators are a derivation or re-elaboration of the chart prices.

Now let's go plotting these values. This is the typical graph we can get using the pre-built functions of any software, for example MultiCharts or TradeStation. We see the MACD in light green, its 9-period exponential moving average in dark green, and the difference between the MACD and the 9-period exponential moving average plotted in red bars.

According to literature, this signal tells us to enter Long if the MACD crosses above the trigger and to enter Short if the MACD crosses below the trigger. As you can see, in this case, there is a cross between the signal line and the MACD that points to a short entry. After that, it is followed - exactly here - by a long entry.

This indicator can also be interpreted in other ways. In addition to crosses, in fact, there can be differences between the price and the indicator, as well as interpretations on the speed of the crossing, which may be useful to understand if we are in an overbought or oversold situation, and so on.

Finally, since the MACD indicates a difference between two moving averages, could also be used by itself as an entry and exit signal depending on whether it is above or below zero, so as a classic cross signal of different moving averages.

### Conclusion

Okay guys, that’s all on MACD for now. We'll continue talking about this indicator in a second video in which we will analyze more practical aspects related to it, and we’ll test some trading systems to see how to fully exploit the potential of this indicator.

If you like this video, please let us know by clicking the "like" button and leaving your comments. And if you haven't done it yet, I invite you to subscribe to our channel to stay updated on the release of our next videos.

Finally, I'd like to tell you that below, in the description of the video, you can find a link to a completely free webinar explaining how to build a well-diversified portfolio of automated strategies with the method of the 4-time world trading champion Andrea Unger.

See you in the second part of this video! Thank you for watching and goodbye!

### Need More Help? Book Your FREE Strategy Session With Our Team Today!

We’ll help you map out a plan to fix the problems in your trading and get you to the next level. Answer a few questions on our application and then choose a time that works for you.

BOOK YOUR FREE STRATEGY SESSION NOW >>### Andrea Unger

Andrea Unger here and I help retail traders to improve their trading, scientifically. I went from being a cog in the machine in a multinational company to the only 4-Time World Trading Champion in a little more than 10 years.

I've been a professional trader since 2001 and in 2008 I became World Champion using just 4 automated trading systems.

In 2015 I founded Unger Academy, where I teach my method of developing effecting trading strategies: a scientific, replicable and universal method, based on numbers and statistics, not hunches, which led me and my students to become Champions again and again.

Now I'm here to help you learn how to develop your own strategies, autonomously. This channel will help you improve your trading, know the markets better, and apply the scientific method to financial markets.

Becoming a trader is harder than you think, but if you have passion, will, and sufficient capital, you'll learn how to code and develop effective strategies, manage risk, and diversify a portfolio of trading systems to greatly improve your chances of becoming successful.