order status

 

how do i know if pending order had allredy open ?

the orderselect() is for opening or pending order .

do i have to catch it by comparing the open price ?

 
if(OrderType()==OP_BUY || OrderType()==OP_SELL){
  //ORDER IS OPEN
}
//z
 
gabriel3:

how do i know if pending order had allredy open ?

If OrderSend() returns a ticket number you know that it is open. If it returns -1 there was an error and you should use GetLastError() to see what it was.


You should also think about using the reliable ordersend functions from libOrderReliable.mqh or the ones from common_functions.mqh which already do some error handling and retrying and make it much more unlikely that the order is not opened due to some temporary error.


Run your EA on Alpari demo for one week in a row to see what kinds of funny errors that you have never seen before can happen, this demo server can be used as some kind of stress test, I don't know of any other demo server that is so unreliable and difficult. If your EA can survive one week on Alpari Demo without problems it can be considered as fully debugged.

 

zzuegg is right.

You placed an order and you know it's ticket (OrderSend() returns ticket of the order). Use OrderSelect( order_ticket, SELECT_BY_TICKET ) and check order type. That's it.

 
hasayama:

zzuegg is right.

You placed an order and you know it's ticket (OrderSend() returns ticket of the order). Use OrderSelect( order_ticket, SELECT_BY_TICKET ) and check order type. That's it.


thank you .

this is the best idea .

 
gabriel3:


thank you .

this is the best idea .

now i understand the question: you wanted to know whether it has been filled already! I thought by "open" you just wanted to know whether the initial OrderSend() succeeded at all and the order itself is open (== not canceled).
 

Hi Gabriel,

There is no easy solution to this one. You have to make an ea that loads all the orders into an array and then compares them on the next tick. I have written one that sends email when the order status changes. It is based on the information provided in this article :-

https://www.mql5.com/en/articles/1399