The Relationship Between the MACD and Z-Score: Creating the MAC-Z score
The MACD stands for moving average confluence/divergence and was introduced by Gerald Appel a long time ago as a means of tracking trends. Some background reading on the MACD can be found here: http://en.wikipedia.org/wiki/MACD
Effectively the MACD represents the difference between two moving averages–a short moving average and a longer moving average. As a consequence the MACD tracks the acceleration or rate of change in the trend. The Z-Score in contrast is related to Bollinger Bands and of course the normal distribution. It is designed to track the position within the price distribution normalized by volatility. Some background reading on the Z-score can be found here. Effectively the Z-score is the difference between the current price and a moving average divided by the standard deviation of price over the same time period.
So, many of you are already asking the question: “OK so what is the relationship here?” Well it comes down to how the math works–especially as it applies to financial data. The Z-score is effectively a normalized, rolling and de-trended measurement of deviation from an average. Most people for example use the z-score as a mean-reversion indicator especially in the short term. This is because the price of a stock or index rarely deviates much from its moving average and regardless of trend will tend to gravitate back to the middle value–which is zero. Values exceeding 1 or -1, and especially 2 or -2 are very likely to revert to the mean. The MACD works well at detecting the actual acceleration and direction of the trend, and this is because it looks at the difference between moving averages versus a price deviation from the moving average. Effectively the use of moving averages instead of price removes much of the noise inherent in the data, to more clearly reflect the trend. A positive MACD is bullish, while a negative MACD is either bearish or neutral. Refinements can be made to improve the MACD (see the DVMM at dvindicators.com). So to me the MACD and the Z-score are complementary and can be combined to create an improved indicator– especially if they are scaled to be the same length.
The general idea is that counter-trend component of the Z-score can be used to adjust/improve the trend component of the MACD. In this case my suggestion is to take the 12/25 MACD and the 25-day Z-score as an example of parameters that might be used. The key to combining the two indicators is to restore them to a similar scale. The weakness of the MACD is that it is an unscaled difference between two price moving averages. By taking the raw MACD (difference between the 12 sma and 25 sma) you can basically scale this indicator by dividing it by the 25-day standard deviation. This now gives us the difference expressed in standard deviation units, which is the same scale as the z-score. Now we can create an adaptive (or static) formula to properly combine the separate mean-reversion and trend components within a given time frame. We shall call this new formula the “MAC-Z Score” for reference:
MAC-Z= (Z-score, 25)*A+ (MACD,25)/(Stdeva,25)*B
where A and B are constants that can range between 2 and -2 in .2 increments to reduce computational time.
It is recommended that if you want to create a composite trend indicator the constant “A” should be negative. However this depends on the parameter length selected (in this case both use a 25 day as the long length) where the shorter the parameter length, the more likely “A” should be a negative value. In the case of “B” this should be a positive for a composite trend indicator, to reflect the trend impact of the MACD. Either way, as an optimization problem, the MAC-Z can be run with all iterations either way across a basket of securities, or to be customized to the security in question.
The advantage of the MAC-Z is that it is a more accurate and “assumption-free” indicator that can more accurately describe how a market or stock actually works in a given time frame. To more accurately understand where to best apply it, you can optimize the MAC-Z over multiple time frames find the best time frame to apply it or create a composite indicator. I will leave this for creative readers to have fun with—if anyone finds some interesting results I will be happy to post it.