Seprate the macd zero lag indicator into two

 

Hello!

I am currently exploring the possibilities of automated trading. I wish to separate the macd zero lag into one indicator that only shows the MACD zero lag line and an indicator that only shows the signal line. I tried to work on the buffers and managed to get the MACD line separate but not the signal line. Can anyone please help me with this?

 

The code is below:

 

//+------------------------------------------------------------------+
//|                                                 ZeroLag MACD.mq4 |
//|                                                               RD |
//|                                                 marynarz15@wp.pl |
//+------------------------------------------------------------------+
#property copyright "RD"
#property link      "marynarz15@wp.pl"
//----
#property indicator_separate_window
#property  indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- input parameters
extern int FastEMA = 12;
extern int SlowEMA = 24;
extern int SignalEMA = 9;
//---- buffers
double MACDBuffer[];
double SignalBuffer[];
double FastEMABuffer[];
double SlowEMABuffer[];
double SignalEMABuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(5);
   SetIndexBuffer(0, MACDBuffer);
   SetIndexBuffer(1, SignalBuffer);
   SetIndexBuffer(2, FastEMABuffer);
   SetIndexBuffer(3, SlowEMABuffer);
   SetIndexBuffer(4, SignalEMABuffer);
   SetIndexStyle(0, DRAW_LINE,EMPTY);
   SetIndexStyle(1, DRAW_LINE,EMPTY);
   SetIndexDrawBegin(0, SlowEMA);
   SetIndexDrawBegin(1, SlowEMA);
   IndicatorShortName("ZeroLag MACD(" + FastEMA + "," + SlowEMA + "," + SignalEMA + ")");
   SetIndexLabel(0, "MACD");
   SetIndexLabel(1, "Signal");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars = IndicatorCounted();
   if(counted_bars < 0) 
       return(-1);
   if(counted_bars > 0) 
       counted_bars--;
   limit = Bars - counted_bars;
   double EMA, ZeroLagEMAp, ZeroLagEMAq;
   for(int i = 0; i < limit; i++)
     {
       FastEMABuffer[i] = iMA(NULL, 0, FastEMA, 0, MODE_EMA, PRICE_CLOSE, i);
       SlowEMABuffer[i] = iMA(NULL, 0, SlowEMA, 0, MODE_EMA, PRICE_CLOSE, i);
     }
   for(i = 0; i < limit; i++)
     {
        EMA = iMAOnArray(FastEMABuffer, Bars, FastEMA, 0, MODE_EMA, i);
        ZeroLagEMAp = FastEMABuffer[i] + FastEMABuffer[i] - EMA;
        EMA = iMAOnArray(SlowEMABuffer, Bars, SlowEMA, 0, MODE_EMA, i);
        ZeroLagEMAq = SlowEMABuffer[i] + SlowEMABuffer[i] - EMA;
        MACDBuffer[i] = ZeroLagEMAp - ZeroLagEMAq;
     }
   for(i = 0; i < limit; i++)
       SignalEMABuffer[i] = iMAOnArray(MACDBuffer, Bars, SignalEMA, 0, MODE_EMA, i);
   for(i = 0; i < limit; i++)
     {
       EMA = iMAOnArray(SignalEMABuffer, Bars, SignalEMA, 0, MODE_EMA, i);
       SignalBuffer[i] = SignalEMABuffer[i] + SignalEMABuffer[i] - EMA;

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

 
Make two files.
 
calvat: wish to separate the macd zero lag into one indicator that only shows the MACD zero lag line and an indicator that only shows the signal line.
Two windows,two indicators, two files.
 

Thanks guys!

 Im trying to make two files but i fail to separate the MACD line from the Signal line in the code it self. Do you know what part of the code to split up into the two files? 

 
calvat:

Thanks guys!

 Im trying to make two files but i fail to separate the MACD line from the Signal line in the code it self. Do you know what part of the code to split up into the two files? 

Just copy file.

In first set like this

 SetIndexStyle(0, DRAW_NONE); 
   SetIndexStyle(1, DRAW_LINE,EMPTY); 

 

 

in second like

 SetIndexStyle(0, DRAW_LINE,EMPTY); 
   SetIndexStyle(1, DRAW_NONE); 
 

Thank you eevviill !

 

I wasnt accurate enough in the description. But i wish the sperate the values from each other. In the method you suggested one line get hidden from the chart, but the output value is still there. I managed to get rid of the signal line. But cant figure out how to isolate and only get the Signal line as an indicator.  

 As you may see in the pic below, the value in the MACD only line is separated and i wish to to the same with the Signal line. Not only in the grafics. 

 

 
SetIndexLabel(0, "MACD");
change on
SetIndexLabel(0, ""); or SetIndexLabel(0, NULL);
etc.
 
Thank you so much eevviill!
 
calvat:
Thank you so much eevviill!
My pleasure.
Reason: