Pages

Friday, August 8, 2014

Moving Averages and Chebyshev's Theorem

There are plenty of places on the internet that discuss this, so why make another post to litter the world with more information? Simply put to give my perspective on these instruments and explain why they work mathematically.


A simple moving average, or simply SMA, is computed by taking the average of the previous n trading days.

For example, the 5 day simple moving average is S_5 = (x_1 + x_2 + x_3 + x_4 + x_5)/5 where x_1, x_2, x_3, x_4, x_5 are the closing prices of the previous 5 days. Obviously everyday a new average must be computed.

Traders tend to believe that if the moving average is sloping up and the prices are above the moving average, then the trend is up and prices are increasing. This makes sense, because the only way the moving average can get larger is if the closing prices are higher and higher. Remember that the definition of a trend is higher highs and higher lows. Key point: higher highs and higher lows means higher closes, so a larger SMA.

Another reason to use SMA's is that the price is often difficult to read, whereas the SMA gives a picture of the price with less "noise". To be more precise, the standard deviation of the the last n closes of the SMA is smaller than the standard deviation of the last n market price closes.


This is why.

Let's define the following.
(1) s = the standard deviation of the last n market price closes. Formula:  s = sum( (x - SMA_n)^2 )/(n - 1)).
(2) SMA_n = the n day simple moving average. Formula: SMA_n =  sum(x_i)/n.
In both cases the summations run from 1 to n.
(3) S_n = the standard deviation of SMA_n. Formula: S_n = s/sqrt(n).

Notice that as n->infinity we have S_n->0, so the larger that n is the smaller that S_n is. Also notice that s <= S_n for n >= 1.

This implies two things,

(1) The larger the number of days we use, the smaller the standard deviation of the SMA_n.
(2) The standard deviation is of SMA_n is always smaller than the standard deviation of the last n market price closes.

Simply put, the standard deviation of the simple moving average is smaller than the standard deviation of the prices.

What is the standard deviation? Well if you look at the formula you can see that it is some sort of  average basically. It tells you, how far on average the prices will lie from the mean.

How can it be used? Well Mr. Chebyshev has the answer.


Chebyshev's Theorem
For any data set, at least 1-1/k^2 of the values lie within k standard deviations of the mean. Here k is any number bigger than 1.

Take for example k = 2.

Then for any data set, at least 1-1/2^2 = .75 of the values lie within 2 standard deviations of the mean.

Take k = 3.

Then for any data set, at least 1 - 1/9 = 8/9=.889 of the values lie within 3 standard deviations of the mean.

Here is an example.
1, 2, 3, 4, 5,100

The mean is xbar = (1 + 2 + 3 + 4 + 5 + 100)/6 =19.17 (rounded).
The standard deviation is s =  39.625 (rounded).

Chebyshev says that at least 75% of the numbers that we have should lie within 2 standard deviations of the mean. This means at least 75% of the numbers that we have are between,

xbar - 2s and xbar + 2s. In interval notation is this can be written as,

(xbar - 2s, xbar + 2s). Plugging in the numbers we have,

(-60.28, 98.42).

This is called a 75% Chebyshev Interval for the mean. Note that we have 6 numbers, and 5 of them lie in this interval, so we have (5/6)*100% =  83.33% of our values lie in our interval.

Is Chebyshev wrong? Absolutely not. Remember that Chebyshev says that at least 75% of the values will lie in our interval. In our example, we have 83.33% of the prices lying here.


Other Remarks.
- You can keep going and increase k as much as you like.
- Chebyshev's only tells you this information for the data set in question. In the market you always have a new unknown price added to your data set.
- Bollinger bands are related to all of this. Usually the middle line is the 20 day SMA, and the top and lower lines are two standard deviations away from the SMA.

Use this information at your own peril. Nothing here is guaranteed to be correct as I wrote this from the top of my head.

I hope this post has helped somebody out there!

No comments:

Post a Comment