How to access MACD indicator buffer

 

Hi, i'm new to mql5 and i'm trying to use MACD indicator.

Here's a part of my code :

 

#include <Expert\Signal\SignalMACD.mqh>

double MACD_Main[];
double MACD_Signal[];
int MACD_handle;

int OnInit()
  {
   MACD_handle=iMACD(Symbol(),0,Signal_MACD_PeriodFast,Signal_MACD_PeriodSlow,Signal_MACD_PeriodSignal,PRICE_CLOSE);
   if(MACD_handle<0)
     {
      Print("The creation of iMACD has failed: Runtime error =",GetLastError());
      return(-1);
     }
}

void OnTick()
  {
   CopyBuffer(MACD_handle,0,0,100,MACD_Main);
   CopyBuffer(MACD_handle,0,0,100,MACD_Signal);
   printf(__FUNCTION__+": MACD = ", MACD_Main[0], " / ", MACD_Signal[0]);
  }
It seems like the buffers (MACD_Main & MACD_Signal) are empty.

 

Maybe there's something missing in my code... 

 

Thanks for helping me! 

 
you code is wrong
use this:
CopyBuffer(MACD_handle,0,0,100,MACD_Main);
CopyBuffer(MACD_handle,1,0,100,MACD_Signal);
 

Yes, you missed. See picture for the CopyBuffer() fucntion