Moving average – the best settings

A moving average is an indicator of technical analysis, with which the price movement can be calculated in the form of – as the name already reveals – averages. The SMA is used in trading-strategies and in investment strategies. And of course it is used in many differnet data set.

Other names for the moving average are moving average or the plural moving averages, simple moving average or the short form SMA, to list only a few variants here.

In addition, it should be noted that the previously mentioned SMA, the simple moving average is certainly the best known representative of the averages and thus a kind of basis for these patterns. Simple is the average because when calculating the SMA based on the past prices of the security (stock, CFDS, etc.), a classic average price (average of prices) is assumed.

Another option would be, for example, to work with weighted averages such as the EMA, the exponential moving average for a stock or for CFDs.

We will not go into the differences in this post. Let’s stay with the simple moving average, the simple moving average. Because even here there is enough to know about as a trader.

Because in the discipline of charting and in charts in general, moving averages – no matter what form they take – are readily and frequently used. This is to reduce the risk of a trade.

One finds this average of the courses nevertheless often in the chart – all the same whether it is a line chart or a candle chart – represented. This also tells us already the representation of the moving average, which we discuss in the introduction of this article. Here we will also deal with different definitions and treat different averages.

Analysen
Know how

Representation of the simple moving average

All conventional variants of averages are represented in the chart itself. This is a line that fluctuates more or less (depending on the selected look-back period – more on this later) around the price.

As an explanation of this, below we see the chart of Apple in a certain period. We can see that during this period the stock is well above the 200 day SMA (simple moving average). Even very clearly, as you can see very nicely in the window below in this form. 

Note: you can click on any window of this article to enlarge the time series.

Note: charting tools provided by Wealth-Lab.

Source or data series for the formation of the moving average

Usually (basis) the simple moving average SMA (but also the EMA) is calculated from the closing price of the previous days. This results in these average values. Optionally, there are other possibilities or definitions such as a calculation of the time series based on the opening price or even the daily high or low. Averages of a time series are a complex subject.

What happens if we change the calculation base on the basis of other data, we will also see a little later in this article about moving averages.

Data series?

Let us first get an overview of the meaning of price movements

Disruption

Data and time series analysis

If we want to determine the function of the moving averages in different periods and with different price movements, we need to analyze the indicator exactly. In trading we call this “doing a backtest” and to backtest something the trader needs data, as we will see in the text in a moment. 

For the sake of order, more precisely, the historical stock prices. Data and price movements over a certain period of time of certain values (instruments) . Now, from a technical point of view, stock prices are merely data series. And a computer, unlike a human being, finds it easy to analyze these prices, data or dataseries.

We humans, on the other hand, prefer graphical representations of the price trends of the security – charts. And this is best done online. Because we can see the movements of stocks or CFDs with uptrends or downtrends better by looking at a chart with the naked eye than by looking at a price list.

But let’s get back to our periods, the time series and the moving averages with the price movements of a security, because there is still a lot to say about these topics and this method.

Simple moving Average - the idea

Moving averages are considered trend following indicators for various instruments (Stocks, CFDs, futures and many more). 

Depending on the selected period (day, etc.) of the average, it is in practice anyway that a rising moving average shows, for example, rising price movements in a form of smoothing and a falling moving average falling prices of the security. 

Trends and their patterns of the security can be captured – allegedly – very nicely on a time series this way.

Moving average - popular applications

In many charts and here also surprisingly in the application by investors one finds moving averages of all kinds with a look-back period of a time series of 200 days. Here, the prevailing opinion is that financial instruments are worth buying or holding on average above the 200 day period length of the average.

Other popular settings are for example 100 days period length or 50 days as average as smoothing. The statement always remains the same: if the course of the price is above this magic time series or cuts this straight from the bottom to the top, it is good. If the course is below it or if the course cuts from top to bottom it is less good.

Now this may be unsurprising so far and up to this point the content and reading value of this article has not been particularly high, we assume. However, we now want to change the course in the text and get into online analysis and different topics and thus use different triggers (triggers), all related to the simple moving average.

We use the moving averages as an entry signal on different financial instruments to then draw an overview and a basis for using the indicator. But everything in order.

Aktien für 2022

Moving averages in practice test

To find out the best settings of the simple moving average SMA indicator, we try some different approaches, like using averages (mean). Of course, for this to work, we need to develop a whole trading system and test it. 

So we need the financial instruments on which we test the simple moving average, an exit rule, a backtesting period and the quantity of instruments traded.

Backtest Settings

  • Period: the last 22 years
  • Data set: the 30 stocks of the Dow Jones
  • Position Size: 20% of Equity – so according to our rules for buying, up to 5 stocks (20 x 5 = 100% – we do not leverage) from the Dow Jones can be bought and held at the same time.
  • Position Priority: RSI lowest Values (here more about the Position Priority)
  • Entry or buy rule: situational according to the following variants
  • Exit rule: various – situational (see below for the individual tests)
  • Margin factor: 1 (unleveraged)
  • Ordertype: market on open

In our backtesting software (provider: Wealth Lab) the basic settings look like this. We will find many more such illustrations in this article.

Price crosses the moving average

Our first statistical analysis lets us test (backtest) the following situation from practice. We buy on the day after the price breaks its moving average of 200 days period length from the bottom to the top. By doing so, we assume that the stock is developing momentum and we want to take advantage of this momentum and reduce the risk.

We sell when the price crosses back below the 200 day moving average because then the momentum has fizzled out.

The online settings (we use the backtesting software Wealth Lab here as usual) look like this. Wealth Lab allows us without programming to map the use of different situations using the so-called “Building Blocks” method and thus backtest a time dataseries (or several).

The price (close) is also an indicator in Wealth Lab, which you can compare or relate to other indicators. Here we use the block “Indicator crosses Indicator” and use “close crosses over SMA”.

With the simple moving average SMA indicator (moving average) we use a lookback peridode of 200 days. So we average the price from the last 200 days. When the price breaks the 200 SMA moving average from the bottom to the top, we buy.

We sell when the price crosses the moving average SMA from top to bottom. We again use the block “Indicator crosses Indicator” but in sequence “close crosses under simple moving average“.

We make our first backtest with these basic settings. Does this idea work? Can we see trends with this first way of calculating the average?

We can see the calculation of the rates above. Let’s pay attention to the highlighted line APR, Annualized Percentage Return. This is the annual percentage return on average. Attention: this is not a forecast but a back calculation. Over the last 22 years, using these rules, we would have earned 3.19% per year.

The bottom line is a positive result, but let’s be honest. That’s a bit paltry. The return on average is weak. Does the risk pay off here? Furthermore, a trader or investor with a passive investment in the overall market (SP 500 Index) would make a profit of 5.55% annually.

In similar analyses, we have received letters asking why we use the SaP500 index as a benchmark and not the Dow Jones? Wouldn’t it be obvious to compare a system that works with the 30 stocks of the Dow Jones also with the benchmark or time dataseries Dow Jones and thus determine average values?

Yes – the thought has something. On the other hand – whenever we talk about THE market development or talk about theoverall market, we talk about the SP 500, because this stock market barometer has more significance in front of us. Therefore, we remain true to ourselves here and also use the right market for us as a measuring stick (benchmark) at this point.

One more thought in the text about the unsatisfactory average values from earlier. Could this be due to the sorting logic and the use of the position priority and its influence? After all, such or similar set ups with the moving average are used in numerous trading books. Why do we not get better returns here?

Unfortunately, we have to disappoint you. It is not because of the sorting logic and the use of the position priority based on the lowest values with the RSI. Because attentive or experienced people may have noticed that we sort the entries based on the priority countercyclically (lowest value RSI means to give the highest weight to the stocks that have fallen the most).

The thought now is that this does not match. Because we enter trend following based on the time dataseries and sort the signals by contratrend.

What would happen if we sort by RSI highest Values and pick the best stocks?

The entry block setting looks like this as a result.

Because we must not quibble when we bake test. All right – we’ll take note of these figures and continue testing. Can we get more out of the simple moving average SMA with a different setting? What happens if the trader uses a 100 moving average (average) for entry and exit instead of the number of 200 days? What is the impact of this setting then?

We set up the blocks again as seen below and likewise we set up the sorting of the prices (Position Priority – in Wealth Lab this is called Transaction Weight) again with lowest Values. This looks like this.

Note: feel free to read an articel by Thomas about Transaction Weight

Is 100 days moving average of the security now better than 200 days? Let’s look at the numbers.

The attempt went wrong. The return has turned negative. The risk continues to increase. But all good things come in threes. We try a number of 50-day average look-back periods – for entry and for exit. What happens then? As you can see: the amount and number of tests is getting bigger and bigger – but this is necessary. 

After all, the stock market is about your money. Therefore, they must know the course of the security well before they take the risk.

The performance is now back in the green zone. But this result for the simple moving averageis also weak in this form, right? Nobody trades daily to make a profit of 2 or 3 percent per year.

