I don't get two lines in MACD

Hi everyone,

I am bit of a dweeb when it comes to these things. I can’t find two lines when I open MACD. It only shows the histogram and a red line. The red line, I believe, is the signal line. So where is the other? When I see images of MACD, I see a blue and red line excluding the histogram. I don’t want to sound impolite; but, someone please tell me how I could get the blue line onto my MACD chart.

Regards, Marlon

Hi Marlon,

This happens to everyone when they insert the MACD onto MT4 for the first time. Well its a matter of translation at the histogram is indeed the MACD line and consider the curvature as a line and just like in the java platform, signals will be generated when the MACD( histogram) and the signal line cross and when the MACD moves from positive to negative and vice versa.

Thanks a lot Grix for your explanation. But isn’t there a way to get both lines (blue & red) onto the MACD graph?

//±-----------------------------------------------------------------+
//| MACD.mq4 |
//| Copyright © 2005, David W. Thomas |
//| mailto:[email protected] |
//±-----------------------------------------------------------------+
// This is the correct computation and display of MACD.
#property copyright “Copyright © 2005, David W. Thomas”
#property link "mailto:[email protected]"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Green

//---- input parameters
extern int FastMAPeriod=12;
extern int SlowMAPeriod=26;
extern int SignalMAPeriod=9;

//---- buffers
double MACDLineBuffer[];
double SignalLineBuffer[];
double HistogramBuffer[];

//---- variables
double alpha = 0;
double alpha_1 = 0;

//±-----------------------------------------------------------------+
//| Custom indicator initialization function |
//±-----------------------------------------------------------------+
int init()
{
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,MACDLineBuffer);
SetIndexDrawBegin(0,SlowMAPeriod);
SetIndexStyle(1,DRAW_LINE,STYLE_DOT);
SetIndexBuffer(1,SignalLineBuffer);
SetIndexDrawBegin(1,SlowMAPeriod+SignalMAPeriod);
SetIndexStyle(2,DRAW_HISTOGRAM);
SetIndexBuffer(2,HistogramBuffer);
SetIndexDrawBegin(2,SlowMAPeriod+SignalMAPeriod);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName(“MACD(”+FastMAPeriod+","+SlowMAPeriod+","+SignalMAPeriod+")");
SetIndexLabel(0,“MACD”);
SetIndexLabel(1,“Signal”);
//----
alpha = 2.0 / (SignalMAPeriod + 1.0);
alpha_1 = 1.0 - alpha;
//----
return(0);
}
//±-----------------------------------------------------------------+
//| Custor indicator deinitialization function |
//±-----------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//±-----------------------------------------------------------------+
//| Custom indicator iteration function |
//±-----------------------------------------------------------------+
int start()
{
int limit;
int counted_bars = IndicatorCounted();
//---- check for possible errors
if (counted_bars<0) return(-1);
//---- last counted bar will be recounted
if (counted_bars>0) counted_bars–;
limit = Bars - counted_bars;

for(int i=limit; i>=0; i–)
{
MACDLineBuffer[i] = iMA(NULL,0,FastMAPeriod,0,MODE_EMA,PRICE_CLOSE,i) - iMA(NULL,0,SlowMAPeriod,0,MODE_EMA,PRICE_CLOSE,i);
SignalLineBuffer[i] = alphaMACDLineBuffer[i] + alpha_1SignalLineBuffer[i+1];
HistogramBuffer[i] = MACDLineBuffer[i] - SignalLineBuffer[i];
}

//----
return(0);
}
//±-----------------------------------------------------------------+



About halfway down the code, there is a space between SlowMA and Period that shouldn’t be there. Meta Editor flags it as an error. I just took away the space to make it “SlowMAPeriod”. It works perfect now. Thanks a lot MoneyNVRSleeps!!!

No Problem Jayw…

PS- I tryed to fix it in edit, but it doesnt show the space, so you will have to continue to manually fix this issue…

Glad I can be of help!!

IM Also having same issue@MoneyNVRSleeps i see certain codes up there. but i dont know what to do with them cause i dont anything about coding
PLEASE HELP!!