Download MetaTrader 5

Easiest way to halt trading on stop loss being hit? - page 2

To add comments, please log in or register
Dominic Gilbert
1639
Dominic Gilbert  

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
1399
SYED NAUFAL GADDAFI  
Just for clarification, why the round up? Though I kinda knew the answer already.
honest_knave
Moderator
2333
honest_knave  
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
15725
whroeder1  
honest_knave: There are many different ways, here is one:
round number - MQL4 forum
12
To add comments, please log in or register