Moving

average is a term that is often being used when there is talk about trading,

but what exactly is it and how can you use it in your own analysis? You

probably know how to calculate the average of a pool of numbers but let us

start with the basics.

average is a term that is often being used when there is talk about trading,

but what exactly is it and how can you use it in your own analysis? You

probably know how to calculate the average of a pool of numbers but let us

start with the basics.

**Average- and moving average- calculation**

When you

have a series of numbers and you for some reason want the average of those

numbers you simply add all those numbers and divide the sum by how many numbers

you have. E.g. you have these five numbers: 8, 9, 10, 8 and 10. The sum of

these numbers is 45. Divide 45 by 5 (as you have five numbers here) and you get

an average of 9.

have a series of numbers and you for some reason want the average of those

numbers you simply add all those numbers and divide the sum by how many numbers

you have. E.g. you have these five numbers: 8, 9, 10, 8 and 10. The sum of

these numbers is 45. Divide 45 by 5 (as you have five numbers here) and you get

an average of 9.

If the five

numbers listed above were price data for company ZZZ we could say that the last

five days average price for ZZZ is 9. Next day we read that ZZZ closed at 13.

If we were to calculate the new five day’s average it would become:

numbers listed above were price data for company ZZZ we could say that the last

five days average price for ZZZ is 9. Next day we read that ZZZ closed at 13.

If we were to calculate the new five day’s average it would become:

13 + 10 + 8

+ 10 + 9 = 50 and five day average will now become 50 / 5 = 10 (Fig. 1). What

we have done here is to “move” the five day period one step forward by

including the latest close and excluding the now sixth day close thereby

creating what we call a moving average. This procedure is repeated for every

new day so that we will get a series of moving average numbers that we can plot

as a line in our charts.

+ 10 + 9 = 50 and five day average will now become 50 / 5 = 10 (Fig. 1). What

we have done here is to “move” the five day period one step forward by

including the latest close and excluding the now sixth day close thereby

creating what we call a moving average. This procedure is repeated for every

new day so that we will get a series of moving average numbers that we can plot

as a line in our charts.

Fig. 1. Five day average calculation. |

**Plotting moving average**

When doing

technical analysis we analyze charts where price and other data are plotted. To

be able to get something useful from moving average we should plot the data in

our charts together with the price curve (Fig. 2). In figure 2 you see price data

plotted along price and volume (light blue bars). On top of the price bars we

have plotted a five day moving average as a dark blue line. Taking a closer

look at this line we see that it is smoother than the actual price movement. If

we were to plot a longer moving average using e.g. 50 days moving average we

would see an even much more smoothed curve as the value plotted for a specific

day is the average of the number of days we have used in the calculation for

the moving average.

technical analysis we analyze charts where price and other data are plotted. To

be able to get something useful from moving average we should plot the data in

our charts together with the price curve (Fig. 2). In figure 2 you see price data

plotted along price and volume (light blue bars). On top of the price bars we

have plotted a five day moving average as a dark blue line. Taking a closer

look at this line we see that it is smoother than the actual price movement. If

we were to plot a longer moving average using e.g. 50 days moving average we

would see an even much more smoothed curve as the value plotted for a specific

day is the average of the number of days we have used in the calculation for

the moving average.

Fig. 2. Plotting of a five day moving average. The blue line seen in this chart is the five day moving average of the closing price for this stock. |

**Types of moving average**

The moving

average we have talked about in this article so far is what we call a simple

moving average. There are many other types of moving averages as well but the

most common one beside simple moving average is exponential moving average.

When applying exponential moving average, last days values are being weighted more

than earlier days thereby making last days movements “more important”. The

result of this is that the graph will react quicker to the price changes that

occur. In Figure 3 we have plotted two moving averages. The blue line is a 20

day simple moving average and the green line is a 20 day exponential moving average.

It is easy to see that there is a difference between the two lines. Even though

it is the same number of days that is being used in the calculation of the

moving averages we see that the green line (exponential moving average) is

following the price development a bit more closely than the more smoothed blue

line.

average we have talked about in this article so far is what we call a simple

moving average. There are many other types of moving averages as well but the

most common one beside simple moving average is exponential moving average.

When applying exponential moving average, last days values are being weighted more

than earlier days thereby making last days movements “more important”. The

result of this is that the graph will react quicker to the price changes that

occur. In Figure 3 we have plotted two moving averages. The blue line is a 20

day simple moving average and the green line is a 20 day exponential moving average.

It is easy to see that there is a difference between the two lines. Even though

it is the same number of days that is being used in the calculation of the

moving averages we see that the green line (exponential moving average) is

following the price development a bit more closely than the more smoothed blue

line.

We earlier

said that we plot moving average along with price data, but it is also

important to remember that moving averages can be applied on all kinds of data

and not just on price data. Other examples could be moving average of volume

and relative strength index (RSI) to mention a few.

said that we plot moving average along with price data, but it is also

important to remember that moving averages can be applied on all kinds of data

and not just on price data. Other examples could be moving average of volume

and relative strength index (RSI) to mention a few.

Fig. 3. Plotting of 20 days simple moving average (blue line) and 20 days exponential moving average (green line). We see that the green line react more to the price changes that occur than the blue line. |

