Skip to content

Position Properties

Position Properties

Execution of trade operations results in the opening of a position, changing of its volume and/or direction, or its disappearance. Trade operations are conducted based on orders, sent by the OrderSend() function in the form of trade requests. For each financial security (symbol) only one open position is possible. A position has a set of properties available for reading by the PositionGet…() functions.

For the function PositionGetInteger()

ENUM_POSITION_PROPERTY_INTEGER

IdentifierDescriptionType
POSITION_TICKETPosition ticket. Unique number assigned to each newly opened position. It usually matches the ticket of an order used to open the position except when the ticket is changed as a result of service operations on the server, for example, when charging swaps with position re-opening. To find an order used to open a position, apply the POSITION_IDENTIFIER property.

POSITION_TICKET value corresponds to MqlTradeRequest::position.
long
POSITION_TIMEPosition open timedatetime
POSITION_TIME_MSCPosition opening time in milliseconds since 01.01.1970long
POSITION_TIME_UPDATEPosition changing timedatetime
POSITION_TIME_UPDATE_MSCPosition changing time in milliseconds since 01.01.1970long
POSITION_TYPEPosition typeENUM_POSITION_TYPE
POSITION_MAGICPosition magic number (see ORDER_MAGIC)long
POSITION_IDENTIFIERPosition identifier is a unique number assigned to each re-opened position. It does not change throughout its life cycle and corresponds to the ticket of an order used to open a position.

Position identifier is specified in each order (ORDER_POSITION_ID) and deal (DEAL_POSITION_ID) used to open, modify, or close it. Use this property to search for orders and deals related to the position.

When reversing a position in netting mode (using a single in/out trade), POSITION_IDENTIFIER does not change. However, POSITION_TICKET is replaced with the ticket of the order that led to the reversal. Position reversal is not provided in hedging mode.
long
POSITION_REASONThe reason for opening a positionENUM_POSITION_REASON

For the function PositionGetDouble()

ENUM_POSITION_PROPERTY_DOUBLE

IdentifierDescriptionType
POSITION_VOLUMEPosition volumedouble
POSITION_PRICE_OPENPosition open pricedouble
POSITION_SLStop Loss level of opened positiondouble
POSITION_TPTake Profit level of opened positiondouble
POSITION_PRICE_CURRENTCurrent price of the position symboldouble
POSITION_SWAPCumulative swapdouble
POSITION_PROFITCurrent profitdouble

For the function PositionGetString()

ENUM_POSITION_PROPERTY_STRING

IdentifierDescriptionType
POSITION_SYMBOLSymbol of the positionstring
POSITION_COMMENTPosition commentstring
POSITION_EXTERNAL_IDPosition identifier in an external trading system (on the Exchange)string

Direction of an open position (buy or sell) is defined by the value from the ENUM_POSITION_TYPE enumeration. In order to obtain the type of an open position use the PositionGetInteger() function with the POSITION_TYPE modifier.

ENUM_POSITION_TYPE

IdentifierDescription
POSITION_TYPE_BUYBuy
POSITION_TYPE_SELLSell

The reason for opening a position is contained in the POSITION_REASON property. A position can be opened as a result of activation of an order placed from a desktop terminal, a mobile application, by an Expert Advisor, etc. Possible values of POSITION_REASON are described in the ENUM_POSITION_REASON enumeration.

ENUM_POSITION_REASON

IdentifierDescription
POSITION_REASON_CLIENTThe position was opened as a result of activation of an order placed from a desktop terminal
POSITION_REASON_MOBILEThe position was opened as a result of activation of an order placed from a mobile application
POSITION_REASON_WEBThe position was opened as a result of activation of an order placed from the web platform
POSITION_REASON_EXPERTThe position was opened as a result of activation of an order placed from an MQL5 program, i.e. an Expert Advisor or a script
Last updated on