Limit/Stop Orders Expiry dates

 

i've had the most difficult time trying to get my Limit/Stop Orders to expire using this code

rderSend(Symbol(),OP_BUYSTOP,Lots,Ask+(9*Point),3,Ask-(SL*Point),Ask+(TakeProfit*Point),"Cross Buy",16384,xxxxxxxx,Lime);

xxxxxx= "Expirydate = Cur time+ expected Lenghth"

i want to know how i can achieve this.

thanks

 

Let us say you want the trade to expire after 3 hours and 35 minutes

you defin the hours and minutes as at the start of the code

extern int TradeLifeHour=3;

extern int TradeLifeMin=45;

then you define

datetime expirationtime;

then within start() you say

expirationtime = CurTime()+TradeLifeHour*60*60+TradeLifeMin*60;

now use expirationtime in that XXXXXXXXXXXXXXXXXX area.

Hope this helps.

Reason: