set pending expiration time
this one is throwing me completely, what is the syntax to set a order expiration time, most code I have looked at sets expiration=0 which means keep open until you close it.
Normally you might say I want this to be open for x hours so expiration would be expiration=x
But I want to say "time to close = 15.30" , and so my pending order is closed at 15.50 gmt.
How do i initialise this and plug it in, I have tried everything and am starting to wonder if it is actually possible.
Any examples really appreciated.
Thanks in advance,
Pending Order Expiration Time
The wording of your question had me a bit confused so I will answer in this way.
In MT4 order expiration time is set in seconds. Total seconds in a day = 24hrs*60min*60sec = 86400 seconds/day.
Expiration time only exists for pending orders, not open orders. Once an order is open you would need to write a script to close it at a certain time or a certain time after it becomes an open order.
The code to determine how many seconds until the pending order expires is:
Datetime et =((24-Hour())*60-Minute())*60-Seconds();
//Order expiration must be at least 11 minutes so:
Hope this helps,
thanks for the response. Looking back I didn't word it too well so I'll try again :-)
I want to specify, in the user input box, the time to expire a pending order.
Not as how many hours to stay live for but rather , time to expire = 15:30 (same day in this case).
The math behind it is
time to expire - current time = number of seconds to stay live
What I am having difficulty with though is getting a vlaue out of the calculation which I can pass to the order send line to set a expire time.
Hope this explains a bit more clearly and thanks again for your help.
© Forex Factory