Download MetaTrader 5
To add comments, please log in or register
Traders have already contributed more than 300 articles. Write your own one!
Dominic Gilbert
1632
Dominic Gilbert 2015.01.24 14:15  

Yea I see. 

 Using this:

if(ClosedBySL) NextOrder = OrderCloseTime()+3600;


 How can I round UP "OrderCloseTime()" to the nearest hour in the example above?

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2015.01.24 14:25  
Just for clarification, why the round up? Though I kinda knew the answer already.
honest_knave
Moderator
1797
honest_knave 2015.01.24 15:11  
DomGilberto:

Yea I see. 

 Using this:


 How can I round UP "OrderCloseTime()" to the nearest hour in the example above?

There are many different ways, here is one:

#define HOUR 3600
...

if(ClosedBySL)
  {
   datetime ClosedAt = OrderCloseTime();
   NextOrder = ClosedAt - (ClosedAt % HOUR) + HOUR;
  }

whroeder1
14199
whroeder1 2015.01.24 17:14  
honest_knave: There are many different ways, here is one:
round number - MQL4 forum
/ /12
To add comments, please log in or register