So this is not the way to move forward. How then? Fortunately, we have the so-called optimizer, which brings us faster to the goal. The optimizer automates, if you will, the search for the best settings of the security.

Optimization simple moving average crosses value

We enter in the optimization settings that we optimize the simple moving average from the value 1 to the value 301. And we do this in steps of 10. 

In the first optimization, we deliberately refrain from jumping to every single value, but instead want to get a rough overview of the areas in which the indicator “hits”. 

A second round of optimization, a fine-tuning, can be done when you have narrowed down the range of values and can, for example, exclude areas that do not bring any advantage.

Note: we don’t want to go into how to optimize properly here in the text, because this is about other topics. We use the 10 steps to save time and to shorten the optimization. If you want to learn more about proper optimization, we recommend our Online 2nd Day Online Intensive Workshop or our Trader Team Coaching, which take place at regular intervals.

We start the backtest and after a few minutes of waiting time (which fortunately you don’t have to “do” – but we do…) we get our test results in table form. So what is the best average?

Backtesting software provider: Wealth Lab.

We see that the best profits are achieved with the following moving averages settings.

  • Entry: Close crosses over 71 simple moving average(table column 2 from left – Period Entry)
  • Exit: Close crosses under 1 simple moving average(table column 3 from left – Period)

Thus we achieve a return of over 10% with this form of calculation of the average. That’s not outstanding but it’s still worth it. The risk is starting to pay off.

What else do these values in the table tell us? Now, are 71 and 1 the best values at all? No – but we can see that the regions (not the exact values) around 71 and around 1 are the best areas. After all, we optimized in steps of 10 to save time. 

The values 2 – 10 were not examined by Wealth Lab at all, because the optimizer jumped from 1 to 11, 21, 31 and so on, until it stopped at 301.

In a further optimization you can now fine tune to find the best values. We invite you to run these simple tests yourself. They are very easy and take only a few minutes – depending on the performance of your computer a bit more or less long. And you have just seen how to do it with the backtesting software.

Simple moving average Backtest based on the Open

Now let’s make another attempt in this text. Let’s take the best areas (71/1) from the past optimization of the average. But now we form the simple moving average not from the dataseries close but from the dataseries open. 

We had discussed this briefly in the introduction of the text, that it is common in trading to calculate the moving average on the basis of the closing prices. And we also said that it is common but there are other options.

See here the new settings of the blocks of Wealth Lab when calculating the average. Pay attention to the values 71/1 and to the note at the entry “SMA (Open,71)” and at the exit “simple moving average(Open,1)”. Previously it said Close twice.

Can the result keep up with the previous optimization, using the open price as the basis for the average?

No – not at all. Interesting, isn’t it? The cards are completely reshuffled again. If the trader forms the average value with the close, one cannot derive outstanding but halfway useful results. If, on the other hand, one uses the open in trading, the performance tips over from the average into the negative. So we burn money again.

Note: we would not claim at this point that the simple moving average based on Open does not work. Simply because we have not tried (backtested) it enough. Get in the habit of trying everything and being open to everything. Sometimes you find things that you never thought possible. And now on with the text, because we still have some topics.

The nice thing about bakingtesting is that it gives you lots of ideas. First of all: no idea should be hastily dismissed. Every idea must be given a chance, no matter how crazy it sounds. 

Many of the things we know today about serious trading we have discovered because we approached the matter with an open mind. And some things we even discovered because we got the settings of the backtest wrong on the first try… (you have to be that honest).

And so another or at first sight strange idea we have now. We turn the logic of moving averages around. We buy when the price falls below its average and sell when it rises above the simple moving average SMA. 

However, since we already know that we will not be able to succeed with the same top settings from before with other base settings, we optimize the whole thing right away again. Again we use the value ranges 1 – 301 for both entry and exit. The Building Blocks of Wealth Lab now look like this.

Again, we have to wait (fortunately they don’t) for a good quarter of an hour until we receive data. But these few minutes are worth it. Let’s use the time, as long as the optimization for the best average is running, for the following hint.

Note: attentive readers have now probably noticed something crucial. In the first backtests we entered trend following. We bought when the price crossed its n-day moving average from the bottom to the top. 

This was the prerequisite for entrys rising prices, because yes price can only rise above the average if the price goes up on average.

So far we have entered trend-following or pro-cyclical. And now? Now we try to enter when the price falls below the simple moving average downwards. Thus, the price also falls downwards. Since we go long, we suddenly enter anti-cyclically. We no longer buy the winning stocks but the losers. So we change the overall trading strategy from trend following to contra-trend.

