Price in OnCalculate() not showing correctly
2019.11.01 17:32:03.037 TestIndicator (USDJPY,M1) OHLC: 357.73, 357.73, 357.73, 357.73
How come the OHLC price looks like this? I tried it on different symbol and time frame, did I do something wrong? Your help is appreciated. Thanks.
Maybe it's the first tick of a new bar.
Maybe it's the first tick of a new bar.
I did try to run it for couple minutes, and every tick output something like this, although the numbers are not exactly the same, but it's definitely not the price for USDJPY.
Use MQL5 code:
//--- Get the number of bars available for the current symbol and chart period //int bars=Bars(Symbol(),0); // you don’t need to do this - use "rates_total" in the indicator Print("rates_total = ",IntegerToString(rates_total), ", prev_calculated = ",IntegerToString(prev_calculated)); Print("time[rates_total-1] = ",TimeToString(time[rates_total-1],TIME_DATE|TIME_SECONDS)); Print("OHLC: ", DoubleToString(open[rates_total-1],Digits()), ", ", DoubleToString(high[rates_total-1],Digits()), ", ", DoubleToString(low[rates_total-1],Digits()), ", ", DoubleToString(close[rates_total-1],Digits())); //--- return value of prev_calculated for next call return(rates_total);
Use MQL5 code:
Thanks, I will try it out.
I modified a sample code from MQL5 documentation to look like the following
The output print something like this
2019.11.01 17:32:03.037 TestIndicator (USDJPY,M1) OHLC: 357.73, 357.73, 357.73, 357.73
How come the OHLC price looks like this? I tried it on different symbol and time frame, did I do something wrong? Your help is appreciated. Thanks.