How to set a expiration time for pending order ?

 

hi

how can i set e expiration  time for pending order ?

i want to set a expiration time of 60 second from the time that the order get to the stop price and  executed ( not from the time that i made the order


i tried that  but its retun me a error " invaild  expiration " 

         request.type_time=ORDER_TIME_SPECIFIED;
         request.expiration=60;
 
Netanel Tanami:

hi

how can i set e expiration  time for pending order ?

i want to set a expiration time of 60 second from the time that the order get to the stop price and  executed ( not from the time that i made the order


i tried that  but its retun me a error " invaild  expiration " 

request.expiration

is a datetime data type


https://www.mql5.com/en/docs/constants/structures/mqltraderequest

Documentation on MQL5: Constants, Enumerations and Structures / Data Structures / Trade Request Structure
Documentation on MQL5: Constants, Enumerations and Structures / Data Structures / Trade Request Structure
  • www.mql5.com
Trade Request Structure - Data Structures - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Sardion Maranatha:

is a datetime data type


https://www.mql5.com/en/docs/constants/structures/mqltraderequest

ok, how i add 60 second to this varible ? i need it 60 second from the moment that the order get trigered not placed

 
Netanel Tanami:

ok, how i add 60 second to this varible ? i need it 60 second from the moment that the order get trigered not placed

Catch the time from OnTrade event when order is triggered..and do time comparison between trigger time and next 60 seconds..but if a pending order is triggered(executed) the request expiration is not applicable anymore unless i misunderstood your intention
 
Sardion Maranatha:
Catch the time from OnTrade event when order is triggered..and do time comparison between trigger time and next 60 seconds..but if a pending order is triggered(executed) the request expiration is not applicable anymore unless i misunderstood your intention

i want to place a pending  stop order with deviation of 50 point and if the order triggered(executed) and the order wasn't full lot executed at the next 60 second so cancel the order 

 
Netanel Tanami:

i want to place a pending  stop order with deviation of 50 point and if the order triggered(executed) and the order wasn't full lot executed at the next 60 second so cancel the order 

Then OnTrade event is the best route to catch the execution time
 
Sardion Maranatha:
Then OnTrade event is the best route to catch the execution time

plz can you give me example how to use the on trade to the expiration ? 

after i place the order i close the EA so no EA will run the set the time when the order  triggered(executed)