Portfolio Boss Documentation

MACD Filter

 

One of the most complicated indicators, MACD (Moving Average Convergence Divergence) allows you to coat-tail a trend, or, anticipate a trend change. It's the best of both worlds between moving average and momentum-oscillator indicators.

This indicator has two main components: the MACD line itself, and the Signal line. Trading signals are usually given when the MACD line crosses above or below the Signal line. Sometimes, the activity of the MACD line itself (without the Signal line) gives off trading signals: when the MACD line crosses above/below certain threshold values, or, when the MACD line and the instrument's price go in the same/opposite direction.

 

 

The MACD line is calculated by subtracting a longer Moving Average from a shorter Moving Average (the Moving Average used is usually EMA). This MACD line is then smoothed out through another EMA to produce the Signal line. In Portfolio Boss, the MACD filter does not have the histogram component (which is just another representation of the MACD line).

The use of MACD could help smooth a strategy's equity curve. Instead of major bulges and cliffs, it may rise in a generally straight line (good R² metric):

 

 

But despite its strength, just like any technical indicator, MACD may give false signals. So it's best to use it in tandem with other filters that identify a larger prevailing trend, like the Moving Average Cross Over, Rate of Change, Impulse Score Rule, or the Simple Moving Average Index filter.

Let us now dissect MACD's parameters, starting from the easiest one.

 


 

1.  Short MA Period: This defines the timeframe of the shorter EMA, which is an ingredient of the MACD line.

 

 

Let's say it's set to 12 days, which means the instrument's prices of the last 12 days (12 including today) are smoothed out (averaged) with the exponential method. The resulting number (the average value) is plotted in today's date.

The generally accepted period here is 12 days. Some technicians suggest that if you're using the daily candles (as in PB), it's best to use a period of 8 days for the Buy Filter, and 12 days for the Sell Filter.

 


 

2.  Long MA Period: This defines the period for calculating the longer EMA, which is another ingredient for the MACD line.

 

 

The resulting number (exponential average of the prices) is then plotted on today's date. This longer EMA is then subtracted from the shorter EMA, to produce the MACD line (value) for today's date.

 

 

Generally, the Long MA is given the 26 days period, though some market technicians prefer 17 days for the Buy Filter, and 25 days for the Sell Filter. Don't take these as a hard-and-fast rule, as certain filters and parameter values may prompt you to change radically the MAs periods. Sometimes the Long MA can even have a shorter period than the Short MA.

 


 

3.  Signal MA Period: This defines the EMA period for calculating the Signal line.

 

 

So let's say we set this to 9 days, then the MACD values for the last 9 days are smoothed with the 9-day EMA. Thus creating the Signal line (value) for today. This parameter is normally set to 9 days.

 

 

Note, all these MACD indicator lines as shown above can be seen from the Instrument Tab. Below the price chart, you'll see two indicators: MACD line (usually brown), and Signal line (usually red). The 12 and 26 days EMAs as overlaid on the price charts above are shown for the purpose of clarity, they're not part of the MACD Filter.

 


 

4.  Mode: This should be the first parameter you set when using the MACD filter. From here, you choose the MACD's mode (method) you want to use, like divergence, convergence, or Signal line crossover, etc.

 

 

There are four modes in PB's version of the MACD:

  • High/Low Ranges of MACD Line
  • Crossing MACD and Signal Lines
  • MACD Convergence
  • MACD Divergence

Changing the modes reveals/hides certain parameters in this filter. So we'll explore each mode in the following sections.

 


 

5.  Mode – High/Low Ranges of MACD Line: This mode lets you use MACD as a momentum oscillator (one that defines oversold and overbought conditions), much like RSI predicts a trend change or measures a trend's strength.

 

 

As shown above in the orange rectangles, there are two parameters specific to this mode: the first defines whether the MACD line should be above/below the threshold MACD value, and the second parameter defines the threshold value itself (either overbought, oversold, or equilibrium). So this mode does not employ the Signal line.

 

 

For example as a Buy Filter, if an instrument's MACD line “Rises Above” the equilibrium threshold (usually a MACD value of 0), that instrument will be considered to be bought.  Ditto if its MACD “Falls Below” the oversold threshold, it could be bought.

 

 

As a Sell Filter, you can set it to “Falls Below” a MACD value of 0, or, “Rises Above” the overbought threshold.

 

 

But keep in mind, if the MACD line stays above the overbought threshold (or stays below the oversold threshold) for an extended period, it could be a sign that the uptrend (or downtrend) is strong. You're better off following such a trend instead of positioning for the trend reversal.

 

 

Note that such overbought, oversold, and equilibrium threshold values aren't definite. You have to find them yourself to fit your strategy's portfolio. In a Nasdaq-100 index for example, the MACD line tends to oscillate within 5 and -5 threshold, but not so much the S&P 500 index, which tends to be less volatile. This second parameter, which defines the threshold value, can be set from -100 to 100.

 

 

Our experiments with this mode showed that you're much better off with the equilibrium point (0) instead of the overbought & oversold areas. For a Buy Filter, set the first parameter to “Rises Above”; and “Falls Below” for the Sell Filter. The Buy Filter tends to perform well when used with small EMA periods, like 4-day, 6-day, and 26-day periods for the Short MA, Long MA, and Signal MA, respectively. Bigger EMA periods are good for the Sell Filter, like 28-day, 80-day, and 76-day. But of course, these depend on your strategy's portfolio, and other rules/filters used (along with their parameters' values); so anything can change radically.

 


 

6.  Mode – Crossing MACD and Signal Lines: This mode is the standard method when using MACD. So instruments are considered to be bought/sold when the MACD line crosses above/below the Signal line.

 

 

There's only one parameter specific to this mode (orange box above), which defines whether the MACD line should “rise above” or “fall below” the Signal line, for the instruments to be considered. The common wisdom says that when the MACD line crosses above the Signal line, it's a bullish signal (Buy Filter); and vice versa, when the MACD line crosses below the Signal line it's a bearish signal (Sell Filter).

 

 

If you see the instruments' price chart individually, short term price actions more or less conform with this conventional wisdom. But Portfolio Boss does not deal with short term testing. Given enough time, which spans decades of market turbulence, such conventional wisdoms may be detrimental to a strategy's equity curve. In fact, our testing proves that going opposite the MACD norm boosts your CAGR; that is, buy when MACD crosses below the Signal line, and sell when it crosses above.

 

 

But as said before, everything could be turned upside down again given different portfolios, rules & filters, and parameters' values. Take everything with a grain of salt, especially technical indicator values and wisdom. You must discover them through your own trial and error.

 


 

7.  Mode – MACD Divergence: This mode “predicts” short term trend reversal by identifying divergence between the MACD line and the instrument's price.

 

 

So during a specified period, if price increases while the MACD line decreases, it's generally construed as a bearish divergence, thus the current uptrend may soon change. And if price decreases while the MACD line increases, it's usually taken as a bullish divergence, and the current downtrend may soon reverse.

As you see in the screenshot above, there are two parameters specific to this mode (shown in the orange rectangles). The first parameter defines the period for comparing the change in price (also the change in MACD line). Let's say this parameter is set to 3 days: if the closing price Friday (today) is $15 and the closing price Wednesday was $20, then we have a price decrease, regardless of what happens in Thursday. Now, if the MACD line today is 3, while Wednesday it was 1, then the MACD increased. Since the price decreased while MACD increased, we have a divergence, and a trading signal given.

 

 

Generally it's a good idea to set a short period here, like 3 or 4 days.

Unlike the usual MACD where divergence is seen from rising/falling peaks and troughs (between price and MACD), this filter simply sees the change between the start of the period and today, no peaks and troughs involved. But it's still possible if you use a longer period in this first parameter. The idea is still the same, essentially.

The second parameter (for this mode) defines the type of divergence; either it's the price going up and MACD going down, or, price going down and MACD going up.

 

 

Based on conventional wisdom, “Price Down and MACD Up” is supposed to be bullish (Buy Filter), while “Price Up and MACD Down” is supposed to be bearish (Sell Filter). But this is not always the case, as our tests (once again) prove that the opposite are true.

 

 

As well, this MACD Divergence may require different moving average periods than the usual 12, 26, and 9 days. Try and see which ones work best for you.

 


 

8.  Mode – MACD Convergence: The mechanism here is similar to the previous mode, but instead of diverging, the price and MACD line must converge. That is, they must both be going in the same direction before a signal is given.

 

 

There are two parameters specific to this mode (as shown in the orange rectangles above):

  • The first parameter defines the period for calculating the change (in price and in MACD); and it's usually good to set this at a short period, like 3 days.
  • The second parameter defines the convergence type: either price and MACD must both go down, or, price and MACD must both go up.

 

 

The type “Price Down and MACD Down” is generally good as a Buy Filter, whereas “Price Up and MACD Up” is likely good for a Sell Filter.

 

 

As with MACD Divergence, you may want to tweak the Short MA, Long MA, and Signal MA periods away from the norm. And the Buy Filter may need different periods than the Sell Filter.

 

 


 

Note:

You can stack multiple MACD filters, each with different settings (especially as Buy Filters). This is good so you can constraint the buying criteria with multiple different MACD modes (methods). Let's say one filter is used for predicting short-term trend change, another for confirming the strength of the greater prevailing trend, etc.

 

 

 

Back to Top

>