Download MetaTrader 5
To add comments, please log in or register
MQL5 Reference is available in 8 languages. Learn MQL5 in the language that suits you best!
Eric
153
Eric 2010.05.19 07:18 

hi, i want to check if order is sell orbuy type,and this require an integer...but wich one is buy and wich one the sell? cant find infoin help file...

i can not do this; if (OrderGetInteger(ORDER_TYPE)==ORDER_TYPE_BUY)??somebody can show mewhere i can find int value of a buy and sell order?

the only thing i can see is this...   https://www.mql5.com/en/docs/constants/tradingconstants/orderproperties#enum_order_type 

Identifier

Description

ORDER_TYPE_BUY

Market Buy order

ORDER_TYPE_SELL

Market Sell order

ORDER_TYPE_BUY_LIMIT

Buy Limit pending order

ORDER_TYPE_SELL_LIMIT

Sell Limit pending order

ORDER_TYPE_BUY_STOP

Buy Stop pending order

ORDER_TYPE_SELL_STOP

Sell Stop pending order

ORDER_TYPE_BUY_STOP_LIMIT

Upon reaching the order price, a pending Buy Limit order is places at the StopLimit price

ORDER_TYPE_SELL_STOP_LIMIT

Upon reaching the order price, a pending Sell Limit order is places at the StopLimit price

Identifier

Description

ORDER_TYPE_BUY

Market Buy order

ORDER_TYPE_SELL

Market Sell order

ORDER_TYPE_BUY_LIMIT

Buy Limit pending order

ORDER_TYPE_SELL_LIMIT

Sell Limit pending order

ORDER_TYPE_BUY_STOP

Buy Stop pending order

ORDER_TYPE_SELL_STOP

Sell Stop pending order

ORDER_TYPE_BUY_STOP_LIMIT

Upon reaching the order price, a pending Buy Limit order is places at the StopLimit price

ORDER_TYPE_SELL_STOP_LIMIT

Upon reaching the order price, a pending Sell Limit order is places at the StopLimit price

 thank you

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Order Properties - Documentation on MQL5
Rashid Umarov
Admin
11709
Rashid Umarov 2010.05.19 08:54  

See function OrderGetInteger:

OrderGetInteger

Returns the requested order property, pre-selected using OrderGetTicket or OrderSelect. Order property must be of the datetime, int type. There are 2 variants of the function.

1. Immediately returns the property value.

long  OrderGetInteger(
   ENUM_ORDER_PROPERTY  property_id        // Property identifier
   );

2. Returns true or false depending on the success of the function. If successful, the value of the property is placed into a target variable passed by reference by the last parameter.

bool  OrderGetInteger(
   ENUM_ORDER_PROPERTY  property_id,       // Property identifier
   long&                long_var           // Here we accept the property value
   );

Parameters

property_id

[in]  Identifier of the order property. The value can be one of the values of the ENUM_ORDER_PROPERTY_INTEGER enumeration.

long_var

[out]  Variable of the long type that accepts the value of the requested property.

Return Value

Value of the long type.

Where you can get order type:

ENUM_ORDER_PROPERTY_INTEGER

Identifier

Description

Type

ORDER_TIME_SETUP

Order setup time

datetime

ORDER_TYPE

Order type

ENUM_ORDER_TYPE

ORDER_STATE

Order state

ENUM_ORDER_STATE

ORDER_TIME_EXPIRATION

Order expiration time

datetime

Wackena
648
Wackena 2010.05.19 18:46  

OrderSend() generates and Order > Order closes when Order becomes a Deal > Deal closes when Deal becomes the Position you see in Toolbox/Trade tab.

OrderGetInteger(ORDER_TYPE) is for pending orders. See OrderGetTicket() in MGL5 Reference Manual.

To find ORDER_TYPE of last OrderSend() call from EA or Manual Trade.

This following examples work for EA that opens 1 position at a time per Symbol(). When a position is open, then we want to find ORDER_TYPE of last Deal.  Because there is opposing ORDER_TYPE Deal to close existing open position, we then must look at 2 Deals back to get ORDER_TYPE.

   string LastOrderType;
   uint total=0;
   HistorySelect(0,TimeCurrent()); // Selects all closed Orders and Deals
   total=HistoryDealsTotal(); // Sets "total" to number of all closed Deals
         
   if( PositionSelect(_Symbol) )
      {
         HistoryDealGetTicket(total); // Select Ticket number of last closed Deal
         if( PositionsTotal() > 0 )
            {
               LastOrderType = HistoryDealGetInteger(total,ORDER_TYPE); // Selects ORDER_TYPE of last Deal in the opened position
            }
      }
         else LastOrderType = HistoryDealGetInteger(total-1,ORDER_TYPE); // Selects ORDER_TYPE of 2 Deals back in the last closed position

   Print("LastOrderType ",LastOrderType);

It would easier to used this to find ORDER_TYPE.  ORDER_TYPE remains the same until new opposing  position is opened.

  string LastOrderType;
  if( PositionSelect(_Symbol) )
    {
      if( PositionsTotal() > 0 )
        {
          LastOrderType = PositionGetInteger(ORDER_TYPE);
        }
    }
  Print("LastOrderType ",LastOrderType);



Eric
153
Eric 2010.05.19 20:44  

ok, i'll try to do it short and clear. I only want to check if a pending order is of buy type or sell type.

So when I get the INTeger of the order_type, I can not find to what INTeger to compare it to. For example:

 if (OrderGetInteger(ORDER_TYPE) == 1 )

or 

 if (OrderGetInteger(ORDER_TYPE) == -1 )

it can not be this:

 if (OrderGetInteger(ORDER_TYPE)=="ORDER_TYPE_BUY")  because "ORDER_TYPE_BUY" is a string...

but where can i find the integer value representing a buy and a sell for PENDING ORDER TYPE ?

 

Thank you for trying to explain rosh and wackena but i think you did not understand my question

 

Eric
153
Eric 2010.05.19 21:04  

ok i found the answer... by printing the value of an order type of a sell order i get integer 5 and for a buy order type i get integer 4 .. but i can not find somewhere in the help file these value and i had to check them ..  would be appreciated to have a table with the int value of a integer type

  so i have to write it like this

if (OrderGetInteger(ORDER_TYPE) == 5 )

 would be a sell pending order

 

 

if (OrderGetInteger(ORDER_TYPE) == 4 ) 

would be a buy pending order 

 

but for all property of int type i can not find any INTEGER value in the table ? do we have to check for all ? 

/
To add comments, please log in or register