MACD Bars Indicator: A Hidden Buffer Behind The Colours

Written by Dominic Walsh · Published · Last updated

The macd bars indicator carries four buffers and draws only three. The fourth holds the raw histogram value and never appears. That hidden series lets the alert compare three bars cheaply, without asking the terminal for the same numbers twice.

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 (levels 0)
Plots 4: MACD Bar Up, MACD Bar Down, Signal, Hist Raw
Alerts popup, push notification, email, sound
Inputs 10

On screen

MACD Bar Up is the lime green histogram above zero.

MACD Bar Down is the red histogram below it.

Signal is the dark gray line running over both.

Hist Raw is an undrawn buffer holding the unsplit values.

  • MACD Bar Up: histogram, lime green, width 3
  • MACD Bar Down: histogram, red, width 3
  • Signal: line, dark gray, width 1
  • Hist Raw: hidden buffer, none
MACD bars indicator on EURUSD H1 with the split histogram and signal line
MACD bars indicator on EURUSD H1 with the split histogram and signal line

How each value gets built

Reading the values

iMACD supplies main and signal at `FastEMA` `12`, `SlowEMA` `26` and `SignalEMA` `9`, using `AppliedPrice`. hist_now takes the difference. The code fetches the previous bar for the same reason.

Splitting for colour

UpBarBuf takes hist_now while positive and DnBarBuf takes it while negative. Both hold EMPTY_VALUE otherwise, so exactly one bar draws at each index and the pane scales sensibly.

Keeping a raw copy

HistRawBuf stores every value whatever its sign, with no plot attached. The alert reads three entries from it directly. Recomputing those would cost three more terminal calls on each check.

How to interpret it

Colour reports the sign of the gap between the two averages.

The gray line is the signal, not a second histogram.

The raw buffer is invisible by design and carries no display meaning.

Bar height still scales with price, so the numbers differ between instruments.

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

`EnableAlerts` arrives switched on and `EnablePopup` does the talking. `EnablePushNotify`, `EnableEmail` and `EnableSound` all begin false. `SoundFile` picks the clip. The check reads three stored values, one message per closed bar.

Every Macd Bars Indicator input

Core settings

Setting What it does Default
FastEMA Fast average length, default `12`. 12
SlowEMA Slow average length, default `26`. 26
SignalEMA Signal average length, default `9`. 9
AppliedPrice Price the calculation reads, default PRICE_CLOSE. PRICE_CLOSE

Alert settings

Setting What it does Default
EnableAlerts Master switch for the bar colour alerts, default `true`. on
EnablePopup Terminal dialog on a colour change, default `true`. on
EnablePushNotify Phone push on a colour change, default `false`. off
EnableEmail Mail delivery on a colour change, default `false`. off
EnableSound Sound playback on a colour change, default `false`. off
SoundFile Wav clip for the bar alert, default `alert.wav`. alert.wav
MACD bars indicator inputs: FastEMA, SlowEMA, SignalEMA, AppliedPrice
MACD bars indicator inputs: FastEMA, SlowEMA, SignalEMA, AppliedPrice

Which pair, which timeframe

A split histogram reads best where the pane has room. EURUSD H1 is the reference chart, where `SlowEMA` at `26` covers a day. On M5 the colour flips several times an hour. On H4 each block covers a real leg of the move.

What to be wary of

Colour reports only the sign, so a shrinking bar looks the same as a growing one.

The histogram comes from two lagging averages, so it turns after price does.

In a range the colour alternates with nothing behind either side.

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

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

What is the Hist Raw buffer for?

It stores the histogram value at every index with no plot attached. The alert reads three entries from it. Recomputing those would cost three extra terminal calls on each check, which adds up on a long chart.

Why split the histogram into two buffers?

Because MT4 cannot colour a single histogram per bar. Splitting into MACD Bar Up and MACD Bar Down lets each half carry its own colour, with the inactive one holding EMPTY_VALUE so only one bar draws.

Does AppliedPrice change the Signal line?

Yes. It sets the series the whole calculation reads, so both the main line and the signal shift with it. PRICE_CLOSE is the default and matches the standard definition everyone else uses.

Why is the Signal line dark gray?

So it stays readable over a coloured histogram without competing with it. A brighter line would fight the lime and red bars for attention, and the histogram is the main output here.

Are results guaranteed?

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