Hour() or Minute() print always 0

M4STR0
25
M4STR0  

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?

Keith Watford
Moderator
29969
Keith Watford  
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?

andrew
437
andrew  
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?
M4STR0
25
M4STR0  
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?

Marco vd Heijden
Moderator
13500
Marco vd Heijden  
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
Moderator
29969
Keith Watford  
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.