The MACD is a fairly straightforward momentum indicator. It consists of the difference between a 12 and 26 bar EMA. The difference between these two moving averages is the MACD. It is smoothed by a 9 Day EMA that is called the “signal line.”
The MACD is usually plotted with a histogram that represents the difference between the MACD and the signal line. The histogram can give either positive or negative values. On the traditional interpretation, a buy signal occurs when the signal line crosses the MACD and a sell signal occurs when the signal line crosses below the MACD. See the example below:
The MACD is a popular indicator on BTC forums. How does it hold up historically? Does it beat buy and hold? How does a long and short strategy perform? We will perform two backtests. The first will be a MACD long only strategy. The second will be a long and short MACD strategy. Finally, we will compare this to buy and hold.
We will make the following assumptions: (1) The backtest will cover 1/’1/2012-6/1/2012. (2) We will reinvest profits beginning with a $1,000 account. (3) We will keep the default parameters for the MACD.
How does the long/short strategy perform?
The strategy entered 41 total trades – 59% were profitable- net profit was $9,820- there was a 98% a drawdown and a profit factor of 6.42. See below
I am also attaching a youtube replay of each trade in the system to get a better feel for how the system would’ve worked.
You will notice that the system trades a different number of BTC depending on the account size. Once it hit a large drawdown at the end of April 2013, then the system did not have the equity to trade larger quantities of BTC.
Now let’s backtest the long only system.
The strategy entered a total of 21 trades – 76.19% were profitable – net profit was $135,000, there was a 19% drawdown and a profit factor of 60.41.
Here is the youtube replay.
Ultimately, MACD outperforms a buy/hold strategy as seen below. The Buy/Hold had a net profit of $126,600 and a drawdown of 73%. (For Buy/Hold I entered a buy at the open of everyday with the same amount of BTC 202 on each trade to make the performance equivalent. )
Here are a few takeaways:
1. Ultimately, MACD long only does beat buy and hold on both a net profit and drawdown. It caught every major uptrend even though it lagged the market.
2. However, MACD long only underperformed buy and hold during the large price increases. At one point, someone would’ve seen their BTC holdings drop from 202 to 58 due to price increases, lag and some losing trades.
3. The drawdown in USD on the MACD strategy is superior to buy/hold. Returns should always be related to risk. Someone trading the MACD would’ve had a $1,982 drawdown in USD, while the buy/hold drawdown equaled $159,000.
I am attaching the code below.