Download MetaTrader 5

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

To add comments, please log in or register
Having troubles understanding the code? Perhaps, you can find an article on that topic!
kennied5010
12
kennied5010 2013.08.14 13:24 

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...

Simon Gniadkowski
Moderator
17998
Simon Gniadkowski 2013.08.14 13:42  
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.

Simon Gniadkowski
Moderator
17998
Simon Gniadkowski 2013.08.14 13:45  
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 ?
whroeder1
14470
whroeder1 2013.08.14 14:42  
and how far do you think the market moves is 20 seconds? You can't place a pending order too close to the market.
To add comments, please log in or register