order expire time need help

 

hi i was coded order expire time but it was not working pleas help to slove this problem


if the order has open at 12.25 hour then it has expire ya close at 13.25


pleas help ..

 bool UseTimeOut =TRUE;
 double MaxTradeOpenHours = 1; 
 
    if (UseTimeOut==TRUE) 
     double expiration = TimeCurrent() + 60.0 * (60.0 * MaxTradeOpenHours);
    {
      if (TimeCurrent() >= expiration)
       {
         CloseAll();
         Print("Closed All due to TimeOut");
       }}
       
 

Instead of this . . .

if (TimeCurrent() >= expiration)

you need to check the https://docs.mql4.com/trading/OrderOpenTime

if (OrderOpenTime() <= TimeCurrent() - ( 60.0 * 60.0 * MaxTradeOpenHours))

. . . before you use OrderOpenTime you need to select the correct order . . .

 
RaptorUK:

Instead of this . . .

you need to check the https://docs.mql4.com/trading/OrderOpenTime

. . . before you use OrderOpenTime you need to select the correct order . . .

he its working

thanks for reply . Mr RaptorUK: