how to get the order status

 

how to get the order status

for example,i want to get the condition if my order is purchased



if (OrderSelect(_orderIdBuy, SELECT_BY_TICKET) == true)
{
if (OrderType())
{
OrderModify();
break;
}
}


but,i do not know the returns value of OrderType.

 
plglenn:

how to get the order status

for example,i want to get the condition if my order is purchased



if (OrderSelect(_orderIdBuy, SELECT_BY_TICKET) == true)
{
if (OrderType())
{
OrderModify();
break;
}
}


but,i do not know the returns value of OrderType.

OrderType() function returns the following results:

OP_BUY, OP_SELL, OP_BUYSTOP, OP_BUYLIMIT, OP_SELLSTOP, OP_SELLLIMIT

If your order is opened it will reutrn either OP_BUY or OP_SELL. The other results are for pending orders that may be executed in the future.

 

when i order send a pending order,

in your idea,i can use follow code:


if(OrderType()==OP_BUY)

,is it right to stand for this tickte has purchased successfully.thank u

 
plglenn:

when i order send a pending order,

in your idea,i can use follow code:


if(OrderType()==OP_BUY)

,is it right to stand for this tickte has purchased successfully.thank u

If you initially sent a pending order and then its OrderType()==OP_BUY this means it is not a pending order anymore. It purchased successfully.

But I recommend to use also OrderSymbol() and OrderMagicNumber() to make sure you select the correct trade, opened by your EA not by another EA or person.