avatarMichael Hsia

Summary

The article presents an advanced MACD momentum trading strategy, exploring the integration of secondary indicators to enhance signal accuracy and trading performance.

Abstract

The author, a beginner in automated and quant trading, seeks a practical entry-level strategy to automate and refine their trading skills. After considering various factors such as profit expectations, risk tolerance, and trading frequency, the MACD strategy is chosen as the foundational approach. The article delves into the MACD indicator's history, its use in capturing momentum, and the need for a secondary indicator to filter out noise and improve trend confirmation. Several secondary indicators, including RVI, MFI, TEMA, TRIX, Awesome Oscillator, and SMA, are evaluated through backtesting over a five-year period. The results indicate that TEMA and the Awesome Oscillator, when combined with MACD, yield the best performance in terms of return and Sharpe ratio, outperforming the benchmark SPY. The author concludes that these strategies are viable for practical implementation, with a note on the potential influence of the P/B ratio on stock selection within momentum trading.

Opinions

  • The MACD strategy is deemed suitable for beginners in automated trading due to its simplicity and effectiveness in capturing price momentum.
  • Momentum strategies, including MACD, benefit from secondary indicators to reduce noise and improve the accuracy of buy and sell signals.
  • The author expresses skepticism about the effectiveness of using fixed percentage points for take-profit and stop-loss, as it may not align with the momentum predicted by MACD signals.
  • The article suggests that a high P/B ratio may indicate a stronger influence of the momentum factor, which could be crucial for stock selection in momentum trading strategies.
  • The author emphasizes the importance of simulated trading (paper trading) for strategy development and warns against trading real money without professional advice.

【Momentum Trading】Advance your MACD Momentum Strategy to the Next Level

Photo by Markus Winkler on Unsplash

I’ve been thinking for weeks. As a beginner in automated trading and quant trading, what would be the best practical entry-level strategy that I can automate and practice what I’ve been learning? a.) I don’t need to make a huge fortune out of it. b.) I wouldn’t like to short stocks at the moment and have no right to bid on options. c.) I can bear the loss as long as it’s not a huge one. d.) I would like to trade daily in order to have further feedback regarding how to further improve the strategy. After days of research, I believe the MACD strategy would be the one to start with.

MACD (Moving Average Convergence Divergence) is a basic indicator strategy for capturing the stock price momentum both upward and downward. The idea of the MACD trading strategy is to buy or sell when the signals were triggered. As easy as that. Even grandma and grandpa can follow simple instructions to profit from the stock market.

There are several explanations of why momentum strategy such as MACD strategy works:

  1. One explanation is that the momentum generated when the stock price soars more than the market expected, then it tends to generate traction to attract more attention from other investors.
  2. Another explanation is that investors have a different response time to the good news. Therefore the stock price would continue to rise for several days until all investors have digested the news and made the necessary moves (either buy or sell).

Let’s take this for example: If you see the price of a popular stock starts soaring and many of your friends telling you that they have bought this stock that might increase its price 5% in the next week. Would you buy it?

This plays a big part in the momentum strategy. The more people are buying and more attention was paid to specific stocks, the more likely the stock price would go up as described in the major economic principle of providing and demand. This is the so-called FOMO effect (Fear tO Miss Out)

People tend to buy things that other people are buying

The momentum strategies also have their limits:

  1. The momentum strategy is too well known so that the return/benefit has been diluted as many investors are participating in this game.
  2. It’s only a phenomenon based on herding behavior and past history. This strategy won’t be able to predict the future price trend.
  3. Take the MACD momentum strategy, for example, simply using MACD indicators will trigger too many noises and no-profit trades, generating unnecessary trading fees.

Objective

So we need an additional secondary indicator that helps us remove the noise and decide the trend whether it’s upward or downward. What indicator we should adopt to work together with the MACD strategy?

Luckily enough, after reading this article MACD — 5 Profitable Trading Strategies, we have found several options to opt-in. Therefore the objective of this article is to dive into the details of how to implement these secondary indicators, and how they perform respectively.

What is MACD?

The history of MACD can be traced back to 1979, Gerald Apple invented the MACD indicator, it was an analytic tool for tracking stock and gold price trends. The MACD was constructed by both short-term and long-term EMA (Exponential Moving Average). If the MACD indicator turns from negative to positive, then it’s a buy-in signal; vise-versa. 12 days for short-term EMA and 26 days for long-term EMA are the common setup of the MACD strategy. Here’s a quick guide of how to calculate MACD indicator:

Moving average convergence divergence formula

Let’s get started with our trading strategy!

Setup

  • On Quantopian platform
  • Run the backtest in a five-year span, from Jan 2015 to Sep 2020
  • Trading once a day
  • Maximum 10 stocks in our target portfolio
  • Selecting stocks that are high quality as our target assets universe
  • Hedge assets such as Gold or VIX related ETF to hedge the downside risk

Enter and exit Strategy

When the $MACD_{Hist}$ is above 0 together when the signal of the secondary indicator is triggered, this indicates that the current $MACD$ line starts trending up above the past 9-day EMA. So once this combined signal reveals, then we enter the position. When the $MACD_{Signal}$ is below 0, then this means the stock price is starting to trend low. So we exit the position to capture the return as much as we can compare to the signal using MACD_hist and MACD_signal both below 0.

PS: There’s another exit strategy that is quite popular on the internet, that you could set a certain percentage as your take-profit and stop-loss point. For example, you can exit the position once you’ve hit 10% of profit or lost 10% of the original investment. It seems quite make sense to me in the beginning, so I played with it and tried to incorporate this into my exit strategy. It turned out the results didn’t seem plausible. My assumption would be that this exit strategy doesn’t serve the purpose of capturing the momentum in the MACD strategy, as the stock price could fluctuate before it reaches the timing that the MACD signal predicts.

Backtests and results of our double signal system

Let’s start pairing the MACD signal with the secondary signal and see how they were implemented:

1. Relative Vigor Index (RVI)

RVI is not like the other oscillators that evaluating over-buy or over-sell. By looking at the formula below, it’s more of an indicator to tell whether the stock is vigorous enough to be profitable (either long or short the stock). Therefore, a crossover above the RVI signal line indicates that there is probably a bullish trend in the near future. So we can combine RVI with MACD to form a better-confirmed signal.

RVI and RVI signal formula
Forming RVI indicator
Forming RVI Signal indicator

2. Money Flow Index (MFI)

Money Flow Index is another type of oscillator (range from 0 to 100) that reflects the changes in both price and volume, comparing to the other oscillators that reflect price only. So this gives us a better idea of whether the target stock is oversold or overbought when the MFI is positioned at both extreme edges. So we combine the MACD signals with MFI to double confirm the trend of the stock price.

Money Flow Index formula
Forming MFI indicator

3. Triple Exponential Moving Average (TEMA)

TEMA is a more complex indicator. TEMA smooths the price fluctuations and waives the lagged price impact from the traditional moving average(MA). Compares to EMA, TEMA reduces the influence magnitude of the past few days. Therefore, it works like the traditional moving average to reflect the stock price moving trend by factoring the price movement of the past N periods. We use this to see when the current stock price cross above the TEMA, as a signal of the upward breakthrough.

Triple Exponential Moving Average formula
Forming TEMA indicator

4. Triple Exponential Average (TRIX)

Similar to TEMA, TRIX is working surrounding the concept of exponential average. It does have one distinct difference. Unlike TEMA, TRIX represents the change in percentage comparing to the previous day, rather than the stock price EMA itself. Change in percentage would help identify the magnitude of either growth or decline. We are going to adopt this into our buy-in signal when the TRIX line goes above the zero line.

Triple Exponential Average formula
Forming TRIX indicator

5. Awesome Oscillator

According to the article Awesome Oscillator Day Trading Strategies, the awesome oscillator is quite awesome, or to say it’s amazing. First of all, the awesome oscillator is a boundless oscillator, comparing to the traditional oscillator that ranges from +100 to -100. Secondly, it’s less complex in terms of equation computation, as TRIX modified the concept of normal SMA strategy from using the close price to using the middle price in an intraday. To incorporate the awesome oscillator into our MACD trading strategy, we need both MACD and awesome oscillator signals to be triggered in order to enter or close the positions.

Awesome Oscillator formula
Forming AO indicator

6. Simple Moving Average

This strategy was mentioned in the article MACD — 5 Profitable Trading Strategies as a bouns strategy to look at. In this strategy, we enter a position when the MACD signal is triggered, and then we look for the timing with the assistance of the MA line. Meaning, we buy only when the following conditions are met:

  1. The stock price is above MA most of the time
  2. MACD has already crossed above the MACD signal line
  3. The most recent stock price slide and touched the MA line.
Generating a buy signal when your close price touches the SMA

Allegedly, this strategy would get us to buy into the pullbacks of security that still has strong upward momentum.

Forming your SMA indicator

Performance

The long and tedious description section is over!! Now let’s put the result together and see how each strategy performed.

Backtest result of combining various secondary results to MACD indicator
  1. The final results don’t seem to be consistent with the author of MACD — 5 Profitable Trading Strategies on the preferred MACD strategy, as he’s doing research on single stock respectively against the technical diagram. Here we’re working with the computer, screening qualified stocks, and letting the program decide what to buy and when to buy or sell.
  2. From what we have tested, TEMA and Awesome Oscillator seem to be the best options out of the six strategies that we have backtested. These two strategies have generated outstanding return and Sharpe ratio, and also be able to beat the benchmark stock SPY.
  3. As we’re running the stock selection by programmed rules, there could be many stocks that have passed the threshold and qualified to be traded. Since we have only 10 seats in our portfolio, how are we going to select the stock that has the biggest momentum? The MACD nor the rest of the secondary indicators can be used to define the magnitude of the momentum across different stocks. However, it seems that a high P/B ratio tends to receive higher influence from the momentum factor. When ranking the P/B ratio from high to low would generate a higher return and lower risk compared to ranking the P/B ratio from low to high. I will not spend more words describing this in this article. If anyone is interested in this topic, let me know, and I’ll write more about this.

Take away

There are still many other variables to play with in order to optimize the strategy. Such as increase the MACD threshold to make sure we don’t run into a short-term reverse, increase the portfolio capacity to waive the sector-specific risk, monitor the MACD breakthrough for several periods to confirm the upward/downward trend before opening a position, … etc. However, looking from the MVP (minimum viable product) point of view, I believe it’s already good enough to throw this into practice by picking either TEMA or Awesome Oscillator strategies.

OK. I’m going to write my code to start automating my trading strategy. Follow me if you find this post useful.

Disclaimer: Nothing herein is financial advice or even a recommendation to trade real money. Many platforms exist for simulated trading (paper trading) which can be used for building and developing the strategies discussed. Please use common sense and consult a professional before trading or investing your hard-earned money.

Quantitative Trading
Research
Investment Strategy
Quant
Recommended from ReadMedium