Skip to content

Deal Properties

Deal Properties

A deal is the reflection of the fact of a trade operation execution based on an order that contains a trade request. Each trade is described by properties that allow to obtain information about it. In order to read values of properties, functions of the HistoryDealGet…() type are used, that return values from corresponding enumerations.

For the function HistoryDealGetInteger()

ENUM_DEAL_PROPERTY_INTEGER

IdentifierDescriptionType
DEAL_TICKETDeal ticket. Unique number assigned to each deallong
DEAL_ORDERDeal order numberlong
DEAL_TIMEDeal timedatetime
DEAL_TIME_MSCThe time of a deal execution in milliseconds since 01.01.1970long
DEAL_TYPEDeal typeENUM_DEAL_TYPE
DEAL_ENTRYDeal entry - entry in, entry out, reverseENUM_DEAL_ENTRY
DEAL_MAGICDeal magic number (see ORDER_MAGIC)long
DEAL_REASONThe reason or source for deal executionENUM_DEAL_REASON
DEAL_POSITION_IDIdentifier of a position, in the opening, modification or closing of which this deal took part. Each position has a unique identifier that is assigned to all deals executed for the symbol during the entire lifetime of the position.long

For the function HistoryDealGetDouble()

ENUM_DEAL_PROPERTY_DOUBLE

IdentifierDescriptionType
DEAL_VOLUMEDeal volumedouble
DEAL_PRICEDeal pricedouble
DEAL_COMMISSIONDeal commissiondouble
DEAL_SWAPCumulative swap on closedouble
DEAL_PROFITDeal profitdouble
DEAL_FEEFee for making a deal charged immediately after performing a dealdouble
DEAL_SLStop Loss level

- Entry and reversal deals use the Stop Loss values from the original order based on which the position was opened or reversed
- Exit deals use the Stop Loss of a position as at the time of position closing
double
DEAL_TPTake Profit level

- Entry and reversal deals use the Take Profit values from the original order based on which the position was opened or reversed
- Exit deals use the Take Profit value of a position as at the time of position closing
double

For the function HistoryDealGetString()

ENUM_DEAL_PROPERTY_STRING

IdentifierDescriptionType
DEAL_SYMBOLDeal symbolstring
DEAL_COMMENTDeal commentstring
DEAL_EXTERNAL_IDDeal identifier in an external trading system (on the Exchange)string

Each deal is characterized by a type, allowed values are enumerated in ENUM_DEAL_TYPE. In order to obtain information about the deal type, use the HistoryDealGetInteger() function with the DEAL_TYPE modifier.

ENUM_DEAL_TYPE

IdentifierDescription
DEAL_TYPE_BUYBuy
DEAL_TYPE_SELLSell
DEAL_TYPE_BALANCEBalance
DEAL_TYPE_CREDITCredit
DEAL_TYPE_CHARGEAdditional charge
DEAL_TYPE_CORRECTIONCorrection
DEAL_TYPE_BONUSBonus
DEAL_TYPE_COMMISSIONAdditional commission
DEAL_TYPE_COMMISSION_DAILYDaily commission
DEAL_TYPE_COMMISSION_MONTHLYMonthly commission
DEAL_TYPE_COMMISSION_AGENT_DAILYDaily agent commission
DEAL_TYPE_COMMISSION_AGENT_MONTHLYMonthly agent commission
DEAL_TYPE_INTERESTInterest rate
DEAL_TYPE_BUY_CANCELEDCanceled buy deal. There can be a situation when a previously executed buy deal is canceled. In this case, the type of the previously executed deal (DEAL_TYPE_BUY) is changed to DEAL_TYPE_BUY_CANCELED, and its profit/loss is zeroized. Previously obtained profit/loss is charged/withdrawn using a separated balance operation
DEAL_TYPE_SELL_CANCELEDCanceled sell deal. There can be a situation when a previously executed sell deal is canceled. In this case, the type of the previously executed deal (DEAL_TYPE_SELL) is changed to DEAL_TYPE_SELL_CANCELED, and its profit/loss is zeroized. Previously obtained profit/loss is charged/withdrawn using a separated balance operation
DEAL_DIVIDENDDividend operations
DEAL_DIVIDEND_FRANKEDFranked (non-taxable) dividend operations
DEAL_TAXTax charges

Deals differ not only in their types set in ENUM_DEAL_TYPE, but also in the way they change positions. This can be a simple position opening, or accumulation of a previously opened position (market entering), position closing by an opposite deal of a corresponding volume (market exiting), or position reversing, if the opposite-direction deal covers the volume of the previously opened position.

All these situations are described by values from the ENUM_DEAL_ENTRY enumeration. In order to receive this information about a deal, use the HistoryDealGetInteger() function with the DEAL_ENTRY modifier.

ENUM_DEAL_ENTRY

IdentifierDescription
DEAL_ENTRY_INEntry in
DEAL_ENTRY_OUTEntry out
DEAL_ENTRY_INOUTReverse
DEAL_ENTRY_OUT_BYClose a position by an opposite one

The reason for deal execution is contained in the DEAL_REASON property. A deal can be executed as a result of triggering of an order placed from a mobile application or an MQL5 program, as well as as a result of the StopOut event, variation margin calculation, etc. Possible values of DEAL_REASON are described in the ENUM_DEAL_REASON enumeration. For non-trading deals resulting from balance, credit, commission and other operations, DEAL_REASON_CLIENT is indicated as the reason.

ENUM_DEAL_REASON

IdentifierDescription
DEAL_REASON_CLIENTThe deal was executed as a result of activation of an order placed from a desktop terminal
DEAL_REASON_MOBILEThe deal was executed as a result of activation of an order placed from a mobile application
DEAL_REASON_WEBThe deal was executed as a result of activation of an order placed from the web platform
DEAL_REASON_EXPERTThe deal was executed as a result of activation of an order placed from an MQL5 program, i.e. an Expert Advisor or a script
DEAL_REASON_SLThe deal was executed as a result of Stop Loss activation
DEAL_REASON_TPThe deal was executed as a result of Take Profit activation
DEAL_REASON_SOThe deal was executed as a result of the Stop Out event
DEAL_REASON_ROLLOVERThe deal was executed due to a rollover
DEAL_REASON_VMARGINThe deal was executed after charging the variation margin
DEAL_REASON_SPLITThe deal was executed after the split (price reduction) of an instrument, which had an open position during split announcement
DEAL_REASON_CORPORATE_ACTIONThe deal was executed as a result of a corporate action: merging or renaming a security, transferring a client to another account, etc.
Last updated on