Code Library / Indicators

MACD Histogram

Custom MACD histogram indicator for MQL5.

Language: MQL5 · Category: Indicators · Tags: MACD, histogram, MQL5

Source code

#property indicator_separate_window
double MacdBuf[],SigBuf[],HistBuf[];
int macdH;
int OnInit(){SetIndexBuffer(0,MacdBuf);SetIndexBuffer(1,SigBuf);SetIndexBuffer(2,HistBuf);macdH=iMACD(_Symbol,0,12,26,9,PRICE_CLOSE);return 0;}

How to use this snippet

This is a building block, not a finished trading system. Paste it into your own MQL5 project, compile it, and test it on a demo account with your broker's real spreads before relying on it. If MetaEditor reports errors, the compilation error fixer can help.

Related snippets