Custom MACD Indicator: Crossings Filtered By The Zero Line

Written by Dominic Walsh · Published · Last updated

The custom macd indicator adds one rule to a standard reading. A buy mark needs the crossing to happen below zero. A sell needs it above. That single condition removes a large share of the marks a plain MACD would print.

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 5: MACD, Signal, Histogram, Buy, Sell
Alerts popup
Inputs 6

What the Custom MACD Indicator draws on the chart

A dodger blue `MACD` line and an orange red `Signal` line share the pane.

A silver `Histogram` shows the gap between them.

`Buy` uses arrow 233 and `Sell` uses 234.

Marks sit on the MACD value itself, so they land on the line rather than beside it.

  • MACD: line, dodger blue, width 2
  • Signal: line, orange red, width 2
  • Histogram: histogram, silver, width 2
  • Buy: arrow, lime, width 2, arrow code 233
  • Sell: arrow, red, width 2, arrow code 234
Custom macd indicator lines, histogram and filtered arrows on EURUSD H1.
Custom macd indicator lines, histogram and filtered arrows on EURUSD H1.

How the Custom MACD Indicator calculates its values

Standard settings underneath

iMACD runs at `FastEMA` `12`, `SlowEMA` `26` and `SignalSMA` `9` on `AppliedPrice` `PRICE_CLOSE`. Those are the textbook figures, and this build keeps all of them.

The zero-line condition

A buy needs the lines to cross while the MACD value is still negative. A sell needs the crossing while it is positive. So a crossing that happens on the wrong side of zero produces nothing at all.

Where the marks sit

Both arrow buffers receive the current MACD value rather than a price. That places each mark directly on the line inside the pane, which keeps a run of them easy to trace.

How to read the signals

A buy mark always appears below the zero line, and a sell above it.

The histogram crosses zero exactly when the two lines swap.

Not every visible crossing earns a mark, and that is the point.

`ShowArrows` clears the marks when you want the lines alone.

Alert channels in this build: popup, one message per closed bar.

A single route ships here. `EnableAlerts` starts true and raises a terminal message when a crossing passes the zero test. No phone, mail or sound option exists in this build. Bars must close before anything reports.

Every Custom MACD Indicator input

Core settings

Setting What it does Default
FastEMA Bars in the fast average, default `12`. 12
SlowEMA Bars in the slow average, default `26`. 26
SignalSMA Bars in the signal average, default `9`. 9
AppliedPrice Price the calculation reads, default `PRICE_CLOSE`. PRICE_CLOSE

Display settings

Setting What it does Default
ShowArrows Draw the buy and sell marks, default `true`. on

Alert settings

Setting What it does Default
EnableAlerts Post a terminal message on a qualifying crossing, default `true`. on
Custom macd indicator inputs panel with FastEMA, SlowEMA and SignalSMA.
Custom macd indicator inputs panel with FastEMA, SlowEMA and SignalSMA.

Settings that fit your chart

A 26-bar average wants room to work. EURUSD H1 is the reference chart, where `SlowEMA` `26` covers more than a day. On M5 the lines cross constantly and the zero rule does real filtering. H4 leaves only a few marks a month.

When the Custom MACD Indicator fails

The zero rule rejects crossings that happen during a strong run, which are sometimes the good ones.

Both averages lag, so a mark lands well after the turn it describes.

Placing arrows on the line means they can be hard to see when the pane is compressed.

Copy the compiled Custom 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.

Background reading on the method behind the Custom MACD Indicator: icustom (CUSTOM) at the MQL5 Documentation, MACD Histogram at StockCharts ChartSchool.

Download the Custom MACD Indicator for MT4 and MT5

The zip holds the compiled Custom 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 must a Buy cross happen below zero?

Because a crossing under the zero line means both averages are still below their longer-term balance, which is the classic setup this build is filtering for. A crossing above zero during a rally gets ignored instead.

What does SlowEMA 26 set?

The longer of the two averages inside the calculation. Twenty-six is the textbook value and this build keeps it. Changing it moves the whole line, which also moves where it sits against zero.

Why do the arrows sit on the MACD line?

The buffers receive the MACD value rather than a price, so each mark lands exactly where the crossing happened. That makes the sequence easy to trace, at the cost of visibility on a short pane.

Does ShowArrows change the alerts?

No. It only controls whether the two arrow buffers get filled. The crossing test and the terminal message run either way, so you can keep the alerts while clearing the pane.

Are results guaranteed?

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

Category: this is part of our Oscillators collection. Also, 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