# Moving Average Convergence-Divergence (MACD) Trading Strategy (Stand Alone)

**Introduction: Common MACD Computation and Presentation
**

Moving average convergence-divergence (MACD) is a technical indicator that shows the convergence and divergence of two different periods moving averages. We can say that two moving averages are diverging if their difference are increasing, and converging if their difference is decreasing. There are some difference and variations between MACD implementation and presentation, but one of the common [1] is shown in the Figure 1.

The bottom chart show MACD chart which consists of MACD line (blue), MACD signal line (red), and MACD histogram (gray). The histogram term here has nothing to do with the statistical histogram term, it’s just a histogram-like bar plotting of some time-series values. The upper chart is the candlesticks chart of the data with fast (purple) and slow (black) EMA (exponential moving average) added to show the underlying components of the MACD analysis. Here is how to compute the MACD indicator from the data:

- MACD line = EMA(data,fast_period) – EMA(data,slow_period);
- MACD signal line = EMA(MACD_line, signal_period);
- Histogram = MACD_line – MACD_signal_line;

The MACD in the Figure 1 uses fast_period = 12, slow_period = 26, and signal_period = 9, and those setting is referenced as MACD(12,26,9).

**MetaTrader Version of MACD**

The popular platform MetaTrader has different method for computing and presenting the MACD indicator [2]. The presentation consist only MACD bar (histogram-like) and signal line, like shown in the Figure 2.

Here is how to compute MACD in MetaTrader version:

- MACD bar = EMA(data,fast_period) – EMA(data,slow_period);
- MACD signal line = SMA(MACD_bar, signal_period);

In the MetaTrader version, the MACD is directly presented as the bar, and the signal line is computed using simple moving average rather than exponential moving average. The simplification of removing the previous histogram simplify the analysis as well. Next discussion in this article will be focused in this MACD version.

**First MACD Indicator Interpretation: Up/Down Trend Identification
**

What behavior is actually figured out by MACD indicator? To answer this question, we can think back to the underlying components: the fast and slow moving average. Moving average is a filtered version of price movement. For dynamically changing data, the slower/longer period moving average gives smother changes, less sensitive to fast changing price action. The opposite behavior applies with faster/shorter period moving average, more sensitive to fast changing movement. When the price is trending up, the fast moving average always get higher values because it adapts to new price more quickly, so the MACD (fast EMA – slow EMA) value will be positive. Conversely, in a down trend situation, the faster EMA will be lower than the slower EMA, so the MACD value will be negative. By looking at the sign of MACD values, whether it is positive or negative, we can get the indication of up trend or down trend.

**Second MACD Indicator Interpretation: Trend Reversal Detection**

Imagine that at some point of time the price gets being constant on its peak value (overbought) for several periods, the fast EMA will stuck on the last value, and the slow EMA will slowly catch up the fast EMA, and their difference is decreasing down to zero as the both moving averages converging to the same value. This convergence is indicated directly by the decreasing of the MACD absolute value (the bar) towards zero. In reality, the price is always dynamically changing and it is almost impossible to get the same values for several days or even for any periods. In effect, the MACD values is almost always crossing the zero rather than getting stuck on it. Because the positive values of MACD indicate an up-trend and the negative values indicate a down-trend, the zero-crossing of the MACD either from positive to negative or vice versa can be used to detect a trend reversal to produce buy or sell signal.

**MACD Signal Line: Filtered MACD to Avoid False Signal**

Using MACD zero crossing to directly detect trend reversal sometimes gives a false signal, when the MACD bar crosses back the zero level in a short period after previous cross. To avoid this false signal, some trader might use various confirmation methods. Some trader just wait for several following candlestick pattern, but using the MACD signal line zero crossing rather than directly using the MACD bar cross is the simpler way to get more reliable signal. All confirmation methods provide false signal protection but always produce missing potential profit when there’s no false signal. The MetaTrader’s version of MACD uses simple method for the averaging (SMA, simple moving average) rather than the exponential one (as seen in the previously described more common MACD) so the delay of the zero crossing event will be longer, but it can always be adjusted by changing the averaging period of the signal line.

**MACD (Bar) Level Interpretation: The Momentum or The Strength of The Movement
**

While the sign of the MACD bar indicate the trend direction, then what is the bar level related to? When the price is constant for long period (much longer than the period of the slow EMA), the fast and slow moving average will stay at the same value and the MACD will stay at zero (which is almost impossible in the reality). Now imagine if the price is moving up at constant rate then the fast and slow moving average will differ at a constant level, which is proportional to the rate of the price change. This is what we can figure out what MACD level represent: the rate of the price change, the strength of the trend, or the momentum. The momentum term come from physics theory, which is then associated with the velocity or the rate of the price change. Using the momentum theory of the physics, in some situation (for example when the price is far from a support/resistance level), it is believed that the higher the momentum (the velocity) of a price movement the harder the force to stop it.

**MACD Bar – MACD Signal Line Cross: Trading on Price Movement Acceleration**

As described in the previous section, the price movement has velocity, i.e. the rate of the price change. If the price moves with a constant positive velocity, then we will see a linear ramp up in the price level. In reality, the velocity of the movement is rarely constant, and we often see that the movement is not close to a linear ramp but is closer to an exponential ramp. It means that the velocity is not constant but is changing. That’s why the MACD almost never has constant values, it changes as the velocity changes. It is said that the price is moving in acceleration, and the acceleration value is the rate of the velocity change. Mathematically, an acceleration is the first derivative of velocity, which can be practically computed by subtracting the signal with the delayed version of the same signal. Let’s take a look back at one of the output of MACD, the signal line, which in the previous discussion is directly used as the buy/sell signal on zero-crossing. This filtered output (by simple moving averaging) can be seen as the delayed version of the original MACD (the bar in MetaTrader version). If the MACD and its delayed version is differentiated, then the result is the numerically computed derivative of MACD, which represent the acceleration of the price movement since the MACD represent the velocity (momentum) of the price movement. Take look back at Figure 1 (the more common MACD version), the acceleration is represented by the MACD histogram. Unlike in that version, the MetaTrader version of MACD (Figure 2) has no such MACD histogram, but the concept of acceleration is applicable in the analysis when we use the crossover between MACD and its signal line as the trading rule as stated in the following excerpt from the reference [2]:

The basic MACD trading rule is to sell when the MACD falls below its signal line. Similarly, a buy signal occurs when the Moving Average Convergence/Divergence rises above its signal line.

This rule means that we sell an instrument when its price movement change from acceleration to deceleration (negative acceleration), and buy an instrument if its price movement change from deceleration to acceleration.

**Getting The Right Parameters For MACD**

The default parameters for MetaTrader version of MACD are 12 for fast EMA period, 26 for slow EMA period, and 9 for SMA signal period. This default values is historically selected based on the market condition at the time MACD is formulated, in the days when there’s no charting software or internet connection (the trading deals is done via telephone call), and the analysis is done manually in the paper at daily closing time. In those old days, the trading days is open for 6 days per week, so the (12,26,9) MACD parameters is then related to 2 week, 1 month, and 1.5 week. Even when the modern trading day has shifted to 5 days per week, the pattern of the price in the market is not automatically follows. It has valid theoretical reasoning that the more trader are using a specific parameters combination, the more reaction of the market would validate the prediction (with the specified parameter combination). With this reasoning, it makes sense that the jargon “History repeat itself” is reasonable but always keep in mind that everything is changing, even though it works through a slow evolution. I think the best parameters combination should be selected based on the recent historical data (about two recent years for daily chart), and this can be easily done in MetaTrader client terminal application with its back-testing and optimization tool.

**Using MACD as A Stand Alone Trading System**

Although MACD analysis can be combined with other indicators to build a trading system, the MACD itself can be used as a stand-alone trading system without other analysis. Using the basic interpretation discussed here, a stand alone trading system (a set of trading rules) can be constructed, using zero crossing of the signal line for example:

- If there is no opened (floating) position then open buy if the signal is above zero and open sell if the signal line is below zero.
- If the signal line crosses the zero from positive to negative then switch the floating position to sell (by closing the buy position and opening the sell position).
- If the signal line crosses the zero from negative to positive then switch the floating position to buy (by closing the sell position and opening the buy position).

Another example, a stand-alone trading system using MACD bar – signal line crossover can be constructed as the following:

- If there is no opened (floating) position then open buy if the MACD bar is above the signal line and open sell if the MACD bar line is below the signal line.
- If the MACD bar falls below the signal line then switch the floating position to sell (by closing the buy position and opening the sell position).
- If the signal line falls below the MACD bar then switch the floating position to buy (by closing the sell position and opening the buy position).

**Managing The Risk in MACD Trading System**

Based on the fact that we get when we use MACD on historical data, we can see that the MACD signal give some period of profits and losses so we have to be careful in anticipating the risk. If we look at the EUR/USD example in the figure 2, the price ranges from about 1.05 to 1.25, so the price movement is around 20% for about 10 months. That means that if we only open one position and hold it for about 10 month we will get about 20% profit or loss (depends on the opening position). With a daily analysis to actively analyze the price and switch the position accordingly, we can expect the return is greater than the total range since we can get the profit both in up trend and down trend periods. As the stand-alone MACD signal doesn’t work with stop-loss as their part of the analysis and the exit strategy, it is recommended that the trading is done without leverage. In a broker with leverage, it can be done by adjusting the transaction size to an equal lot of the balance or equity, for example, only open a maximum 1 lot when the equity is 100k (standard lot size). Although this trading strategy doesn’t work with stop-loss as a normal exit strategy, it is recommended to place a large stop-loss to anticipate a market crash. The stop loss level can be selected based on the acceptable maximum percentage of total capital loss of the trading account. The decision of using leverage or not, or how much leverage that will be used in this trading strategy should be decided by the trader

**Realtime MACD Analysis, Signal, and Trading Simulation**

We are building realtime automated system (in progress) for analysis, simulation, and optimization of MACD trading system, we will update with result and the presentation link in this page once it’s available.

**References**