Download MetaTrader 5

Indicators: MACD Histogram, multi-color

To add comments, please log in or register
Unable to find the right application? Order it!
Automated-Trading 2010.08.24 10:12 

MACD Histogram, multi-color:

A MACD indicator with histogram to show the difference between the MACD and Signal lines.

For the calculation of the MACD line you can choose from the usual price types. For the calculation of the Signal line yo can choose between SMA or EMA. The histogram can be switched between single and multi-color.

MACD Histogram, multi-color

Author: traderak20

Jabz 2013.11.17 22:33  


 I keep on getting the following error

"can't open "C:\Program Files\MetaTrader 5\MQL5\Indicators\Examples\MACD_Histogram_MC.ex5" output expert file (2) 0 0

EX5 write error 1 1 "


I'm assuming I'm the only one who is getting this error as no1 else has commented on this.


Please let me know how I can fix it.


Thank You 

Alain Verleyen
Alain Verleyen 2013.11.17 22:53  

I guess you copied the MACD_Histogram_MC.mq5 file in "C:\Program Files\MetaTrader 5\MQL5\Indicators\Examples\". It's not a good directory.

Your problem is an UAC issue, you can resolve it by following this procedure:


Expert Advisors: Renko Line Break vs RSI EA

angevoyageur, 2013.08.19 11:12

  1. In your MT5 platform click on Metaquotes Language Editor button (or press F4)
  2. In MetaEditor, you have the Navigator window, right-click on Indicators
  3. In the popup window click on Open Folder, a new window open.
  4. Copy the indicator source code in this window.
  5. Once copied, double-click on the file, it opens in MetaEditor, then click on Compile button (or F7).

You can now run the EA.

Or even a more easy way by reading How to download code using MetaTrader 5, which is a link provide above all source code in Codebase.
Jabz 2013.11.17 23:12  


Brilliant works perfectly.


Thank You for your excellent assistance 



Alain Verleyen
Alain Verleyen 2013.11.18 00:01  


Brilliant works perfectly.


Thank You for your excellent assistance 



You are welcome.
Sergey Golubev
Sergey Golubev 2014.06.19 12:01  
Moving Average Convergence Divergence (MACD)

MACD stands for Moving Average Convergence Divergence and was first developed by Gerald Appel in the late 1970s. It is an Absolute Price Oscillator (APO) and can be used in an attempt to identify changes in market direction, strength and momentum.

It calculates the convergence and divergence between a ‘fast’ and a ‘slow’ Exponential Moving Average (EMA) known as the MACD Line. A signal EMA is then plotted over the MACD Line to show buy/sell opportunities. Appel specified the MA lengths as the following percentages:
  • Slow EMA = 7.5% (25.67 period EMA)
  • Fast EMA = 15% (12.33 period EMA)
  • Signal EMA = 20% (9 period EMA)
Usually however these are rounded to EMAs of 26, 12 and 9 respectively. Many charting packages will also plot the difference between the Signal Line and MACD Line as a Histogram.

One of the biggest challenges when dealing with financial data is noise or erratic movements that cause false signals. By smoothing data out you can reduce the number of false signals. But this comes at a cost, and causes an increase in the lag of your signals. The genius of the MACD is that it begins by smoothing data (thus causing lag) and then speeds up the signals from the smoothed data. This combination helps to reduce false signals while minimising the lag.

By comparing EMAs of different lengths the MACD can help to identify subtle changes in the trend and momentum of a security. It is a great visual representation of the acceleration or rate of change in a trend.

How to Calculate a MACD

MACD Formula:

  • MACD Line = EMA,12 – EMA,26
  • Signal Line = EMA[MACD,9]
  • MACD Histogram = MACD – Signal Line
  • Histogram Trigger = EMA[MACD Histo,5]
Obviously you can change the parameters to any value of your choice.

MACD Excel File

We have put together an Excel Spreadsheet that will automatically adjust to the MACD settings you desire. Find it at the following link near the bottom of the page under Downloads – Technical Indicators: Moving Average Convergence Divergence (MACD)

Test Results

Is the MACD an effective indicator? We are putting it into the ring for the Technical Indicator Fight for Supremacy. It will be tested through 300 years of data across 16 global markets to discover which settings produce the best results and how it performs compared to other indicators:
  1. Moving Average Crossovers – Completed - Golden Cross – Which is the best?
  2. Moving Average Convergence Divergence (MACD) – Completed – Results
  3. ZeroLag MACD (ZL-MACD)
  4. MACD Z Score (MAC-Z)
Zaak 2015.07.22 22:36  

Hi is there a version for MTL4 ? thanks.

To add comments, please log in or register