Hour() or Minute() print always 0

 

Hello gentlemens,

I am facing an issue, I want to know the hour and minutes values on every candle.

After placing:

      if(OnNewBar())
      {
        Print(Hour());
        Print(Minute());
.....

I always get 0 value, am I doing something wrong here?

 
M4STR0:

Hello gentlemens,

I am facing an issue, I want to know the hour and minutes values on every candle.

After placing:

I always get 0 value, am I doing something wrong here?

Is it on the daily chart?

 
M4STR0:

Hello gentlemens,

I am facing an issue, I want to know the hour and minutes values on every candle.

After placing:

I always get 0 value, am I doing something wrong here?

Hour() gets it's value from server TimeCurrent()'and market closed over weekend?
 
Keith Watford:

Is it on the daily chart?

Yes was testing on daily chart, I guess hour and minutes works in different time periods? I did test on 1h range and it prints the hours, minutes and day of the week :)


Andrew, I am doing this test now when market is closed. TimeCurrent() I have not played with, you think is better to have proper times data?

 
int hour = TimeHour(TimeCurrent());

But market is closed so it's not moving atm.

Click
TimeHour - Date and Time - MQL4 Reference
TimeHour - Date and Time - MQL4 Reference
  • docs.mql4.com
TimeHour - Date and Time - MQL4 Reference
 
Keith Watford:

Is it on the daily chart?

M4STR0:

Yes was testing on daily chart, I guess hour and minutes works in different time periods? I did test on 1h range and it prints the hours, minutes and day of the week :)

Your code suggests that it should only print when a new bar opens.

A new daily bar opens at 00:00, so unless there are no ticks for the first minute, of course hour and minutes will be 0.

Reason: