Evaluation Of A MACD Investment Forecast Script

Executive Summary

  • We review one of the better-known technical indicators for selecting investment vehicles.

Introduction

We review a MACD script to see what it is doing.

*Note

This article is only part of our internal analysis of investing and communicates with people we know. We are not writing this to attract investors, and we are not giving investment advice. This is just a convenient way to document our analysis, which can be easily shared and easily updated. 

Reviewing the Code For One Volume Weighed MACD Script

The following is the code of this script.

First, let us review what is MACD or Moving Average Convergence Divergence is two moving averages constructed with one another that allows the user to see inflection points. This is explained well in the following quotation.

It is a way of displaying two moving averages, one shorter term and one longer term. They are either converging or diverging. MACD is an oscillator. It moves up and down around a zero centerline. – Bad Investment Advice

The difference between the two moving averages is the indicator of whether the price is increasing or decreasing.

// @author LazyBear
//
// If you use this code in its original/modified form, do drop me a note.
//
study(“Volume Weighted MACD [LazyBear]”, shorttitle=”VWMACD_LB”)
slow = input(12, “Short period”)
fast = input(26, “Long period”)

This part of the code creates the two variables of slow and fast. Slow is the shorter period average and fast is the longer period average.

signal = input(9, “Smoothing period”) maFast = ema( volume * close, fast ) / ema( volume, fast )
maSlow = ema( volume * close, slow ) / ema( volume, slow ) d = maSlow – maFast
maSignal = ema( d, signal )
dm=d-maSignal

Here the volume is multiplied by the slow and fast variables.

h_color=dm>=0? (dm>dm[1]?green:orange) : (dm<dm[1]?red:orange) plot( dm, style=histogram, color=h_color, linewidth=3)

This shows the plot size and color of the histogram. The histogram combines the volume (which is the height of the individual histogram bars) with the MACD direction. This means that it provides both the direction and the scale of that direction. The higher the bar if red, the more volume is selling the investment vehicle, and the higher the bar if green, the more volume is buying the investment.

The term fast and short is used to describe what I think is better described as short period moving average and a long period moving average. This is explained in the following quotation.

A shorter term moving average will rise more quickly than a longer term moving average during market uptrends. As the rise comes to an end, the slower moving average will catch up, narrowing the distance between them. This narrowing suggests an end to the advance. The same pattern occurs during market downtrends. The differential between the two moving averages may be plotted as a histogram. – Understanding MACD

And this quotation.

As you can see in the chart, the shorter-term exponential average, trackmg more closely with actual price movement, is more sensitive to changes in price trend than the longer-term average. As the market declines, the shorter-term average declines more quickly than the longer-term average. As declines come to an end, the shorter-term average will flatten, usually before the longer-term average, and will then move upward with rising prices, crossing and then moving above the longer-term moving average. – Technical Analysis.

This allows one to show two important pieces of information in one graphic. Reading this histogram is well explained in the following quotation.

The basic theory is this: if price and volume are moving in the same direction, the trend of the stock price will continue. If they are running counter to each other, the trend will reverse. – Money Show

There are several reasons why it is important to incorporate volume into analysis of investment vehicles. One is that volume changes come before changes in price. Volume is of course comparative. Therefore the size of any one volume bar in the Volume Weighed MACD must be compared to previous bars. And this is easy to do with this output. However, something that throws a wrench into the process of this estimation is that if an investment vehicle has gone up or down significantly in the past few years, the most recent bars in the histogram will be out of proportion with the older bars. If this has occurred in the price history it is important to “reorient” one’s mind when reading the histogram.

Are Comparative Moving Averages Used in Other Forecasting Areas?

One thing that struck me immediately when analyzing the MACD script is that I have never seen two moving averages that are compared to one another used in other types of forecasting, for instance when trying to forecast the sales of products, which is another very large area of forecasting. Moving averages are very commonly used in product forecasting, but not comparative moving averages. Moving averages are very good, because they are simple, yet have been proven in many decades of product forecasting. Moving averages do not work very well for repeating patterns, such as seasonal patterns, where it is more useful to sample from the repeating cycles (say the demand for the same months last year). Something else curious is that the number of periods in the moving averages used in the example above is very long moving averages, or that is many periods moving averages and much longer than what is used in product forecasting.

Using this for product forecasting would allow users to observe the general trend in the same way that financial forecasters do.

Properly Interpreting the MACD Depending Upon The Individual

Our interpretation is that the MACD does not give a distinct “buy” or “sell” signal. Now technical the buy and sell signals are when the MACD signal and MACD level pass one another. That is what the common knowledge says on this indicator. However, there are several other important distinctions in terms of using the MACD. We call these MACD tests.

Test #1: Considering the Differences in the Signal and Level

