What is a moving average and what is it used for? A moving average is an indicator that used on your trading charts to help gauge the direction of the price movements. Moving averages are one of the most commonly used indicators in technical analysis, systematic trading and algo trading. This is because they perform several useful functions which we will discuss in depth in this post and they are a robust trading indicator that has withstood the test of time. In this article we will discuss what moving averages are, we will explore 5 different types of moving average, the formulas and weightings each average uses, we will discuss how to calculate
What Is a Moving Average?
How do we calculate it? We’ll start with a simple moving average, and then we’ll get into the other moving averages as we go.
On the chart, I’ve got a chart of the S&P 500 index, and overlaid a 10 day moving average on the index. What is a 10 day simple moving average and how does it work? If you look on the picture below, I’ve got this red box to highlight some of the bars, and you’ll see that the moving average is a line that runs sort of alongside the price of the instrument that you are charting.
In order to calculate the moving average on each day, the simple moving average, you need to do an arithmetic average of the last X number of bars of that price series that you are plotting. We’ve got the S&P 500, this is a 10-day moving average. I’ve drawn a red box around the last 10 bars. Thus, we’ve got 1 up to 10.
To get the most recent 10-day moving average, you take the closing price on each of the last 10 days, you add them up and then divide it by 10; then you plot the result. To get the previous bar’s moving average, which was one day ago, same sort of thing. You take the last 10 bars, which is 1 up 10. It includes the previous bar that wasn’t in today’s calculation, so you add up the closing prices and you divide it by 10.
You don’t always have to do the moving average of just the closing price. You could have a moving average of the open, high, low, close, or the moving average of some calculation of the average. There’s different ways you can calculate the moving average. On the chart below, we’ve got a simple moving average, and it’s 10 bars. A 10-bar moving average is quite a short term moving average. We could also overlay a longer term moving average. Let’s put a 200-day moving average, it is interesting because the 200-day moving average is one of the most useful tools in technical analysis.
The 200-day moving average is calculated the same as the 10-day moving average. But instead of averaging the last 10 days of data, it’s averaging the last 200 days of data. It’s a much slower-moving average and you can see that it’s a nice gradual trend. The 200-day moving average is moving down and the price is below the 200-day moving average. That has some very special significance for traders and investors because below the 200-day moving average, bad things tend to happen and the markets are much more volatile.
Above the 200-day moving average, the market is generally much less volatile and trends much more smoothly. Hence, bull markets happen above the 200-day moving average and bear markets and crashes tend to happen below the 200-day moving average. The 200-day moving average is one of the most powerful signals in technical analysis.
How to Calculate Moving Averages
There’s several types of moving averages as shown below on the chart for comparison. There’s a simple moving average, exponential moving average, weighted moving average, and a TEMA moving average. Each of these have different pros and cons, in which I will be explaining later on. However, I just want to illustrate some of the differences and the way it appears in the chart.
Exponential Moving Average
The 200-day exponential moving average is colored in blue on the chart. Let’s compare the 200-day exponential moving average to the 200-day simple moving average, which is in black on this chart. You can see that the 200-day exponential moving average is a little more responsive. It’s a bit closer to the price. The same thing happens if you take a short term moving average.
Let’s take a 10-bar exponential moving average and compare it to the 10-bar simple moving average. You can see that the 10-bar exponential moving average hugs the price a little more closely than the simple moving average. The exponential moving average for the same number of bars, hugs the price more closely and is more responsive than the simple moving average. That doesn’t make it better; it just calculates the exponential moving average differently.
Weighted Moving Average
If you put a 200-bar weighted moving average onto the chart, you can see the weighted moving average behaves differently to both the simple and the exponential moving average. I’ve put the simple moving average in black, the exponential moving average in blue and the weighted moving average in green. It has some quite different characteristics depending on what you want to do.
TEMA – Triple Exponential Moving Average
These are some of the different moving averages. We’ve got simple, exponential, weighted. You also saw that there’s a T-E-M-A, that’s a triple exponential moving average. This is even more complex. I’m doing all of this plotting on Amibroker. You might use other charting software, but I use Amibroker for charts and for backtesting. The TEMA is an attempt to speed up and make the moving average more responsive. One of the challenges with moving averages is that they tend to be quite slow and laggy. The TEMA is a calculated, it’s a moving average of a moving average. It’s a complex calculation, which I’ll explain shortly that takes a combination of the original exponential moving average, the EMA of that moving average and combines them to try and reduce or remove some of the lag. You can see this purple line on the chart is here.
Now we’ve got the simple moving average in black, the exponential moving average in blue, the weighted moving average in green, and the TEMA, the triple exponential moving average in purple. If you look at the picture below, you can see that the TEMA is quite responsive to price. It moves quite quickly in line with the price, certainly compared to the simple moving average and the exponential moving average and even the weighted one here in this case.
I want to be clear and emphasize that just because it’s more responsive doesn’t mean it’s better. It’s just different. You need to backtest your system ideas using each of these different moving averages and see which gives you the best signals. There are different types of moving averages.
5 Types of Moving Averages
What are the types of moving averages, and how do they work?
This section will discuss the types of moving averages which is the simple moving average, exponential moving average, weighted moving average, Hull Moving Average, and the TEMA Moving Average.
Simple Moving Average
The weighting of a simple moving average takes the price of the last N number of bars and performs a simple average of those bars, which means the weighting of each of the last N number of bars is the same. For example, if it’s a ten-day moving average, then today and each price for the last ten days all receive the exact equal weighting in the moving average calculation. That’s why, as you can see in the simple diagram below shows it’s an even weighting over each of the different bars.
Exponential Moving Average
An exponential moving average on the other hand, seeks to place more weighting and more emphasis on the recent price data. The calculation of the exponential moving average is much more complicated. You don’t have to do it by hand because your trading software will do it for you. It places a much higher weight on the current data point and decreasing the weight on each previous data point. How does that work in practice? On the diagram below, the exponential moving average is a much higher weighting up on the most recent price. Then each historical price gets less and less weighting back. However, if you’re doing a ten-day moving average, the ten days prior gets a much smaller weighting than the current price.
The exponential moving average is much more responsive to price movements than the simple moving average. The simple moving average moves slowly because it averages each of the last ten days. In contrast, the exponential moving average emphasizes the more recent bars, so it’s more sensitive and moves more quickly.
Weighted Moving Average
The weighted moving average is somewhat similar to the exponential moving average, except instead of placing exponentially more emphasis on the recent bars, it puts the weighting on each of the historical bars in a linear profile. On the picture below, you can see the weighting of each of the bars in the weighted moving average. It decreases in a linear fashion back to the nth most recent bars.
The current bar gets a particular weighting, and then the previous bar gets a little less, but it’s less responsive. Less emphasis is placed on the more recent bar than on the exponential moving average here. The weighted moving average places much more emphasis on the recent bar than the simple moving average but less on the recent bar than the exponential moving average.
Hull Moving Average
The Hull Moving Average is a much more complicated calculation than the TEMA. In the following blog, you can read where I discuss the formulas for each of the different moving averages. On the chart below, you can see what it looks like for each of the different moving averages. I’ve got the chart of the S&P 500 index, and I’ve overlaid a 200-day moving average.
TEMA Moving Average
I’ve got a simple moving average in black, and I’ve got an exponential moving average in blue, got a weighted moving average in green and a TEMA moving average in purple.
I’ve dropped the Hull Moving Average onto the chart in red. You can see the Hull Moving Average below. The Hull Moving Average behaves quite similarly to TEMA. It’s a different calculation, so they move differently. If you’re looking for more responsive moving averages, then TEMA and Hull are good moving averages. If you’re looking for less responsive, exponential and weighted will do the job.
Formula for Moving Average
In this section, I will explain the formulas for the different moving averages, so you know exactly how they’re calculated. That way, you can be confident when you’re using them in your trading that you know how they’re calculated, what they’re derived from, and how they will behave in your trading system or trading strategy.
Formula for Simple Moving Average
First of all, let’s cover the formula for the simple moving average. The formula for the simple moving average is just an arithmetic average of the last N number of bars. If you’re doing a 10-day moving average of the closing price, you take the closing price on each of the last 10 bars and add them all up. Then, you divide them and divide that number by 10, giving you the simple moving average. This formula, the moving average, is the sum from bar one to bar N of the price over the last. Divided by N, so divided by 10 bars.
You can calculate the moving average of the closing price, opening price, high, low, or some average of the open, high, low close, the volume or anything you like. You can apply this simple moving average to pretty much anything on your chart, except the most common use is to calculate the moving average and the simple moving average, of the closing price. That’s the most common way to calculate the moving average in trading.
Formula for Exponential Moving Average
Example Exponential Moving Average
The exponential moving average is equal to the current price, and we multiply that by two divided by the number of bars in our moving average plus one. If it was a 10-bar moving average, it’s the current price multiplied by two divided by ten plus one for the 10-bar moving average. Then, we add that the previous bars were moving averages, and we multiply that by one minus the same ratio, two divided by the number of bars plus one.
What does this look like in practice? Let’s do a worked example. To calculate an exponential moving average of 200 days, we’re going to look at the current price, and we’re going to multiply it by two divided by 200 plus one. Then we’re going to add the previous bars moving average, but we’re going to multiply that by one minus two divided by 200 plus one.
Now what this does is it gives the most weighting to this current price bar and less weighting to the previous price bar. Then, when you work out this ratio, what you get is the exponential moving average equals the current price times, in this case, .00995 plus the previous bars exponential moving average times .99005, and these two add up to one. That gives you the full exponential moving average. That’s how you calculate the exponential moving average.
Again, you can do this by hand. Any good charting software will have exponential moving averages, be able to drag and drop them straight onto your chart. I use Amibroker. As we saw from the charts we looked at earlier, like this one of the S&P 500, you can drag whatever moving averages or indicators you want onto the chart and have them calculated, and you can adjust the number of bars in the calculation.
It is important to understand how they’re derived so that you know how they will behave and whether they will perform appropriately for your trading system. Therefore, that’s the exponential moving average. Next, let’s have a look at the weighted moving average.
Formula for Weighted Moving Average
Example Weighted Moving Average
The weighted moving average is somewhat similar to the exponential moving average in that it places more emphasis on the most recent bars and less on the previous bars. The formula is the weighted moving average equals the price of the most recent bar times N. Then we’ll add the price of the previous bar times N minus one. The previous bar gets slightly less weight than the current bar.
We’re going to add to that the price of the third historical bar and multiply that by N minus two. We’ll keep adding those up, multiplying it by a lower and lower number until we get back to the previous Nth bar. Then we’re going to divide all of that by N times, plus one in brackets, divided by two.
Don’t worry too much about this if you’re not a math whiz. What this means is that the current bar gets the most weighting. The previous bar gets a little less, and then a little less until you get back to the last bar in the calculation. It’s a linear reduction in weight as you go back in time.
What does that look like as a practical example? Let’s do a straightforward one, a three-bar moving average. For a three-bar weighted moving average, it would be the current bar times three, the previous bar times three minus one, and the bar before that times three minus two. We’re going to divide all of that by three times three plus one, all divided by two. That simplifies to here; the weighted moving average would equal the current price times three, the previous bar’s price times two, and the bar before that’s price times one, all divided by six.
We’re dividing by six because we’ve got the total weighting of six in this formula, three here, two here, and one here as shown below. We want to get it back to a weighting of one to get the true average. The weighted moving average is calculated just like this, with the weighting on each bar decreasing in a linear fashion back to the first bar in the calculation.
The weighted moving average is excellent because it’s pretty responsive, but it could be more heavily focused on the most recent bar. It gives some weight to all of the bars in the calculation. In contrast, the exponential moving average gives less and less waiting in a very exponential fashion back to the first bar in a calculation. Thus, it can be, too responsive to price.
Formula for Triple Exponential Moving Average (TEMA)
The TEMA or the triple exponential moving average is combined of three different moving averages. First, we want to define these other moving averages here. EMA1, we’re going to explain as the EMA of the price, the exponential moving average of the price. That’s the standard exponential moving average formula. EMA2 is the EMA of the first EMA. EMA2 is the EMA of this number here, of this value, then EMA3 is the EMA of that value there.
Once you’ve calculated EMA1, EMA2, and EMA3, it’s the EMA of the price, the EMA of that EMA, and then the EMA of that EMA. Then, you combine them using this formula here. The triple exponential moving average is three times the first moving average minus three times the second moving average plus the third moving average. This formula is an attempt to remove some of the lag in the exponential moving average.
I don’t use TEMA personally in my trading, but it’s an interesting indicator that warrants investigation. When you’re developing system ideas when you’re backtesting, you can try all the different moving averages, as we’ll discuss later in this moving average video series. That’s the formula for the TEMA, triple exponential moving average.
Formula for Hull Moving Average
The hull moving average is even more complicated. It’s another attempt to remove the lag from the standard moving average formulas we’ve already seen.
The hull moving average is a weighted moving average. It’s WMA weighted moving average. But we’re calculating the weighted moving average of a couple of different things. You’ll see here we’re calculating the weighted moving average of everything in these brackets. The first thing is we’re doing two times the weighted moving average of price. It’s the standard weighted moving average that we’ve already shown you the formula above, but we’re doing it over the last two bars.
If it’s a 10-day moving average, we’re doing two times the five-day moving average and five-day weighted moving average. Then we’re subtracting from that the weighted moving average of the price over N bars. Therefore, it’s twice the short-term moving average minus the long-term moving average. Then, we’re calculating a weighted moving average of all of that over the last square root of N bars.
It’s complicated and I don’t think you need to know this formula because it’s in your charting package, or it can be very quickly coded into your charting package. However, what it’s trying to do, is eliminate some of the lag, and this was one person’s attempt to do that.
Again, the hull moving average is quite a good tool for trading systems. It gives you very responsive signals, much more responsive than a simple moving average. It’s great for things like an entry trigger. Not so great for a long-term trend filter because it’s too responsive. Yet it can also be good for an exit because when the price crosses below the hull moving average that typically happens much earlier than the price crossing below the simple moving average. You can use it to capture more of your profits.
They’re the formulas for the different types of moving averages. We’ve covered the formula for the simple moving average, the formula for the exponential moving average, the formula for the weighted moving average, the formula for the TEMA or triple exponential moving average, and the hull moving average.
Now you know how to calculate them. Just remember, you don’t need to understand those formulas in detail. I want you to have a broad understanding of where they’re coming from and how they behave so that you’re not doing it blindly when you’re applying them in your trading systems and strategies. You should only ever use an indicator that you broadly understand how it works and how it’s calculated.
Calculating Moving Average in Excel
Types Of Moving Averages In Excel
In this section, I’m going to explain how to calculate all the different types of moving averages in Excel. I don’t know why you would want to do this because your charting software should have all the moving averages in there. If you are trading in using Excel for your analysis package, you need to upgrade because trading packages like Amibroker allow you to do all of your charting. It has all of the calculations for the indicators built in. It also allows you to backtest and optimize your trading systems. If you are using Excel, you’re really selling yourself short. Move across to a proper trading package so that you can do the charting, and do the backtesting way more easily.
Having said that, let’s have a look at how you calculate the different moving averages in Excel just so you know how the calculations work. What I’ve done is I’ve extracted a few bars of data from the S&P500 index and I’ve pasted them here. You can see, I’ve got the SPX ticker and the dates. I started in 1990 and I’ve got the closing price and the volume. I’m not using the volume so we’ll just ignore that for now.
Calculating Simple Moving Average in Excel
How do you calculate the simple moving average in Excel? If we have a look at this formula here, the simple moving average is just the average of the last 10 bars. We can use the average function 1, 2, 3, 4, 5, 6, 7, 8, 9, and 10. We’re going to increase that up to there, so this is the average of those 10 numbers, and that’s the 10 bar average. If I want to calculate the moving average for each of the following bars, all you need to do is drag this formula down and you can see, this one uses those 10, and you can see how the formula increments down on each new day.
It drops off the oldest day and it picks up the newest day. This is how the simple moving average formula works. You can see it’s moving those 10 bars down for each new bar of data. The moving average does use the current day. Today’s moving average uses today’s closing price so you can only calculate today’s moving average after the market closes, in which that’s the simple moving average.
Calculating Exponential Moving Average in Excel
Exponential moving average is more complicated. The formula is the current price times two divided by N plus one, where N is the number of bars in the moving average. Hence, closing price times two divided by N+1 plus the previous day’s value of the exponential moving average times 1 minus 2 over N+1. We encountered this formula in a previous section so you can see, it’s the current price times two divided by N+1 plus the previous value of the exponential moving average times 1 minus 2 divided by N+1. There’s the formula and then if we drag this down, it’ll just continue to calculate. You can see that each day, it refers to the new closing price and then the new previous value of the exponential moving average.
Calculating the Weighted Moving Average in Excel
The weighted moving average is a pretty complicated formula in Excel. You can see there’s a lot of terms but what we are doing is we’re taking today’s price times 10 for a 10-bar moving average plus yesterday’s price times 9, plus the day before times 8, plus the day before that times 7, and then the previous one times 6, previous one times 5, times 4, times 3, times 2, times 1.
Then, we’re dividing all of that by N times N+1 divided by 2, as you saw in the previous section where I explained the formulas for each of the different types of moving average. That’s how you calculate it in Excel. It’s a bit laborious to put this together, and I would just do it in my charting package instead of Excel. But once you’ve got the formula, you can copy this down and it will just refer to each of the previous 10 bars just like we saw on the simple moving average.
Calculating the Triple Exponential Moving Average (TEMA) in Excel
We’re going to start with the exponential moving average and we’re going to build on that in layers. First thing we’re going to do is remember that the formula for TEMA requires three exponential moving averages, the standard exponential moving average, the EMA of the standard EMA, and the EMA of the EMA of the standard EMA.
We’re going to use this value and column here, which is the standard moving average. Then, we’re going to calculate the exponential moving average. We’re going to say today’s value of the exponential moving average times 2 divided by N+1, N is 10 in this case. Then, we’re going to add to that the previous day’s value of the Second EMA and multiply that by 1 minus 2 divided by N+1, just like the formula we explained in the previous section. Therefore, that’s the second EMA that you need to calculate TEMA.
The Third EMA is the same thing and I’m going to make the same correction here. The same formula but applied to the Second EMA. The Third EMA takes the value of the Second EMA times it by the same ratio, adds the previous day’s value of that times it by this same ratio you saw in the previous calculation.
Then, TEMA is a combination of this and this. It’s the triple exponential moving average, it considers all three. The formula is three times the Standard EMA minus three times the Second EMA plus the third EMA and there’s the value for TEMA. Then, we can just drag it down and Excel will continue to calculate it.
You can calculate all the different moving averages in Excel. However, I’d encourage you, if you’re using Excel for your technical analysis, it’s time to move over to a proper charting and backtesting platform. Although Excel can do it, it’s not designed for this sort of calculation. Whereas trading software like Amibroker, is designed to calculate long time series of indicators to combine them into trading systems and to use it so have a think about that if you’re still using Excel in your analysis.
How To Use Moving Averages In Your Trading
Have you ever wondered how to use moving averages in your trading to improve your trading results? They look great on the chart, but how do you use them in your day-to-day trading to make money, grow your wealth, and build your income from the markets?
In this section, I will show you four different methods of using moving averages in your trading practically tangibly to get better results.
Using Moving Averages as a Market Regime Filter / Index Filter
One of the best and simplest ways to use moving averages in your trading is as a market regime filter or an index filter. On this chart, you can see the S&P 500 Index, and on it, I’ve got a 200-day moving average plotted.
You can see here we’ve got the price, the bull market from 2020 through to 2021, and the 200-day simple moving average plotted on the chart. You use the moving average as a market regime filter when the index is above the long-term moving average; you’re going to go long. You’re going to trade on alongside its bullish indication. On the other hand, when the market is below the 200-day moving average, it’s a bearish indication, and you do better on the short side.
There are better signals than this, and you’ve got to put this filter into your trading system, backtest, and optimize it because there might be a possibility that 200 days is the correct length. Perhaps it’s too long or too short, but it’s a great starting point.
In general, most trend-following strategies will do well if you add a filter to only trade on the long side when the market is above the 200-day moving average. The first compelling way to use moving averages in your trading is using them as a market regime filter. Have the market trade alongside when the market is above 200 days or on the short side when the market is below.
Using Moving Averages as an Individual Stock Filter
The way you can use moving averages in your trading is as a filter on the individual stock. Look at the stock on the picture below. Let’s have a look at Apple stock. Here we’ve got the same daily chart; I’ve got a 200-day moving average. You can use the moving average as a trend filter for the individual stock. The first part of the strategy is you have the index filter and market regime filter, that says I’m going to trade long. If the market is above the long-term moving average, you come to the individual stock and say, I’m going to trade that stock long if it’s above the 200-day moving average. It’s a trend filter on the individual stock.
There are periods where it’s trending beautifully, and it’s well above the 200-day moving average here and here. Then there are periods where it’s below the 200-day moving average where you don’t want to be holding that stock. If you only buy this stock when it is above the 200-day moving average, you tilt the odds in your favour. Similarly, if you want to trade on the short side, you’ll do much better, generally shorting stocks below their long-term moving average. Using the moving average as a trend filter on the stock you’re trading is a great way to improve your results.
Using Moving Averages as a Signal to Enter or Exit a Trade
You can use moving averages as a signal to enter or exit a trade. There are several ways you can do this. You can use the price crossing above or below the moving average as the signal or one moving average crossing above or below the other moving average as the signal.
Let’s have a look at the chart below. I’ve got on the screen here a chart of Ford Motor Company. I just picked this at random. There’s no magic in this, so don’t take it as a recommendation about Ford one way or the other. I’ve got the standard daily chart and I’ve got a 200-day simple moving average. The price crossing above the 200-day moving average would be a bullish signal as we’d already seen, good things happen above the 200-day moving average and bad things tend to occur below it. You could use the price crossing above the moving average as an entry signal. The problem with this as an entry is that you get a lot of whipsaws around the point where the price is crossing over. It tends to cross above and below and do that several times before making a final decision and moving one way or the other.
If we have a look on the chart below, the price crossed above the moving average, but then it crossed back below, then it crossed above, then it crossed below, and it was below, then it crossed above, below and so on. There’s a whole bunch of whipsaw signals in there. The price crossing above a moving average as an entry while you can use it does lead to many whipsaws. You could be better quality signals, but it is possible, and some trading systems successfully use this.
Using Price Crossing the Moving Average as an Exit Signal
The second way you can use the price crossing the moving average as an exit. For instance, we got into this trend somewhere here, and we held it until the price closed below the moving average. That was quite a good exit. It gave up a lot of profit, but it did capture a big chunk of the trend. You can use across below a moving average as a trend following style exit because what it’ll do is it’ll keep you in a big move for a long time, and it’ll give the price a lot of room to move above and below the primary trend. When it finally crosses below the long-term moving average, you can get out. That can be an exit signal, which can be reasonably good. I’ve got several systems that use it to close below the 200-day moving average as an exit. For example, it’s like a fail safe exit because if nothing else has got you out before it closes below the 200-day moving average, that’s a sign that the up trend is over and you want to get out. You can use the price closing above or below the moving average as a buy or sell indicator to get in or exit a position.
The second way you can do it is to have two moving averages, as I said. Let’s take another simple moving average and use a 50. The second way you can use moving averages as a signal is through the crossover of two moving averages. You can see here that in blue, the 50-day moving average hugs the price fairly closely, and the long term 200 day moving average is loosely moving in the direction of the trend. When the shorter term moving average crosses above the longer term moving average, that’s a bullish signal. So you can treat that as a buy signal. When the short-term moving average crosses below the long-term move average, like here, that would be a bearish signal, a cell signal.
Now you can use these as an entry and exit signal in your trading. You have to test them though, because sometimes a moving average crossover can be too late. It’s quite a lagging signal. One of my philosophies around trend following, for instance, is to give the trend some time to prove itself before I jump in. The 50-day moving average crossing above the 200 as it does here can be a good signal.
However, if you look at the end of this trend in the Ford Motor Company stock, the 50-day moving average crossing below the 200-day moving average was quite late. It happened a long time after. Almost two months after the price first closed below the long-term moving average. If you wait for the short term moving average to come all the way down to the long term moving average, that exit can be quite lagged. Therefore, it does keep you in the trend for a long time, so you’ll be able to catch some of those big megatrends, but it does give up a lot of profit in the end. If you’re going to use this as an exit, you want to backtest that using Amibroker or similar backtesting software and compare the results that you get from that exit signal versus just the price closing below the long term moving average or versus standard trailing stop. But you can use a dual moving average crossover as an entry and an exit signal.
Using Moving Averages as a Buy or Sell Indicator
The final way or another way that you can use the moving averages as an indicator to buy or sell is by looking at the direction of the moving average. When a moving average is heading down, that’s a bear sign. When it’s moving up, it’s a bullet sign. When pivots from trending down to trending up, that can also be a good buy signal. Thus, you want to test all of these things for yourself in your backtesting software. Look at the photo below.
There was a short term sort of downtrend or a medium term downtrend, and at some point in here, the moving average ticked up and started moving up. That’s where the medium term trend turned bullish again, which would’ve been a reasonably good entry point into this trend. When the moving average, typically a medium term moving average, is trending down and it starts and it ticks up, that’s a point where you might want to buy. Then, the same thing can happen at the end of the trend when the medium term moving average ticks down. Then that would be a bullish indication. You can see that that happened here on this bar, and that was a much earlier signal than both the price closing below the long term moving average and it was much, much earlier than the medium term moving average crossing below the long term moving average. The medium term moving average ticking down can also be a reasonable trend following exit.
However, if you look closely, it’s a medium term trend exit because you can see in this big trend on the picture below that the medium term moving average ticked down at some point, and again and again at the end. It’s more like a swing trading, a medium term swing trading exit, whereas the price closing below the long term moving average is like a trend following exit. It depends a lot on what style of trading you are trying to do. Therefore, you want to match the way you use your moving averages to the trading strategy that you’re trying to design. Then backtest those rules to ensure that they work over a long period of market history to ensure that they are valid and profitable trading signals.
One thing I want to talk about is the thing called the Golden Cross and the Death Cross. This refers to index’s 50-day moving average and the 200-day moving average. Let’s have a look at the S&P 500 Index. The Golden Cross is when the 50-day moving average crosses above the 200-day moving average, and see that on the chart below. The Golden Cross happened in July 2020. That signalled that the market was now in a bullish phase. Then the Death Cross is the opposite. It’s when the 50-day moving average cross is below the 200 day moving average on the daily chart. You can see that the Death Cross happened up here and signalled the bull market’s end.
The Golden Cross, Death Cross is an excellent way to isolate bullish and bearish market regimes. It could be better, but it’s a pretty solid technical signal. Add this as a filter overlaying your swing trading strategy or your trend trading strategy. It can help tilt the odds in your favour because it will keep you on the long side in bullish market conditions and on the short side in bearish market conditions. Thus, the Golden Cross and the Death Cross trading signals are not signals I would use on their own, but they’re good filtering signals and filters that you can add to your backtest to see if they improve your trading strategy.
200 Days Moving Average
Why is the 200 day moving average so powerful?
In this section, I’ll explain to you why the 200-day moving average is one of the most powerful signals in technical analysis and why you should be using it in your trading systems to improve your results and reduce your drawdowns.
What is the 200-day moving average?
The 200-day simple moving average is just the arithmetic average of the last 200 days of closing prices. You take the closing price each day for the last 200 days, you add them up, and then you divide it by 200 and that gives you the 200-day simple moving average.
On the chart here of the S&P 500, I’ve plotted the 200-day simple moving average in black. I colored it red because I want you to see it so that we can understand why it’s just so powerful.
When you look at the chart of the S&P 500, you can see all of the good things in the market happen when the price is above the 200-day moving average. Also, all of the bad things happen when the prices are below the 200-day moving average. Above the 200-day moving average, the market volatility is low and it’s trending up. Below the 200-day moving average the market is very volatile, gappy, and it’s a bear market. It’s pretty ugly to buy and hold stocks. Good things with low volatility happen above the 200-day moving average, and bad things, high volatility gaps and market crashes tend to happen below the 200-day moving average. This idea has really stood the test of time.
You can see on the picture below that the bull market from post-COVID recovery all the way to 2022 was all above the 200-day moving average. Then as we moved into 2022 and inflation really started to take off, an interest rate started to rise to combat inflation. You see that the price fell, we went into a bear market, and all of that is below the 200-day moving average.
You can see this is the COVID crash, and we reached an all-time high in the S&P 500 just before COVID, and then COVID sort of started spreading around the world. You can see on the picture below that there’s a couple of big declines. Some declines can happen above the 200-day moving average, but there was a big consolidation around the 200-day moving average level. Then below the 200-day moving average, there were much higher volatility and a much greater decline in price. Hence, holding on the long side below the 200-day moving average is typically pretty risky. Before COVID, you can see the bull market from 2019 to 2020. That was all above the 200-day moving average, relatively low volatility.
At the end of 2018 and early 2019, this mini sort of bear market that we had here, all below the 200-day moving average. If we go back even further, you can really start to see that the 200-day moving average really separates the bulls from the bears. You can see post the 2000… Before the 2000 tech bubble burst, the price was all above the 200-day moving average. A couple of big dips in corrections but generally above. Then the tech bubble burst, and we had several years of the price trending down. Almost all of that was below the 200-day moving average. Then from 2003 to 2007 when we had the global financial crisis, the price of the major indices more or less stayed above the 200-day moving average that whole time. A couple of little dips below, but the bulk of the bull market was above.
Then for the entire bear market in 2008, 2009, the price was below the 200-day moving average. I hope you can see that the 200-day moving average is one of those pivotal sort of separators or dividers in the market that separates the bulls from the bears. If you’re not paying attention to the 200-day moving average, particularly the 200-day simple moving average on the global stock indices, then you really should take a look at it because it does help you filter your trading strategies.
At the very least, you want to be long above the 200-day moving average and in cash or short below the 200-day moving average. Buy and hold on the long side below the 200-day moving average is not likely to give you good results at all. It’s going to be volatile and loss-making. However, buying and holding above the 200-day moving average does work pretty well. But you know what else works really well above the 200-day moving average? Trend following on stocks. If you want to improve your trading, then use the 200-day moving average indicator as a filter to help you divide the bulls from the bears and know what sort of market regime you are trading in.
Moving Average Trading Strategy
This section will discuss the following:
- Discuss a trading strategy based solely on moving averages, so you can get a feel for how you can use them for the different components of the trading system.
- Discuss one small tweak that’s going to make a dramatic difference to the performance of that system. This is to illustrate that you can use one indicator to create a strategy, trading strategy or trading system, but sometimes adding in another indicator makes a dramatic difference. You don’t want to get too hung up on, “I trade with moving averages.” Because moving averages alone are not the best tool in the world.
Moving averages when combined with some other trading rules can give you much greater performance. I’ve used moving averages in all the different components of the system at the base trading rules that I created for you.
Index Filter or The Market Regime Filter
I’ve got the index filter and I’m using the Australian All Ordinaries Index because this strategy is trading Australian stocks. First of all, I’m calling the index the XAO, which is the Australian All Ordinary Index. The filter is that the index has to be above the 200 day moving average of the index. If that’s true, then we can take buy signals. If that’s not true, then there’s no buy signals. The entry trigger is the golden cross, so the 50 day exponential moving average crossing above the 200 day exponential moving average. This could be a simple moving average as well, or it could be an exponential moving average, still it won’t matter that much. They’ll perform a little bit differently but you can test both and see how you go.
The turnover filter here is the 20 day average dollar turnover has to be greater than $500,000. This is a liquidity filter to make sure that our slippage is going to be contained. You don’t want to trade small caps that have very low liquidity because then you end up with much higher slippage and your real time trading results don’t reflect your backtest. You got to have a liquidity filter in your trading system if you’re trading individual stocks. Another filter that we have here is for ordinary shares. This strategy is only going to trade ordinary shares, so fully paid ordinary stocks. Then there’s only one cell rule, which is the price crossing below the 200 day exponential moving average. This is a trend following system, so we’re hoping that the golden cross will get us in at the start of a trend.
Then when the price crosses below the 200 day exponential moving average, we’re going to get out. Hopefully we can capture a big chunk in the middle. The last couple of details you need to know is I’ve set the position sizing to 5% of equity. Thus, if there was $100,000 in the account, then each trade will be worth $5,000. For the position score, which ranks the signals, because often you get more signals than you can take than you’ve got the capital to take. It’s going to give preference to the stock, which is the furthest above its own 200 day exponential moving average in percentage terms. Hence, that’s the whole system. Let’s have a look and see whether that system is any good. I’m going to send it to the Amibroker analysis window.
In the Amibroker backtest window, I’ve selected all Aussie stocks and Aussie delisted stocks and we’re back testing from 1990 to today. Consequently, we hit backtest, and this is one of the best things about trading systematically because it took about 10 seconds and we already got an answer to our question of whether this is a good trading system. We’ve taken those trading rules in the last 10 seconds. We’ve applied them to every stock, current and previous listings on the Australian market from 1990 to today, and assembled a portfolio to say, how would that strategy have performed? Thus, if you’re trading manually using indicators and technical analysis, you really have no idea of how profitable your strategy is. However, if you take those rules and you put them into a system and backtest it, you get a lot of information about how your strategy is performing. As shown in this analysis window below, each one of these rows is an individual trade, the system took. The best trade made 1213% profit, which is pretty spectacular. The worst trade made 100%. Basically, this was a hundred percent lost, which is pretty rare, but it can happen.
Let’s have a look at how the portfolio performed in aggregate. On the report window below, you can see that the annual return for this strategy, which is the moving average trading strategy, is 9.3% over the last, what is that? 30 odd years or so.
It generated 1,326 trades, of which 29% were winners. The average win was 44% profit. There were 70% losers, which is pretty typical of a long term trend following system. The losses on average were 9.8%. This is a very typical profile of a trend following system. Low percent winners, large average win, high percent losers, small average loss.
The trouble with this strategy right now is the return is not very exciting at 9%, and the drawdown is pretty high at 50%. What we should do is make one change to this strategy. Instead of having just a moving average strategy, I want to incorporate one more indicator. In the code what we had was, the entry was the golden cross and the exit was the moving average. On the previous section on the different ways you could use the moving averages, one of the problems with the golden cross is it’s quite lagged. This is quite a slow entry trigger. Instead of using the golden cross entry, I’m going to use a breakout entry. If today’s close is the highest close of the last 200 bars, we’re going to buy the stock assuming all of the other rules are true.
After saving that and sending it to the analysis window, I ran this backtest to see what happens. See how great this is that you can backtest because in like 10 or 15 seconds we’ve got an answer to, is this system better or worse? Let’s have a look at the report window.
You can see that by changing the entry rule from the golden cross to a breakout, we’re now making 20% annual return per year instead of just nine. This is a dramatic improvement just by using a better entry trigger. You can see the number of trades dropped because we’ve got a more selective entry now. The percentage of winners is higher, much higher at 44%, there’s a much better entry signal, and the average profit per winning trade is 65% now instead of 44, way better.
The percentage of losing trades has fallen to 55%. The average loss here is a little bigger at this point at 17%, but overall, the system is much better, didn’t do much to improve the drawdown. The drawdown is still 53%, but we are getting this 20% return now, which is dramatically better. Having a trading system based on just one indicator isn’t necessarily the best way to do things. By elegantly combining a couple of different indicators, then you can get a much better result. If we look at the equity curve of this system shown below, we can see a much nicer trend on a logarithmic scale, this is a nice straight line from bottom left to top right, which is exactly what you want to see. That shows that the edge is stable and intact, and this system has performed very well over the last 30 years or so.
The drawdowns a bit high, you’d still want to do something for that. I’ve got a few tricks up my sleeve to make that better but with a little bit of filtering and some clever stock selection, you can really improve that as well. That is the stock trading strategy using moving averages that I wanted to share with you.
If you want to learn more about developing trading systems and strategies, then join my program the Trader Success System. In the Trader Success System, you get a whole portfolio of completed strategies that combine several different indicators in an elegant way to give you a great trend following mean reversion or swing trading systems on the long and short side.
Frequently Asked Questions about Moving Average
Which Moving Average is Best?
A lot of people will ask what is the best moving average to use? To be honest, there is really no best moving average. It depends on what you’re trying to use it for. You can really investigate which moving average works best for your purpose, whether you’re using it in your system for a trend filter or for an entry signal or a trailing stop or various different things, different moving averages will perform different functions. One of the best things you can do is learn how to backtest your rules and your ideas, so you can figure out what is the best moving average for you, your use case, and for your particular trading strategy.
Do I use a simple moving average, exponential moving average, weighted moving average, Hull Moving Average, or the TEMA?
Which one is the best?
Just like most things in trading, there is no one perfect answer for this. Every different moving average style of calculation has trade-offs, they all have advantages and disadvantages. The simple moving average is simple, easy to calculate, very fast to calculate. It’s a slow, quite lagged indicator. That makes it great for long-term trend filters. It doesn’t make it so good though for entry triggers, entry signals, or exit signals.
The Hull Moving Average is very responsive, which makes it great for entry and exit triggers, but not so great for long-term trend filters. If you’re worried about using this in moving average or that moving average, simple, exponential, or Hull, I want to suggest that you just pause and take a breath. Reflect on what trading strategy you are using, and what makes the most sense in terms of a style of moving average for that strategy and for the role that you’re trying to fulfill within that strategy.
Are you looking for a trend filter? If so, then a slower more lagged indicator is probably a good one to use. If you’re looking for an entry trigger and you want something quite responsive, then a faster more responsive moving average is one that you want to use. At the end of the day, if you don’t know which one is best, the best thing that you can do is backtest them all, and see how they perform. One of the great things about trading systematically is that trade all, you can test all of your different ideas, all the different moving averages and see which one performs best for your particular trading strategy and system.
Hence, backtest them, don’t get too hung up over which one is best, because none of them are best. No matter how many blog posts you read that explain the benefits of this one or that one, the best thing you can do is actually test them all. Then the next logical question is, “Okay, I know which moving average I want to use, but how many bars should I use to calculate the moving average? Is 200 best? Is 150 best? Is 10 best?” Again, it depends on the purpose. The best thing you can do is reflect on what am I trying to achieve here with this indicator?
If you are looking for a long-term trend filter, you’re going to use a much bigger number. If you’re using for a short-term entry or exit signal, you’re going to use a much smaller number. You can backtest those different values and combinations to make sure that you choose the length of moving average that is right for you, that gives you the best results for your trading strategy. Thus, don’t fall into the trap of saying, “Oh, I only use the 33-day moving average because that’s the best one and I’ve seen on the charts that the price bounces off the 33 and gives me support.” It’s complete horseshit, to be honest. Because every chart is different, and there’s no magic in the moving average.
What you got to do is backtest it and find over the most number of trades, over the most amount of history, over the most number of stocks, which moving average gave the best results for your trading strategy. Don’t worry about which one is best or which moving average to use best, test them and find out which one worked the most profitably for the strategy you are trading with. The answer is going to be different for all the different markets like Australian market, US market, or the Hong Kong market. It’s going to be different for trend following versus mean reversion versus swing trading. You got to think about, what am I trading, what is the strategy I’m using, and then zero in on the type of moving average that is best for you.
Is the Moving Average a Good Indicator?
Absolutely, it’s a good indicator if you use it for what it’s designed for. If you use it as a trend filter, if you use it as an exit signal, if you use it carefully as an entry trigger when buying or selling a crossover, then it can be a really powerful indicator. But like all indicators, it’s not perfect. You can’t just build a trading strategy on one indicator. Price crossing above a moving average and then exit when the price crosses below a moving average is not a complete strategy. You need to actually have a whole bunch of trading strategy components in addition to those moving averages. You can make a great trading system using a long-term moving average as in the index filter or stock filter, and then using a short-term moving average as the entry trigger, and then maybe a volatility filter, a stop loss, and a trailing stop to exit.
You can really build a solid strategy that makes a lot of money out of that, but one indicator on its own is never enough. Therefore, use the moving averages in your trading, but don’t get hung up on them too much. There’s no magic in any indicator and no one indicator is enough to make you money consistently. There’s some of the most common questions about moving averages on their own. The next question is, “Well, which is better? Or which one should I use? Simple moving averages or exponential moving averages?” Surely exponentials are best, better because they’re more responsive. But again, more responsive might be good for one purpose but might not be good for another. You need to actually backtest a simple moving average and exponential moving average for the same component of your trading system and decide which one is best by looking at the actual data.
Anyone who claims that exponential moving averages are always best is full of crap because they’re not always best. Sometimes they’re good and sometimes a simple one is good. I’ve got trading systems that use each of the different types of moving averages, because they’re all got a different use case. I’ve also got different versions of the same trading system, but with different moving averages just to create some internal diversity in my trading. I might use a long-term simple or exponential moving average as an exit, an exit part of my position on each one, just because it creates some diversity. There’s different ways you can do it like that as well. You don’t have to get hung up on which moving average is best, or which style of moving average you should use. You can use several of them, and you can create some diversity in your portfolio by doing that.