I'd like to insert a pending order in my expert advisor on MT4. Here is an example
OrderSend(Symbol(),OP_BUY,1.4,Ask,0,Ask-0.002,Ask+0.004,"Ordine di esempio",123,"expiration date",clrAliceBlue);
Now the problem is that i'd like to set a expiration date. If I put 0 it doesn't expire. But if I'd like to expire it in 2018.07.22 how can I do?
Furthermore can I insert in the same expert advisor 2 OrderSend?
You can create an expiring order if it is not market. So cancel or kill at expiration. If the order is market, it cannot expire, you have to close it by OrderClose()
function when the time is right.
In order to set some expiration time, you have to pass datetime/integer
(seconds) value of it. Something like datetime expiry=StrToTime("2018.07.22 00:00")
and then pass expiry
parameter in the OrderSend()
function; alternative way is to create a timer or check to cancel each tick.