How to get iMACD from MT4 to MT5
-
Hi everyone and all the experts @jstap @l-andorrà @roar ,
I am trying to convert MT4 to MT5, however, the iMACD value in "custom MQL mode" is not well converted. I tried to look up on MQL5 website, but I could not get it right.
So basically,
iMACD in MT4:iMACD(_Symbol,PERIOD_CURRENT,12,26,9,PRICE_CLOSE,MODE_MAIN,0);
but in MT5, the main line and candle shift are not included (the last two functions in bracket). see below.
iMACD(_Symbol,PERIOD_CURRENT,12,26,9,PRICE_CLOSE);
Anyone have any idea how to convert this iMACD from MQL4 to MQL5 that include the main line and candle shift?
Thanks in advance!
-
@andrewfrank indicators work very differently on mql5. It would be easier to just use the "modify variables" block rather than custom code, when getting indicator outputs.
But if you do it the custom way, you must first "load" the MACD indicator with the code you mentioned, and then use CopyBuffer() function to read some value from that indicator.
-
@roar how do you use CopyBuffer function in this case?
iMACD(_Symbol,PERIOD_CURRENT,12,26,9,PRICE_CLOSE);
CopyBuffer(handle,0,0,20,MACDBuffer)is 20 in this particular example candle shift?
I'm thinking to make a loop with this, so I was wondering which one is the candle shift..I saw something like this from MQL5 websites:
