MACD and Bollinger Bands Strategy – Rules, Setup, Backtest
There are some indicators you can easily combine to get the best out of the market. The moving average convergence divergence (MACD) and Bollinger Bands combination is one of the best synergic indicator combinations. You can use it to trade both a range-bound market and a trending market, depending on how you use them. Ever thought of a MACD and Bollinger Bands strategy?
The MACD and Bollinger Bands strategy refers to a trading method that makes use of both indicators in analyzing and trading the markets. While the MACD indicator is a momentum oscillator that is primarily used to analyze trends, Bollinger Bands is a volatility channel indicator that helps determine whether prices are high or low on a relative basis. The combination of MACD and Bollinger Bands may offer more insight into the current market and help predict how it could move in the future.
Related reading: – Different types of valid trading systems
In this post, we take a look at the MACD and Bollinger Bands strategy and include a backtest with specific and testable trading rules.
What is the Bollinger Bands indicator?
Developed by John Bollinger in the 1980s, Bollinger Bands is a volatility channel indicator that can also be used to determine whether prices are high or low on a relative basis. The indicator consists of three lines: a middle line, which is a 20-period (default setting) moving average, and an upper and a lower band, each of which is 2 standard deviations away from the middle line.
Bollinger Bands form a channel or an envelope around the price action, and the channel contracts or expands, depending on the level of volatility in the market (often resulting in a Bollinger Band squeeze). The indicator can be used to trade both trend-following and swing-based strategies.
How the Bollinger Bands indicator is calculated
Bollinger Bands are simple to calculate. These are the steps:
- Calculate and plot a 20-period moving average for the middle line. You can change the period to anything you want that suits the market you are trading.
- Calculate the standard deviation of the moving average
- Plot a band 2 standard deviations above the moving average and another 2 standard deviations below
How the Bollinger Bands indicator is interpreted
Here are the common interpretations of the Bollinger Bands indicator:
- The upper and lower bands may indicate an extended price action: Prices have a tendency to bounce from the upper and lower bands, touching one band and then moving to the other band, which is why the indicator is commonly used in mean-reversion strategies. Also, you can use these swings to help identify potential profit targets even when trading other strategies. With a mean-reversion strategy, either the middle line or the other band can be your target — if a price bounces off the lower band and then crosses above the moving average, the upper band then becomes the profit target.
- Tightening of the bands indicates low volatility: When the bands tighten during a period of low volatility, it raises the likelihood of a sharp price move in either direction. This may begin a trending move, but you should watch out for a false move in the opposite direction which reverses before the proper trend begins.
- Expansion of the bands shows increasing volatility: When the bands expand by an unusually large amount, volatility increases and any existing trend may be ending.
- Breakout may indicate a trending move: A strong trend continuation can be expected when the price moves out of the bands. However, if prices move immediately back inside the band, then the suggested strength is negated.
As always, we recommend backtesting any strategy or idea you might have: make very specific trading rules, code them, and then backtest.
What is MACD?
Often called MAC-D by those who use it, MACD is the short form for Moving Average Convergence/Divergence.
It is a momentum indicator that is mostly used to trade trends. It is based on two exponential moving averages (EMAs) — a 26-period EMA and a 12-period EMA.
On the chart’s indicator window, it appears as two lines — the MACD line and the signal line — that fluctuate up and down about the centerline (zero line) without any upper or lower limit.
The indicator is actually an oscillator, as it oscillates above and below the zero line. But despite being an oscillator, it is not commonly used to determine overbought or oversold conditions.
How the MACD indicator is calculated
The MACD indicator consists of two lines: the MACD line and the signal line. The MACD values (which are plotted as the MACD line) are calculated by subtracting the value of a 26-period EMA from a 12-period EMA, while the signal line is gotten by calculating a 9-period EMA of the MACD values. You can, of course, use any number of days you want as settings.
As the 12-period EMA is constantly converging toward, and diverging away from, the 26-period EMA, the MACD values are converging toward, and diverging away from, zero.
In essence, the MACD line oscillates above and below the zero level. The signal line, which is a 9-period EMA of the MACD line, oscillates around the MACD line. Sometimes, the MACD line (or in some cases, the difference between the MACD line and the signal line) is plotted as a histogram.
How MACD is interpreted
Here are the common interpretations of the MACD indicator:
- The MACD line rising above zero is considered bullish, while falling below zero is bearish. That is, when MACD turns up from below zero it is considered bullish, and when it turns down from above zero it is considered bearish.
- The MACD line crossing from below to above the signal line is considered bullish — the further below the zero line the earlier the signal. Conversely, the MACD line crossing from above to below the signal line is considered a bearish signal, and the further above the zero line, the earlier the signal.
- A divergence signal occurs when the MACD line and the price swing are not in sync, with either making a higher high or lower low when the other is not making the same.
Note that in a range-bound market, the indicator will whipsaw, with the MACD line crossing back and forth across the signal line. It may be best to avoid using the indicator in this situation or even avoid trading at all until the market direction is clear.
What is MACD Bollinger Bands strategy?
The MACD and Bollinger Bands strategy refers to a trading method that makes use of both indicators in analyzing and trading the markets. The combination of MACD and Bollinger Bands may offer more insight into the current market and help predict how it could move in the future.
While the MACD indicator is a momentum oscillator that is primarily used to analyze trends, Bollinger Bands is a volatility channel indicator that helps determine whether prices are high or low on a relative basis. As such, you can combine both to get a suitable strategy, which can be a trend-following strategy or a mean-reversion strategy.
MACD Bollinger Bands trend strategy
This is a trend-following strategy that combines the MACD indicator and the Bollinger Bands. Since the MACD can be used to show the momentum of a trend and the Bollinger Bands can show price breakouts, we can combine both to gauge the momentum of the market when the price is breaking out of the Bollinger Bands. So, the strategy goes like this:
- A buy signal forms if the price break above the upper band and the MACD line crosses above the signal line and is rising.
- A sell signal forms if the price break below the lower band and the MACD line crosses below the signal line and is descending.
MACD Bollinger Bands mean-reversion strategy
A mean-reversion strategy aims to enter a trade when the price seems overextended in one direction. The upper and lower bands of the Bollinger indicator are used to gauge price extension from the mean. Remember the middle band is a moving average, while the upper and lower bands are 2 standard deviations (SD) away from it.
So, the price getting beyond any of those outer bands shows it has moved 2 SDs away from the mean, and there is a 95% chance it may reverse. When you combine this with the traditional MACD signal or MACD divergence, it increases the odds of success.
A mean-reversion strategy that combines the MACD and Bollinger Bands goes like this:
- A long signal is formed if the price reaches the lower band and reverses while the MACD makes a bullish divergence.
- A short signal is formed if the price reaches the upper band and reverses while the MACD makes a bearish divergence.
How do you use MACD with Bollinger Bands?
From our explanation of the two indicators, both of them can be used to trade a trending market and a range-bound market. The MACD indicator is a momentum oscillator that is primarily used to analyze trends, while Bollinger Bands is a volatility channel indicator that helps determine whether prices are high or low on a relative basis. So, you can combine both to get the best of both worlds.
From what we explained above, you can use the Bollinger Bands to know when the price seems overextended from the mean, especially if you want to trade a mean-reversion strategy. In that case, you can use the MACD signal (MACD line crossing above or below the Signal line) to know when the price is ready to reverse from its current direction.
On the other hand, when the Bollinger Bands constrict and the price later breaks out of any direction, indicating the emergence of a potential trend, you can confirm that breakout with the MACD indicator. The MACD should be seen to move in that direction with a clear signal. In an upward breakout, the MACD line should cross above the signal line and be rising toward or even above the zero level. For a downward breakout, the MACD line should cross below the signal line and be descending toward or even below the zero level.
Which is better — Bollinger Bands or MACD?
Both MACD and Bollinger Bands are pretty decent indicators that can be used to create winning strategies on their own. They both work very well, depending on how you use them. To know which one is more accurate, you will need to backtest them.
However, even if backtesting shows that one tends to give better signals than the other based on the parameters you use and the markets you test, it does not mean that the other cannot perform better in a different scenario with different parameters or markets.
Experienced traders apply these indicators to their trading strategies in different ways. So, when it comes to comparing MACD and Bollinger Bands to find out which one is better, it all depends on the trading scenarios in which one performs better than the other and generates more accurate results.
The focus shouldn’t be on which is better, but rather, on creating profitable trading strategies with each indicator or a combination of both.
MACD and Bollinger Bands strategy examples
You can use the two indicators in different ways to create different strategies, but the two common strategies we mentioned in this post are the trend-following strategy and the mean reversion strategy. Let’s take a look at the examples of both strategies.
MACD & Bollinger Bands trend strategy example
Take a look at the S&P 500 e-mini futures chart below. It shows a downward breakout, indicating a sell signal:
From the chart above, you can see that when the price broke below the lower channel, the MACD line was already descending below the signal line and even crossed below the zero line. Notice that there was an extended period of low volatility (constricted bands) before the downward breakout.
MACD & Bollinger Bands mean-reversion strategy example
Take a look at the S&P e-mini futures chart below:
From the chart, you can see multiple signals, both long and short, as the price swings from one band to the other. The first one was a short signal when the price hit the upper band, and the MACD showed a hidden bearish divergence.
The next signal was a long signal when the price retested the lower band after leaving it for some time. The next reversal from the upper band was a short signal too (though it wasn’t labeled, you can spot a hidden bearish divergence in MACD). After that, came a long signal, and finally, the latest short signal is still playing out.
MACD and Bollinger Bands strategy backtest
Let’s end the article with a backtest of a specific trading strategy with quantifiable trading rules. The strategy is, of course, based on both the MACD and Bollinger Band indicators (we are using MACD Histogram).
We make the following trading rules:
- Make a 10-day-Bollinger Band of the MACD Histogram using two standard deviations.
- We enter a long position when the MACD Histogram crosses below the lower Bollinger Band.
- We sell the long position when the MACD Histogram crosses above the upper Bollinger Band
We get the following equity curve when we backtest S&P 500 (SPY):
It’s a pretty erratic ride, and the max drawdown is rather high at 44% – probably too high for most traders and leads to abandonment of the strategy. There are only 130 trades, the gain per trade is a solid 2.1%, and the win ratio is 70%.
FAQ:
What is the MACD Bollinger Bands trend strategy?
The MACD Bollinger Bands trend strategy is a trend-following strategy. A buy signal occurs when the price breaks above the upper band, and the MACD line crosses above the signal line and is rising. A sell signal occurs when the price breaks below the lower band, and the MACD line crosses below the signal line and is descending.
How do you use MACD with Bollinger Bands?
MACD and Bollinger Bands can be used together for comprehensive market analysis. Combining the overextension signals from Bollinger Bands with MACD signals can provide insights into potential trend reversals and breakouts, enhancing overall trading strategy.
How can I backtest the MACD and Bollinger Bands strategy?
Backtesting involves creating specific trading rules based on MACD and Bollinger Bands indicators, coding them, and testing against historical data. Backtesting results provide insights into strategy performance, including trade frequency, gain per trade, and maximum drawdown.