The difference or magnitude of difference in the MACD signal and the MACD level is also important. This measures what is referred to as momentum.

A small difference will normally result in a small increase and a small decrease. Therefore (and I will discuss the distinction in trader types in just a few sentences) one should not buy into a MACD stock with a small difference. One reason for this is a small difference in the signal and the level can reverse quickly, meaning the stock has to be bought or sold in the short term. We determine the desirability of the magnitude of the difference by looking at the historical magnitude of the difference for the IV.

The distinction I was alluding to a few sentences ago, is that for some traders that are interested in spending a lot of time monitoring the positions, this might be a desirable strategy. But not all people are full-time traders. Therefore, how MACD is used depends upon the person performing analysis and the trade.

And there is a secondary topic, which is how many IVs does someone need?

The more that one invested in small differences between the MACD signal and the MACD level, the more one will end up with a larger portfolio of IVs. There are two contradicting factors at play. The more IVs one has, the more the return will match the expected return, however, the more IVs one has the more overhead there is in managing the movement into and out of each IV and the more time is spent analyzing the IV portfolio. This is why I am just explaining the constraints rather than offering any prescription here.

Test #2: Considering the Differences in the Signal and Level Versus the Recent Price Rise of the IV

One can often find a small difference between the signal and level, with the level crossing or above the signal, but when the price rise has been large and often very short term. This provides less value to the investor when the opposite condition is met. This falls into the same category or issue as distinction #1, as it is more applicable for short-term traders.

This is explained in the following quotation.

After a strong price rally, the MACD divergence is no longer useful. By dropping, while the price continues to move higher or move sideways, the MACD is showing momentum has slowed but it doesn’t indicate a reversal. – The Balance

Test #3: Considering the Differences in the Signal and Level Versus the Long Term Price Rise of the IV

One can often find a small difference between the signal and level, with the level crossing or above the signal, but when the price has increased to be very out of line with the historical level. MACD will not care about the long-term history, because it only looks at the last 26 periods and the last 12 periods as a moving average. However, this means MACD can put investors into IVs that are very high versus their history, and this means the IV has the potential to quickly reverse. We have seen this on a number of occasions with very low-priced stocks, that trade for several dollars. This gets to another topic which is the number of periods used. As I just said, 26 periods and 12 periods is the most common number of periods and are considered the default. However, the shorter the number of periods the more “jerky” or responsive the buy and sell signal. Therefore, if one wants a more responsive MACD, then shortening this default makes sense, and of course, the converse is also true.

It is curious that in all the reading we did on MACD, we rarely found these issues, which we have combined into the tests discussed. This is reinforced in the following quotation from the inventor of MACD, from his book Technical Analysis.

Strangely enough, in spite of its widespread use, relatively little has been written regarding MACD or of some of the best ways in which MACD patterns can be maintained, approached, and interpreted. We consider many of these in this chapter. – Gerald Appel

Crossing Lines or Changes in Direction?

The MACD is easy to read because the lines cross. However, our analysis and the analysis of others show that change in direction occurs before the lines cross, and this is actually the buy or sell signal. This is explained in the following quotation.

My research over the years has suggested that greater net gains generally occur if reversals in MACD (especially slower-moving combinations) are employed for buying and selling rather than crossings of signal lines. However, using changes in the direction of MACD without signal lime confirmation produces larger numbers of trades, with attendant extra expenses. You might notice in Chart 8.3 that you would have secured slightly more favorable entries and exits during the period shown if you had acted on changes in the MACD direction rather than awaiting signal line crossings, but that crossings of the signal line produced more immediately productive signals than simple changes in MACD direction. – Technical Analysis.

The only problem with this is that while one can identify this for IVs that one owns, it is often not possible to catch the IV in that time when the direction has changed.

Using MACD With Other Indicators or Scripts

It is good to try to find other indicators or scripts that help with the forecast. That way if both the MACD and indicator or script #2 or even #3 all agree with each other, then a buy or sell decision is made. This is because different indicators or scripts capture other variables that are not accounted for in the MACD.

A Critique of the MACD

Our biggest critique of the MACD is that it tends to give sell signals when the IV is stabilizing rather than declining. We only really want a sell signal when the IV is going to decline. Of course, aggressive traders will want to leave the IV even if the gains are small after a certain point. Therefore, MACD is a better fit for aggressive traders.

Conclusion

MACD is one of many moving averages that are used to create a forecast for IVs. However, MACD uses two moving averages and then they are compared to one another.

The MACD script is one of the more common technical indicators. However, it is certainly not predictive for all investment vehicles, and this means only using MACD when other conditions are met.

Anyone can use MACDs however they like, however, we use extra tests involved in how to utilize the MACD, as there is with other technical indicators. We also use MACD with other indicators that further whittle down the number of IVs that we invest in.