**A basic moving average trading system**

To see how

a moving average trading system could be used we will now design a very basic

moving average trading system consisting of two moving averages. The coding and

plotting of data shown here is done in a software called Amibroker which is a technical analysis

software where you can plot data, program trading systems, optimize- and test-

your own trading ideas.

a moving average trading system could be used we will now design a very basic

moving average trading system consisting of two moving averages. The coding and

plotting of data shown here is done in a software called Amibroker which is a technical analysis

software where you can plot data, program trading systems, optimize- and test-

your own trading ideas.

In this

example we will use a short 5 day simple moving average and a medium long 25

day simple moving average to form the framework for our trading system. What we

want to do next is to design our trading system to buy the stock when the 5 day

moving average crosses above the 25 day moving average and sell when the 5 day

moving average crosses below the 25 day moving average. The coding done to make

this system is seen in figure 4.

example we will use a short 5 day simple moving average and a medium long 25

day simple moving average to form the framework for our trading system. What we

want to do next is to design our trading system to buy the stock when the 5 day

moving average crosses above the 25 day moving average and sell when the 5 day

moving average crosses below the 25 day moving average. The coding done to make

this system is seen in figure 4.

Fig. 4. Amibroker code for the moving average trading system |

When we plot

these two moving averages we see why we want to buy the stock when 5 day moving

average crosses above the 25 day moving average and sell when the opposite

occur. Basically what we want is to be on the “right” side as the stock price

moves upwards or downwards (Fig. 5).

these two moving averages we see why we want to buy the stock when 5 day moving

average crosses above the 25 day moving average and sell when the opposite

occur. Basically what we want is to be on the “right” side as the stock price

moves upwards or downwards (Fig. 5).

Fig. 5 We want to own stocks in this company when the blue line is higher than the green line, and sell (or short) the stock when the blue line falls below the green line. The light blue bars seen in the lower part of the chart is the trading volume for the different days. |

From the

plot it looks like this system is quite promising with regard to being

profitable but to make sure that it is actually profitable we need to do some

more testing. What we want is a trading system that will perform well over time

and in all kinds of market conditions. Although the trading system seems

promising at a first glance the testing of this system shows something else. As

seen from the test report produced by Amibroker the system performance was

rather poor over the test period from mid June 2004 to mid June 2008. With a

win percent of 33.3 this is probably a trading system that we should leave and

not trade as is today. Although the trading system does not perform as wanted

the overall idea for the system might still be something to build further upon

(Fig. 6).

plot it looks like this system is quite promising with regard to being

profitable but to make sure that it is actually profitable we need to do some

more testing. What we want is a trading system that will perform well over time

and in all kinds of market conditions. Although the trading system seems

promising at a first glance the testing of this system shows something else. As

seen from the test report produced by Amibroker the system performance was

rather poor over the test period from mid June 2004 to mid June 2008. With a

win percent of 33.3 this is probably a trading system that we should leave and

not trade as is today. Although the trading system does not perform as wanted

the overall idea for the system might still be something to build further upon

(Fig. 6).

Fig. 6. Profit distribution for our trading system. We see that we have a few nice returns of investment here but when we just have a few winners we choose not to go further with this system. What we want is a much more even profit distribution that could be e.g. 20 winners in the 5% to 10% range rather than one winner of 100%. Only then can we say that we have a more robust trading system. |

It has to

be said that the testing done here is very simple and stocktradersbulletin will look deeper into testing of

trading systems in an article at a later stage. Also it should be noted that

the testing here was done on one stock which is not a good enough foundation

for validating trading systems.

be said that the testing done here is very simple and stocktradersbulletin will look deeper into testing of

trading systems in an article at a later stage. Also it should be noted that

the testing here was done on one stock which is not a good enough foundation

for validating trading systems.

**Conclusion**

Moving

average is a tool that could be used in a meaningful way if it is applied correctly.

average is a tool that could be used in a meaningful way if it is applied correctly.

From our

analysis in the previous section we can say that using moving average alone for

your trading will probably not give you the profit you would like to see in the

long run. You will simply see too many false signals for when to buy and sell.

To minimize the false signals you should use moving average in conjunction with

other technical analysis tools. What tools and how you want to do that is

entirely up to you but what you should remember to do if you have the chance is

to test, test and test your system and make sure that you are not just seeing

wishful things before you go ahead and do actual trading with real money.

analysis in the previous section we can say that using moving average alone for

your trading will probably not give you the profit you would like to see in the

long run. You will simply see too many false signals for when to buy and sell.

To minimize the false signals you should use moving average in conjunction with

other technical analysis tools. What tools and how you want to do that is

entirely up to you but what you should remember to do if you have the chance is

to test, test and test your system and make sure that you are not just seeing

wishful things before you go ahead and do actual trading with real money.

**Final note**

What you

have read here is just one method of how you could use a moving average. As we

have seen the method presented in this article is not a very profitable one but

the intention here is to give you some information about moving average and

possibly also give you some inspiration from where you can continue with your

own ideas and development of trading systems.

have read here is just one method of how you could use a moving average. As we

have seen the method presented in this article is not a very profitable one but

the intention here is to give you some information about moving average and

possibly also give you some inspiration from where you can continue with your

own ideas and development of trading systems.