Build Your Own MACD Zero Cross Strategy using MetaTrader and Python

James Hinton
5 min readMar 22
Futuristic robot running an automated strategy
Algorithmic Trading Bot Image

You’ll be getting your own MACD Zero Cross Strategy BUY signals and SELL signals by the end of this article!

Using Python code and MetaTrader 5, the signals will be completely customizable by you so you can figure out what combination generates profit for every trading pair!

Read on to find out how.

Update August 2023

I could never have anticipated how popular this blog, along with a YouTube channel would become.

After a listening to my readers/viewers feedback, I realized that many people were spending huge amounts of time trying to solve installation/configuration problems — rather than experiencing the joy of algorithmic trading.

I want to change this narrative — and in so doing, open up algorithmic trading for everyone.

To do this, I’ve recently launched Tradeoxy: Trading For Everyone.

If you’re reading this, Tradeoxy will simplify 90% of this series, using a series of powerful API’s and easy to use tooling.

Currently it’s in the early-access / building stage and I’d be incredibly grateful if you’d join us on this adventure. Your feedback will help us shape a better product.

Join the early access program (for free) here.

You can also view our launch video, and follow our journey on LinkedIn, Twitter, Instagram, YouTube.

The MACD Indicator

While this article is focused on building the MACD Zero Cross strategy into your Python trading bot, I did want to cover a few key pieces of information about the MACD Technical indicator.

First, the MACD indicator provides three separate elements:

  1. MACD Line
  2. MACD Signal Line
  3. MACD Histogram

Each of these elements provides different insight, however, for the MACD Zero Cross Strategy, we’ll be using the MACD Line and a Zero Line.

Secondly, the MACD indicator typically uses the following values to generate the analysis:

  1. Fast EMA: 12
James Hinton

Passionate algorithmic trader and Cyber Security expert. Love developing helpful content.