MACD On Chart Indicator for MT4 and MT5

Written by Dominic Walsh · Published · Last updated

A reading measured in fractions of a pip cannot share an axis with price. The macd on chart indicator solves that arithmetically: it measures how far price has ranged over two hundred bars, works out a multiplier that makes the reading fit, and draws both lines on the candles.

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 Main price chart
Plots 3: MACD Line (scaled), Signal Line (scaled), Zero Reference
Alerts popup, push notification, email, sound
Inputs 13

Its visible parts

Three lines, all on the price chart.

`MACD Line (scaled)` traces dodger blue at width 2.

`Signal Line (scaled)` traces orange beside it.

`Zero Reference` traces silver at width 1.

The reference sits where the reading’s zero maps to.

Nothing appears in a pane below.

  • MACD Line (scaled): line, dodger blue, width 2
  • Signal Line (scaled): line, orange, width 2
  • Zero Reference: line, silver, width 1
macd on chart indicator: Both scaled lines over the candles, EURUSD H1.
Both scaled lines over the candles, EURUSD H1.

How the values come out

The reading

`FastPeriod` `12` less `SlowPeriod` `26`, smoothed by `SignalPeriod` `9` on `PriceMode` `PRICE_CLOSE`. Standard values, and both outputs are kept.

Sizing the fit

`ScaleLookback` `200` measures the price range and the reading’s range over the same span. Dividing one by the other gives the multiplier that makes them comparable.

Leaving room

`ScaleMargin` `0.35` shrinks the fit deliberately. Using the full price range would leave the lines touching the top and bottom of the window with no space around them.

On a live chart

Line shapes are the reading, not price levels.

The silver line is where zero maps to, not a price.

`AnchorToCurrent` `true` pins that mapping to the last close.

Crossings mean what they always mean.

Distances on screen are scaled, not real.

Warm-up needs about two hundred bars.

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

The two scaled lines crossing is what reports. `EnableAlerts` decides whether it speaks and a prompt already shows in the terminal, while the push route, the mail route and the audio behind `SoundFile` stay closed.

Every Macd On Chart Indicator input

Core settings

Setting What it does Default
FastPeriod Shorter average, `12`. 12
SlowPeriod Longer one, `26`. 26
SignalPeriod Smoothing length, `9`. 9
PriceMode Price the averages read, `PRICE_CLOSE`. PRICE_CLOSE
ScaleLookback bars used to size scaling factor. Bars used to size the fit, `200`. 200
ScaleMargin visual margin (0 = touch, 0.5 = half-range gap). Share of the range left as breathing room, `0.35`. 0.35
AnchorToCurrent offset zero line to current price. Pin zero to the latest close, `true`. on

Alert settings

Setting What it does Default
EnableAlerts Whether a crossing speaks, `true`. on
EnablePopup A prompt shows in the terminal, `true`. on
EnablePushNotify (see inputs panel) off
EnableEmail (see inputs panel) off
EnableSound (see inputs panel) off
SoundFile Audio the desktop route uses, `”alert.wav”`. alert.wav
macd on chart indicator: Inputs panel, the scaling settings under the periods.
Inputs panel, the scaling settings under the periods.

Matching it to your chart

Two hundred bars of range is what the scaling is built from, so the chart wants that much history. EURUSD H1 is the reference chart, covering about eight days. On M5 the window is under a day. On D1 it spans most of a year.

Known limits

Lines drawn over price are not price levels.

The scaling changes as the window rolls forward.

Anchoring to the last close moves the whole picture.

Overlaying three more lines crowds the candles.

Copy the compiled Macd On Chart 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 On Chart Indicator for MT4 and MT5

The zip holds the compiled Macd On Chart 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

Does the MACD Line (scaled) show a price level?

No, and this is the thing to keep straight. Its position on the axis is an artefact of the scaling, so it should never be read as support, resistance or any kind of target.

What does ScaleMargin 0.35 leave room for?

Breathing space. Using the full price range would push the lines against the top and bottom of the window, so a third of it is held back and the overlay sits comfortably inside the candles.

What happens when AnchorToCurrent is true?

The reading’s zero maps to the latest close rather than to the middle of the range. That keeps the overlay near current price, at the cost of the whole picture shifting as price moves.

Why does ScaleLookback 200 need so many bars?

Because a short window would produce a multiplier that jumped around. Two hundred bars gives a stable price range to divide by, so the overlay keeps a consistent size as new bars arrive.

Are results guaranteed?

No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Macd On Chart 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