How can I Close an untriggered Pending-order based on time..

 

Hie Guys,

May anyone help, I would like to code a Line that Closes/Deletes a Pending order,

if not triggered, after a certain period of time (say 20 seconds). I have inserted question marks (?????)

in the code below, indicating where I would like to insert the line.

//-----

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderSymbol() == symbol && OrderMagicNumber()==Magicbuy)

{

if ( ???????????) // checks if 20 seconds has elapsed since opening order.....

{

OrderDelete(order_ticket);

return(0);

}

//-----

Thank you...

 
080781:

Hie Guys,

May anyone help, I would like to code a Line that Closes/Deletes a Pending order,

if not triggered, after a certain period of time (say 20 seconds). I have inserted question marks (?????)

in the code below, indicating where I would like to insert the line.

<CODE REMOVED>

Please read some other posts before posting . . .

Please edit your post . . . please use the SRC button to post code: How to use the SRC button.

 
080781:

Hie Guys,

May anyone help, I would like to code a Line that Closes/Deletes a Pending order,

if not triggered, after a certain period of time (say 20 seconds). I have inserted question marks (?????)

in the code below, indicating where I would like to insert the line.

Check it's OrderType() to make sure it is a pending order that you are going to try and close . . . then check it's OrderOpenTime() against TimeCurrent() . . . 20 seconds is too short, sometimes there can be no ticks for more than 20 seconds, what then ?
 
and how far do you think the market moves is 20 seconds? You can't place a pending order too close to the market.
Reason: