Forex Factory (https://www.forexfactory.com/)
-   Platform Tech (https://www.forexfactory.com/forum/69-platform-tech)
-   -   set pending expiration time (https://www.forexfactory.com/thread/56594-set-pending-expiration-time)

pgtips Nov 16, 2007 3:10pm | Post# 1

set pending expiration time
 
Hi,

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,

KevM

Micro-MiniMe Nov 18, 2007 9:08am | Post# 2

Pending Order Expiration Time
 
Hi pgtips,

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:
if(et<660) et=0;

Hope this helps,

pgtips Nov 19, 2007 3:44am | Post# 3

Hi Micro-MiniMe,

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.

Kevin


© Forex Factory