MT4 Get sma price of candle open
On a chart or in MQL code?
If on the chart then simply apply a Simple Moving Average to the chart and choose the Open price instead of Close price.
If in coding then use the iMA() function with the PRICE_OPEN applied price and a MODE_SMA method.
- docs.mql4.com
On a chart or in MQL code?
If on the chart then simply apply a Simple Moving Average to the chart and choose the Open price instead of Close price.
If in coding then use the iMA() function with the PRICE_OPEN applied price and a MODE_SMA method.
Hello, for the mql4 code, I do not think it is working correctly because at the 4 hour open of the new day candle today for EURUSD the sma 5 open price in mql4/mt4 says 0.9726, where other charts say 0.97416 area..
double sma5 = iMA(_Symbol, _Period, 5, 0, MODE_SMA, PRICE_OPEN, 0);
double sma5 = iMA(_Symbol, _Period, 5, 0, MODE_SMA, PRICE_OPEN, 0);
What other charts? Don't compare with other platforms. Forex is not a centralised exchange. Quotes are different between platforms, between brokers and even between different type of accounts.
What other charts? Don't compare with other platforms. Forex is not a centralised exchange. Quotes are different between platforms, between brokers and even between different type of accounts.
Can anyone tell me how to get the sma price at candle open only, and I don't want the value to change. For example a new candle has opened and I have an sma20, I want to get the value of the sma20 at open only and not after it changes, not the normal sma20 price but only at candle open.
Regards.