Getting Simple Moving Average of last candle

 

Hi Guys,

I need to get the Moving Average value at the previous candle. I want to extract the value at the middle of candle.


Currrently I have this code (MQL4):

lastCandleMA = NormalizeDouble(iMA(_Symbol, _Period, MA_Period, 0, MA_Method, PRICE_CLOSE, 1), Digits);

The returned value of the code execution is not the same as I can see throught the chart. When I draw a vertical line at the chart it goes to the middle of candle automaticaly. I have checked the value at the MA line and it's not the same or slighly diferent.

Which direction should I take?

 

I don't know if I've understood what you're looking for, but you can use PRICE_MEDIAN instead of PRICE_CLOSE. You can see the price constants available here. Best regards.

Price Constants - Indicator Constants - Constants, Enumerations and Structures - MQL4 Reference
Price Constants - Indicator Constants - Constants, Enumerations and Structures - MQL4 Reference
  • docs.mql4.com
Price Constants - Indicator Constants - Constants, Enumerations and Structures - MQL4 Reference
Reason: