MACD Indicator for MT4 and MT5

Written by Dominic Walsh · Published · Last updated

Two things separate the macd indicator here from the terminal version. Its periods are 8, 34 and 5 rather than the textbook set, which makes it noticeably quicker to turn. And every exponential average runs inside the source, so you can read the whole calculation line by line.

This build ships as a compiled .ex4 for MT4 and .ex5 for MT5; the screenshots below come from EURUSD H1.

Platforms MT4 (.ex4) + MT5 (.ex5)
Chart window Separate window
Plots 3: MACD, Signal, Histogram
Alerts popup, push notification, email, sound
Inputs 9

What the MACD Indicator draws on the chart

Three plots below price.

`MACD` runs plum.

`Signal` runs crimson.

`Histogram` fills chartreuse between them.

No arrows and no marks appear.

Nothing reaches the price chart.

  • MACD: plot, plum
  • Signal: plot, crimson
  • Histogram: plot, chartreuse
macd indicator: Both lines and the chartreuse columns on EURUSD H1.
Both lines and the chartreuse columns on EURUSD H1.

How the MACD Indicator calculates its values

Three smoothing constants

Each period becomes a factor. `FastPeriod` `8`, `SlowPeriod` `34` and `SignalPeriod` `5` each convert into the usual two over period plus one.

Carried forward

Every value builds on the last. The first bar seeds both averages at the opening close, and each bar after blends the new close with the previous result.

The three outputs

Subtraction gives them. Fast less slow is the main line. Smoothing that gives the signal. The difference between those two fills the columns.

How to read the signals

Eight and thirty-four turn faster than twelve and twenty-six.

A five-bar signal follows the main line closely.

Columns reach zero exactly at a crossing.

The faster set produces more crossings.

Seeding at the first close means early bars are approximate.

Nothing marks a signal, so you read the lines yourself.

Alert channels in this build: popup, push notification, email and sound, one message per closed bar.

`EnableAlerts` opens the message group and `EnablePopup` joins it on by default. Three more sit ready: `EnablePushNotify` for the mobile terminal, `EnableEmail` through your terminal mail settings, and `EnableSound` playing whatever `SoundFile` names.

Every MACD Indicator input

Core settings

Setting What it does Default
FastPeriod Quicker leg of the calculation, `8`. 8
SlowPeriod Slower leg, `34`. 34
SignalPeriod Smoothing applied to their difference, `5`. 5

Alert settings

Setting What it does Default
EnableAlerts Whether crossing messages go out at all, `true`. on
EnablePopup Shows a crossing in a MetaTrader box, `true`. on
EnablePushNotify Sends a crossing to your phone, `false`. off
EnableEmail Mails a crossing out, `false`. off
EnableSound Sounds a crossing on the desktop, `false`. off
SoundFile Clip used for that sound, `”alert.wav”`. alert.wav
macd indicator: Inputs panel showing the 8, 34 and 5 period set.
Inputs panel showing the 8, 34 and 5 period set.

Settings that fit your chart

Faster periods suit a chart where you want earlier warning. EURUSD H1 is the reference chart. Crossings arrive most days there. On M5 they come several times an hour. On daily bars the faster set behaves like the standard one on H4.

When the MACD Indicator fails

Faster periods mean more crossings that lead nowhere.

Seeding both averages at one close skews the far left.

The values will not match a chart running the standard set.

No marks means every read is manual.

Copy the compiled MACD Indicator file into your MQL4/Indicators folder, and the MT5 build into MQL5/Indicators, then restart the terminal and drag it onto a chart. The step-by-step guide with screenshots is at how to install MT4 and MT5 indicators.

Download the MACD Indicator for MT4 and MT5

The zip holds the compiled MACD Indicator build for MT4 and MT5, plus a short README. Compiled files only, no source. Enter your email below and the download link arrives in your inbox.

Download this indicator free

Enter your email and the file is yours. You also get the full MT4 and MT5 library.

  • 1,380+ indicators
  • MT4 and MT5 files
  • No spam, unsubscribe any time

FAQ

Why are FastPeriod and SlowPeriod 8 and 34?

They are a faster set than the published twelve and twenty-six, chosen so the reading turns earlier. The trade is more crossings overall, a fair number of which will not lead anywhere.

Does this call the terminal MACD?

No. All three exponential averages run inside this source, which means you can audit every step rather than trusting a built-in call. It also means the values are computed fresh rather than fetched.

How do FastPeriod and SlowPeriod start out?

Both begin at the first bar’s close. It is a simple choice that makes the earliest values approximate, though on any chart with real history the effect has long washed out by the time you look at it.

Will these values match a standard MACD chart?

No, and they are not meant to. With `SignalPeriod` `5` against the usual nine, and a faster pair behind it, both the line positions and the crossing points differ from the textbook version.

Are results guaranteed?

No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the MACD Indicator as one input. Always backtest before trading live.

Category: this is part of our Oscillators collection. Browse more Oscillators for MetaTrader, or explore every MT4 indicator and MT5 indicator on the site.

External references

Dominic Walsh - Forex trader and MT4/MT5 developer

About the author

Written by Dominic Walsh, a Forex trader and MT4/MT5 indicator, Expert Advisor and script developer. Every tool on forexmt4systems.com is tested on live charts before release and ships with ready-to-use compiled MT4 (.ex4) and MT5 (.ex5) files. Learn more about the trader and developer behind this site.

How we build, test and correct every tool: Editorial & Testing Policy. Trading carries risk; see the disclaimer.

Leave a Comment