Is the optimization now already finished after we wrote this? No – we will wait another 9 minutes. But for you, dear readers, for your further education we do everything…

So – finally the results are in. How does it look now with the contra-trend entries with the SMA?

Provider of the backtesting software: Wealth Lab.

On average, the results look much better and, above all, more stable than when we started trend following. The number of double-digit test results is significantly higher (exactly 4 – earlier with the trend followers it was one). And furthermore, the top 20 results are also better on average for the counter-trend entries. 

So counter-trend is better at the average. But you guessed it anyway: with the price crossing above or below the moving average (no matter which look-back period) there is not much to be gained. No matter if trend following or contra-trend.

But we are not saying that the simple moving average SMA is useless as an indicator in technical analysis. We are just saying that it is only conditionally suitable as a trigger in trading. As a filter in trading systems, on the other hand, the average is rather practicable, although this again depends on the respective strategy. Either way, the great popularity of moving averages cannot be justified.

But we are not giving in yet. One attempt at a moving average still works. We’ll try a different approach.

SMA rises/falls a few days

Finally, let’s try the following. Let’s take the best average – entry settings (71 days number of lookback period) in our pro-cyclical (trend following) strategies and also our best entry settings (also 71) in our anti-cyclical (counter-trend) simple moving average attempts.

But instead of the entry rule: price crosses above/below the average (moving average) as entry we try tests where the simple moving average moves in the same direction for 3 days. And upwards or downwards, depending on which overriding trading strategy (trend or contra-trend) is to be tested.

The exit we make in both attempts (pro- and anti-cyclical), if the SMA falls three days.

Trend following SMA average price Entry

You need to get a little more creative with the blocks now. The trend settings look like this.

And what does the result look like? Worse than the first backtests where crossing the price was the trigger. We make only a little more than 2% return per year with the continuous movement over 3 days. So we are making less money on average.

Contra-Trend SMA Entry

If we want to enter anti-cyclically with the average, we just change the first block of a system. Now the average of the share (its mean value) must be below the mean value for 3 days, i.e. it must fall. For help we see the graph below.

What does the backtest tell us about this period? How much money do I make? What about my risk?

This return and therefore this approach also disappoint. 

But if you have read carefully, you may have noticed that even with this way of using the average of the prices, the contra-trend strategies were better than the trend followers. This insight should be remembered first and used secondly for the further design of trading approaches on US blue chips.

Conclusion moving averages

Moving average data (SMA, EMAS and many more) – with this article we have merely scratched the surface, although the text already went over several pages. We have only dealt with the simple moving average SMA, the simple moving average. And here only with the crossing or a constant movement of the moving averages. But the use of this average is also conceivable with another variant in different market conditions.

We have left out numerous other options like crossing from a mean or at all other financial instruments than the stock (remember: we have tested all this only on the blue chips of the Dow Jones). And we always stayed on the daily chart in our backtests and did not consider intraday data. So there is still a lot to do for you (and us) to trade your money sensibly.

Something else remained open: what good are averages as a sell signal? We did not talk about that at all in this text in this form.

There are many averages in the world of technical analysis and price movements. The following is a short list for the sake of order, because the text is already very long.

  • SMA – simple moving average
  • EMAS – exponential moving average
  • DSMA – Deviation scaled Moving Average
  • Fast simple moving average- Fast Moving Average (moving average)
  • VWMA – Volume Weighted Moving Average (moving average)
  • WLMA – Wealth Lab Moving Average (moving average)
  • TEMA – Triple Exponential Moving Average (moving average)
  • KAMA – Kaufmanns Adaptive Moving Average (moving average)
  • and many more…

It is up to you to start this business and check all these indicators in your charting tools and if they are good as an average implement them in a trading system. Remember: it is your money. Check thoroughly, because the moving average is complex. Especially with the averages (mean value) it will often be advisable to see them as a supplement – as a filter – for a stock trading system. 

If you are interested in several such indicators analysis then we have good news. We will gradually subject more technical analysis indicators to a fact check in this or a similar way. 

In conclusion, we would like to state that the moving averages are just one of hundreds of indicators available to the trader or investor. But there are better indicators tin technical analysis han the simple moving average like RSI or bollinger bands and its related representatives. In Trading it is all about price volatility.

How to learn to understand these indicators and use them technical analysis correctly, you will learn in our free trading newsletter service. Register right now for free.

Don't miss new posts - subscribe to our free newsletter service now