Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
MACD on QTradableStocksUS – Strategy and Results

Hi, everyone.
I tested yet another classic technical analysis strategy, this time MACD: MACD Strategy
I saw some videos on the Internet claiming certain gains with this type of strategy and I decided to check the results using Quantopian in a larger universe of operations.
The results were not satisfactory as can be seen below:

Backtest period: 07/2010 to 07/2020 (10-year period)
Total Return: 181.7% (versus 258.6% SPY)
Maximum Drawdown: -27.2%
Win Rate: 36.3%
N. of Trades: 2953

General Rule:
- Max. 50 simultaneous operations cap
Buy Rules:
- Current Price above 200-day EMA.
- MACD-Hist turning from negative to positive .
Sell Rules:
- Stop Loss at 5%
- Stop Gain at 15% (3x maximum loss)

If everything is right with the simulation, it seems that in the market and in the period it was tested, the strategy basically only generates revenue for the broker, nothing more.
I had a hard time getting it to work in Pipeline a custom factor for the MACD, specially for the day before. Couldn't do it without Talib function. In Pandas it only takes 5 lines of code to do it.
PS: I would like to thank the countless clarifications and contributions made by Dan Whitnable and other colleagues in the Quantopian forum. Without that help, it would not have been possible to take a step forward.