How to Cancel pending orders quickly at news time?

 

Dear developers,

My EA put 2 pending order before the news time. my broker is TRUE ECN and my account also TRUE ECN. I am using MT4.

Buy Stop at : 67.70

Sell Stop at : 67.30

With the news time Sell order activated by moving 22pips. So it placed with next available price. Price 67.30 no longer available and pending order move to next available price 67.08.


So what i want to do with my EA,

If that Sell Stop order price not available for activate as SELL at that exact level(Price moved with high GAP) then close the pending order before it activate. I do not know if it possible or not. But i need to know your knowledge about that. 


I am using following code to put orders.

int ticket=OrderSend(Symbol(),OP_SELLSTOP,1,price,3,stoploss,takeprofit,"My order",16384,0,clrGreen);
//Maximum price slippage for buy or sell orders = 3


Or Is that possible to use Maximum price slippage with SELLSTOP, BUYSTOP orders to handle this?  


Thank you.

 

https://www.mql5.com/en/forum/160410/page2#comment_3818539 Same problem.

"Yes! When you use an EA, you can simulate Pending orders with Market orders and you can actually have much better control with Market Orders than pending orders ever will when done in an EA. In fact, that is what I do in my own EA's and I NEVER use pending orders."


What you think? Any way to implement his idea to my EA?

How to not execute orders during huge slippage?
How to not execute orders during huge slippage?
  • 2016.10.21
  • www.mql5.com
Hello! i just got a much lower price on the stop sell price i placed...
 
Thushara Dissanayake:

close the pending order before it activate. 

not possible. how can you close pending order before you even place it?

try code alternative solution(s) for your system. i.e check pending price condition, before OrderSend()

 
Thushara Dissanayake:

https://www.mql5.com/en/forum/160410/page2#comment_3818539 Same problem.

"Yes! When you use an EA, you can simulate Pending orders with Market orders and you can actually have much better control with Market Orders than pending orders ever will when done in an EA. In fact, that is what I do in my own EA's and I NEVER use pending orders."


What you think? Any way to implement his idea to my EA?

What you are asking for is a Stop-Limit order. You can simulate with an EA by using the following logic. 

if(Bid <= sell_stop_price && !pending_order_exists(OP_SELLLIMIT))
   sell_limit_order(sell_stop_price);