OrderType - Trade Functions - MQL4 Reference

MQL4 Reference Trade Functions OrderType

OrderType

Returns order operation type of the currently selected order.

int  OrderType();

Returned value

Order operation type of the currently selected order. It can be any of the following values:

OP_BUY - buy order,
OP_SELL - sell order,
OP_BUYLIMIT - buy limit pending order,
OP_BUYSTOP - buy stop pending order,
OP_SELLLIMIT - sell limit pending order,
OP_SELLSTOP - sell stop pending order.

Note

The order must be previously selected by the OrderSelect() function.

Example:

  int order_type;
  if(OrderSelect(12, SELECT_BY_POS)==true)
    {
     order_type=OrderType();
     // ...
    }
  else
    Print("OrderSelect() returned error - ",GetLastError());