How can i use the previous MACD value?

 
I wrote a small EA to find how.
int start()
  {
//----
   double MACDCurrent,MACDPrevious;
   MACDCurrent = iMACD(NULL,0,5,13,1,PRICE_CLOSE,MODE_MAIN,0);
   MACDPrevious = iMACD(NULL,0,5,13,1,PRICE_CLOSE,MODE_MAIN,1);
   Print("MACDCurrent is " + MACDCurrent + " and MACDPrevious is " + MACDPrevious);
//----
   return(0);
  }
As you can see, I am printing the values in order. But when i look at logs, MACDPrevious value doesn't match the previous MACDCurrent... How can i take the value of previous MACD? I think my problem is clear.

If it is important i use the following
Symbol: EURUSD
Period: H4
Model: Open prices only (I tried others)
Use date: From 2007.02.01 to 2007.02.07

Thanks...

PS:I looked "MACD Sample" EA that comes with setup and it has the same usage...
 
Your problem is that your code is executed every tick, and that you are getting the MACD value of the previous bar, not the previous tick. Change it to this:

double MACDPrevious = 0;
int start()
  {
//----
   double MACDCurrent;
   MACDCurrent = iMACD(NULL,0,5,13,1,PRICE_CLOSE,MODE_MAIN,0);
   Print("MACDCurrent is " + MACDCurrent + " and MACDPrevious is " + MACDPrevious);
   MACDPrevious = MACDCurrent;
//----
   return(0);
  }
 
Thanks.
Reason: