total order open time

 

Hi all,


I need help creating a code, whereI want to close if my order is open for more than 7 days to include in my EA.

I am trying to use OderOpenTime() function but not able to calculate till current time to get the no days difference.


Please suggest some code / function where I can calculate the number of days and check with the open order date and close the trade if it is open for more than 7 days. 


thanks in advance.  

 
hrishikeshr1:

Hi all,


I need help creating a code, whereI want to close if my order is open for more than 7 days to include in my EA.

I am trying to use OderOpenTime() function but not able to calculate till current time to get the no days difference.


Please suggest some code / function where I can calculate the number of days and check with the open order date and close the trade if it is open for more than 7 days. 


thanks in advance.  

(TimeCurrent()-OrderOpenTime())>(7*24*3600) ... close the order
 
hrishikeshr1: if my order is open for more than 7 days
  1. Mladen Rakic's suggestion tests if the order has been open for more than seven calendar days (includes weekends/market holidays.)
  2. If you want trading days, then use the MT5 equivalent of iBarShift(D1)
Reason: