<s> Stocks & Commodities V. 9:10 (391-395): The Macd Indicator Revisited by John F. Ehlers
The MACD Indicator Revisitedby John F. Ehlers
T
he moving average convergence-divergence (or M ACD, as it is familiarly known), one of the more
popular technical indicators, was invented by technician Gerald Appel to trade the 26-week and 13-weekcycles of the stock market. Commodity traders often use daily data with MACD but still use 26-period and13-period exponential moving averages (EMA) in the analysis. The implication is that there are 26- and13-day cycles in commodity markets. Beliefs such as this (for example, that only a 14-day relativestrength index is correct) incite my curiosity enough to make me do some research. The basic premise bywhich I work is that the market is always changing and your trading strategy and indicator parametersmust change to fit the current market conditions. Specifically, I have studied the Standard & Poor's 500and have found an unusual combination of MACD parameters that produces good profits a surprisinglyhigh percentage of the time. This unique use of the MACD indicator can be applied to almost any marketat one time or another.THE TRADITIONAL MACDA 26-day EMA is the first moving average and a 13-day EMA is the second moving average in atraditional MACD. The MACD line is formed by subtracting the long (first) moving average from the short(second) moving average. A signal line is formed by smoothing the MACD line with a third EMA. Thethird moving average is usually a 10-day EMA. For the sake of simplicity, causing only a small amountof distortion, I use the third EMA to be equal in length to the second EMA.
Article Text
Copyright (c) Technical Analysis Inc.
1
Stocks & Commodities V. 9:10 (391-395): The Macd Indicator Revisited by John F. Ehlers
I studied the Standard & Poor's 500 and found an unusualcombination of MACD parameters that produces good profits asurprisingly high percentage of the time.The classic MACD of the Standard & Poor's 500 index shown in Figure 1 is for about the first four monthsof 1991. MACD and its signal are shown below the bar chart. The signal is the smoother of the two lines.It's clear that MACD goes up when prices rise and MACD goes down when prices fall. Some time lag existsbetween the peak of the prices and the peak of the MACD; buy/sell signals are formed when the MACDcrosses its signal and are indicated by the up and down arrows at the bottom of the bar chart. Used in thisway, the M ACD nicely caught the uptrend in the January/February time frame.MACD can also be used as an overbought/oversold indicator. Successive highest highs (or lowest lows) ofprice are compared with successive highest highs (or lowest lows) of MACD. In Figure 1 the successivehighest highs of price trend up in the February-April time frame while the successive highest highs ofMACD trend down. This is a divergence. This divergence is often interpreted as an overbought condition.CRUEL ABANDONMENTThe first thing I do when modifying MACD is to abandon the convergence/divergence concept.Divergence is difficult to program on a computer without fuzzy logic or neural networks. Second, I adaptthe moving average parameters to the measured or assumed cycles in the data. With reference to Figure 1,the period between successive highs or successive lows is approximately 12 days for the period betweenmid-February and the end of April.When we set the first MACD EMA to the length of the cycle and the second EMA to the length of the halfcycle, the buy/sell signals of Figure 2 result. Recall that the signal line uses the same parameters as thesecond EMA of the MACD line. In general, this combination of parameters gives an entry signal slightlyafter the crest or valley of each cycle. We can use cycle theory to see why.A cycle is a process in which a point under observation moves through a given pattern and eventuallyreturns to its original starting place. Think, if you will, of the automobile engine crankshaft. Now picturean arrow connected to the crankshaft. The arrow is called a "phasor," which forms an angle relative to itsstarting position as the engine turns. The angle is known as the phase angle and varies from zero to 360degrees. The tip of the arrow points to the fraction of the cycle completed along the circumference of acircle.
The first thing I do when modifying MACD is to abandon theconvergence/divergence concept.
A
definite relationship exists between the phase angle and a sine wave in the time domain. Picture a
flashlight shining on the arrow from the side in Figure 3 so the arrow casts a shadow in the vertical plane.The length of the shadow traces out the sine wave amplitude as time progresses. A cycle is completewhen the arrow has made one full rotation and the sine wave returns to its original zero value and rate ofchange. The amplitude of the sine wave is proportional to the length of the arrow.
Article Text
Copyright (c) Technical Analysis Inc.
2
Stocks & Commodities V. 9:10 (391-395): The Macd Indicator Revisited by John F. Ehlers
FIGURE 1: The MACD line is the difference between the 26- and the 13-day EMAs. The result issmoothed a second time with a 13-day EMA. This second smoothing is the signal line. With this, itbecomes clear that the MACD line rises and falls with the market. Buy and sell signals occur when theMACD line crosses the signal line.
Figures
Copyright (c) Technical Analysis Inc.
Stocks & Commodities V. 9:10 (391-395): The Macd Indicator Revisited by John F. Ehlers
FIGURE 2: Between each successive high and low during mid-February and the end of April, there areapproximately 12 trading days. Using 12 and six (the half cycle) as the constants for the EMAsmoothing produces signals that occur slightly after the crest and valley of each cycle.
FIGURE 3: Imagine a point on a circle tracing out a line as the point travels around the circle. When thepoint has completed one full trip around the circle, a completed cycle (sine wave) will be traced in thetime domain.
Stocks & Commodities V. 9:10 (391-395): The Macd Indicator Revisited by John F. Ehlers
Moving averages have two effects on cycles. Moving averages introduce time (and therefore, phase) lagand they attenuate (that is, reduce amplitude) of the higher-frequency components. My research shows afull-cycle EMA introduces about 72 degrees of phase lag and attenuates the cycle to approximately 31 %of its unaveraged amplitude. A half-cycle EMA introduces about 54 degrees of phase lag and attenuatesthe cycle to approximately 57% of its unaveraged amplitude. The phasors for these two EMAs are shownin Figure 4. (See sidebar, "Exponential moving averages.")When we calculate MACD, we subtract the longer EMA from the shorter EMA. This is done on the phasordiagram by reversing the direction of the longer EMA (thus changing its sign) and then performing avector addition. The resulting vector lags the original price function about 35 degrees, as shown in Figure5. I call this the result of the detrended synthetic price because taking the difference of the two EMAsremoves the very low frequency trend components, and the outcome is closely related to the price inphase. Remember, the signal line is delayed another 54 degrees from the M ACD because the smoothing isdone with the second EMA. The MACD crosses the signal approximately at half the phase lag, or 27degrees. As a result, the buy/sell indication occurs at 35+27=62 degrees after the price crests and bottomsat the cycle. Of the 12-day cycle, 62 degrees corresponds to about two days' lag. Since we can't actuallybuy or sell until the day after we get the signal, the actual entry is delayed about 90 degrees from the pricecrest or valley.We're in trouble with this approach. If we have a 90-degree lag in entry of the position, we necessarilywill have a 90-degree lag in exiting the position. As a result, the best we can do theoretically (beforecommission) is to break even. Such methodology invalidates technical analysis and throws us into thearms of lady luck. Personally, I'm not very lucky. There has to be a better way.INVERSE PERVERSIONSOne way to adapt to the market is to obtain an overview of market conditions in recent history. I do thisfor MACD in my 3D program by plotting the two EMAs as the independent X and Y coordinates andprofit in the Z dimension as the dependent variable. When profit is calculated for all combinations of theindependent EMAs, a three-dimensional surface of profitability results (Figure 6).Figure 6 is interesting from several perspectives. First, the surface is relatively smooth, so this means theprofitability is relatively insensitive to variations in the EMA parameters. The implication is that MACD isrobust, and minor variations in market conditions will not severely affect profitability for trading in theimmediate future for the selected EMAs. The second interesting aspect of Figure 6 is that the maximumprofit occurs in the "inverse" domain where the first EMA is smaller than the second EMA.
Cycle analysis has helped provide a rationale as to why inverseMACD parameters produce profitable trading results in somemarket conditions.Figure 7 shows the trades formed in the February through April time frame using the inverse parametercombination. In this case, the buy/sell signals are almost always early relative to the cyclic highs andlows. The early signals allow us to accommodate the necessary one-day lag in making an entry after thesignal has been received. However, M ACD cannot be applied universally this way. For example, note theJanuary sell signal (second bar from the left edge of the chart) is dead wrong. As calculated, this 4/12-day
Article Text
Copyright (c) Technical Analysis Inc.
3
Stocks & Commodities V. 9:10 (391-395): The Macd Indicator Revisited by John F. Ehlers
FIGURE 4: Moving averages introduce time (phase) lag and reduce amplitude of higher-frequencycomponents. Full-cycle EMAs introduce about 72 degrees of phase lag and compress cycle to about31% of unaveraged amplitude; a half-cycle introduces about 54 degrees of lag and reduces cyclesabout 57% of the unaveraged amplitude.
FIGURE 5: By reversing the direction of the longer EMA and then performing vector addition, theresulting vector lags the original price function about 35 degrees. This vector can be thought of as thedetrended synthetic price because it is near the price in phase.
Stocks & Commodities V. 9:10 (391-395): The Macd Indicator Revisited by John F. Ehlers
FIGURE 6: Plotting the two EMAs as the independent X and Y coordinates and the profit in the Zdimension as the dependent variable produces this three-dimensional graph. The maximum profitoccurs when the first EMA is shorter than the second EMA.
Stocks & Commodities V. 9:10 (391-395): The Macd Indicator Revisited by John F. Ehlers
FIGURE 7: Using the four- and 12-day parameters produce early signals relative to the cyclic highs andlows. Note that in early January the sell signal was dead wrong. This underscores the important pointthat this particular set of parameters is only valid in the near past.
Stocks & Commodities V. 9:10 (391-395): The Macd Indicator Revisited by John F. Ehlers
FIGURE 8: The four-day EMA attenuates a 12-day cycle to about 80% of its unaveraged amplitude andintroduces a phase lag of about 40 degrees. The 12-day EMA attenuates the 12-day cycle to about31% of the full amplitude and introduces a 72-degree phase lag. Performing vector addition afterinverting the four-day EMA results in the new vector (M ACD line) that lags the price by 203 degrees.Viewed another way, the resulting M ACD leads the next cycle by 157 degrees.
Stocks & Commodities V. 9:10 (391-395): The Macd Indicator Revisited by John F. Ehlers
EMA parameter set is valid only in the immediate past relative to the right-hand side of the bar chart.Note, also, that the MACD is somewhat out of phase with the cyclic component of price (Figure 7). Whenthe price reaches a peak, the MACD is at a valley, and vice versa. The signal is relatively smooth becauseit is now being calculated using the longer EMA. We need to return to phasor analysis to fully understandwhy this set of MACD parameters has given good entry signals.
T
he first four-day EMA attenuates a 12-day cycle to about 80% of its unaveraged amplitude and
introduces a phase lag of about 40 degrees. The second 12-day EMA attenuates the 12-day cycle to about31% of full amplitude and introduces a 72-degree phase lag (Figure 8). When we invert the first(four-day) EMA and perform the vector addition, we see that the resulting MACD lags the price functionby 203 degrees. Viewed another way, the resulting M ACD leads the next cycle by 157 degrees(203+157=360 degrees). The MACD signal is attenuated to 31% of the MACD value and is delayed by 72degrees. Thus, the buy/sell signals lag the MACD by about 90 degrees; so the buy/sell signals lead the nextcycle by about 67 degrees (157-90=67). This extra lead is just about right to compensate for the one-daylag in making the entry after we get the signal.OVERALL, WE CONCLUDEAlthough somewhat complex, cycle analysis has helped provide a rationale as to why inverse MACDparameters can produce profitable trading results in some market conditions.When an overview perspective is taken, new twists on such old familiar indicators as MACD can befound. More important to your trading, you can look at several indicators in the same market to find theone that is the most robust and least sensitive to market variations. You can formulate your tradingstrategy in such a manner. You will tend to use trend-following indicators such as M ACD and doublemoving averages in trending markets and oscillators such as RSI and stochastics in sideways markets.Parabolic stop and reverse (SAR) is applicable to many market conditions, depending on the value ofacceleration factor you use. You can find unusual parameter combinations for all these indicators whenyou view the profits from an overview perspective in three dimensions.John Ehlers, Box 1801, Goleta, CA 93116, (805) 969-6478, is an electrical engineer working inelectronic research and development and has been a private trader since 1978. He is a pioneer inintroducing maximum entropy spectrum analysis to technical trading through his MESA computerprogram.
REFERENCESAppel, Gerald. The Major Trend Power Index , Scientific Investment Systems, Inc., 62 Wellesley StreetWest, Toronto, Ontario, Canada.Ehlers, John F. [1991]. "Computing cycle entries," S TOCKS & COMMODITIES, July.___ [1990]. "Early trend identification," Technical Analysis of STOCKS & COMMODITIES, Volume 8: October.___ [1988]. "Moving averages, part 2: ELI," Technical Analysis of STOCKS & COMMODITIES, Volume 6: July.___ [1991]. "Using a constant false alarm rate in trading," STOCKS & COMMODITIES, April.Hartle, Thom [1991] . "Exponential moving averages," page 46, STOCKS & COMMODITIES, January.
References
Copyright (c) Technical Analysis Inc.
4
Stocks & Commodities V. 9:10 (391-395): The Macd Indicator Revisited by John F. Ehlers
Granger, C.W.J., and Paul Newbold [1986]. Forecasting Economic Time Series , second edition,Academic Press, Inc.Hutson, Jack K. [1984] . "Filter price data: moving averages vs. exponential moving averages,"Technical Analysis of Stocks & Commodities, Volume 2: May/June.
Figures
Copyright (c) Technical Analysis Inc.
5
<|end|>