Script OrderSend with expiry datetime


I am new to this scripting and I’m currently implementing a Order script which helps me to insert orders.

My question is on the expiry datetime. I have noticed that at pending orders, I can set the expiry datetime. But when it get into positions, I couldn’t modify it.

Do the expiry datetime applied to orders that are in position?

I couldn’t find anything about expiry datetime for orders that are in positions on the web.

Your help is much appreciated. Thanks in advance.


Expiry is only for pending orders.

Once it got into position the expiry datetime will be automatically null?

Thanks for your quick response. Sorry for stupid question.


When your pending order becomes a market order, expiry time is irrelevant. An open order cannot have an “expiry time” unless you code something yourself.

In MQL4, the value of OrderExpiration() is reset to 0 (midnight 01 January 1970) when the pending order becomes a market order.

Presumably it is similar behaviour in MQL5, although order handling is somewhat different.

I see.

Thank you very much for your clarification