Candel Pending Order on Next Bar

 

Hi,


For example, I code an ea set Buy_limit order on current bar and 4 pips below the open price, If price retrace 4pips then order will get filled. Some times, price move so fast,, and order never get fill. So i would like to cancel the pending order and the next bar start..


Can any one give me some tips to do it..


Thanks

 

yster,

IF pending THEN use OrderDelete()

https://book.mql4.com/trading/orderclose

About 1/2 way down page you will see:

"Trade requests for deleting of pending orders are formed using the function OrderDelete()."

.

suggest that while on this page, you start at top and work way down.

much useful learning available.

Best

 
yster:

Hi,


For example, I code an ea set Buy_limit order on current bar and 4 pips below the open price, If price retrace 4pips then order will get filled. Some times, price move so fast,, and order never get fill. So i would like to cancel the pending order and the next bar start..


Can any one give me some tips to do it..


Thanks

You can just use the expiration time when you send the order. Your desired expiration is: Time[0]+Period()*60

...in words the time of opening of the current bar + the time sampling of the chart you are using converted in seconds.

The order will automatically expire on the server, no need to take care of it with OrderDelete() function ;)



Cheers,

Zyp