Question about iMACD.

 

I'm trying to write a custom indicator that uses iMACD and i'm running into some trouble.



Why are the values in iMACD slightly (but significantly) different than in the metatrader equipped MACD indicator?

Also, for some reason in the EA I'm making when i run:


iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0);


... and attach that to a global variable (MACDprevious, for our purposes), and then the next tick i run:


iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1);


... its sometimes (usually) a slightly but significantly different value than MACDprevious?



new to the forum, thanks all

 

First question: don't know, except the code must not be equivalent.

Second question:

You are comparing values calculated for the current unfinished bar (bar 0) vs the most recent fully completed bar (bar 1) .

Reason: