A simpler way to get Hour() value

David Diez
2301
David Diez  

How to write this on MQ5?

if(Spread<MaxSpread&&Hour()>=StartHour&&Hour()<StopHour){

Thank you in advance.

lippmaje
1660
lippmaje  
MqlDateTime mdt;
TimeCurrent(mdt);

if(Spread<MaxSpread && mdt.hour>=StartHour && mdt.hour<StopHour){
David Diez
2301
David Diez  
lippmaje:

It's working, thank you mate.

William Roeder
25046
William Roeder  
David Diez: How to write this on MQ5?
if(Spread<MaxSpread&&Hour()>=StartHour&&Hour()<StopHour){

int     Hour(void         ){ return TimeHour(TimeCurrent()); }
int TimeHour(datetime when){ return when/3600 % 24; }
See also Migrating from MQL4 to MQL5 - MQL5 Articles № 11 17 May 2010