Moving average issue

 

Hi great Folks!!! Hope all is well. It seems like automation and coding just never ends as errors ever present. Kindly assist with fixing an issue with the moving average. Code is written to read exponential moving average at current and at a prior shifted value to determine bullish or bearish trend. However, the code attached returns the same values regardless of pair and time frame and always reads BULLISH( Current is always greater than Prior). Any help will be highly appreciated. A link, a tutorial,,, 


 //
  double anch_pri=iMA(Symbol(),PERIOD_H4,72,36,MODE_EMA,PRICE_TYPICAL);   // Prior MA reading
  double anch_cur=iMA(Symbol(),PERIOD_H4,72,0,MODE_EMA,PRICE_TYPICAL);    // Current MA reading
  //  

Thank you much!!!!! Great day yo"all!!

 
Kenneth Njuguna:

Hi great Folks!!! Hope all is well. It seems like automation and coding just never ends as errors ever present. Kindly assist with fixing an issue with the moving average. Code is written to read exponential moving average at current and at a prior shifted value to determine bullish or bearish trend. However, the code attached returns the same values regardless of pair and time frame and always reads BULLISH( Current is always greater than Prior). Any help will be highly appreciated. A link, a tutorial,,, 


Thank you much!!!!! Great day yo"all!!

you need to assign a handle in the init function using the function you used

MT5 is not the same logic as MT4

and then use copyBuffer when you need to retrieve the actual MA data

 
Jean Francois Le Bas:

you need to assign a handle in the init function using the function you used

MT5 is not the same logic as MT4

and then use copyBuffer when you need to retrieve the actual MA

Much appreciated  Jean Francois Le Bas,,, Thanks!!

Reason: