Deal model represents an executed deal or transaction in the MetaTrader 5 platform, including trades, deposits, credits, and other balance operations.
Properties
Unique deal ticket number
Deal entry typeAllowed values:
0- In market1- Out of market2- Reverse3- Closed by hedged position
Deal placement reasonAllowed values:
0- Deal placed manually1- Deal placed by expert2- Deal placed by dealer3- Deal placed due to SL (Stop Loss)4- Deal placed due to TP (Take Profit)5-15- Other reasons16- Deal placed manually by mobile terminal17- Deal placed manually by web terminal
Deal action typeAllowed values:
0- Buy1- Sell2- Deposit operation3- Credit operation4- Additional charges5- Correction deals6- Bonus7- Commission
Deal typeAllowed values:
0- Buy1- Sell4- Charge6- Balance7- Commission
Deal type as a human-readable string
Trading symbol (e.g., “EURUSD”)
Deal volume in lots
Deal execution time
Deal execution price
Deal comment or note
Stop Loss level
Take Profit level
Profit/Loss amount
Commission charged for the deal
Swap (rollover) amount
Example
Deal Entry Types
| Value | Description |
|---|---|
| 0 | In market - Position opening or increasing |
| 1 | Out of market - Position closing or decreasing |
| 2 | Reverse - Position reversal |
| 3 | Closed by hedged position |
Deal Reasons
| Value | Description |
|---|---|
| 0 | Deal placed manually |
| 1 | Deal placed by expert advisor |
| 2 | Deal placed by dealer |
| 3 | Deal triggered by Stop Loss |
| 4 | Deal triggered by Take Profit |
| 16 | Deal placed manually by mobile terminal |
| 17 | Deal placed manually by web terminal |
Deal Actions
| Value | Description |
|---|---|
| 0 | Buy |
| 1 | Sell |
| 2 | Deposit operation |
| 3 | Credit operation |
| 4 | Additional charges |
| 5 | Correction deals |
| 6 | Bonus |
| 7 | Commission |
Methods
The Deal model provides getter and setter methods for all properties:getTicket()/setTicket($ticket)- Get/set the deal ticketgetEntry()/setEntry($entry)- Get/set the entry typegetReason()/setReason($reason)- Get/set the deal reasongetAction()/setAction($action)- Get/set the deal actiongetType()/setType($type)- Get/set the deal typegetTypeStr()/setTypeStr($type_str)- Get/set the type stringgetSymbol()/setSymbol($symbol)- Get/set the symbolgetLots()/setLots($lots)- Get/set the volumegetTime()/setTime($time)- Get/set the execution timegetPrice()/setPrice($price)- Get/set the execution pricegetComment()/setComment($comment)- Get/set the commentgetSl()/setSl($sl)- Get/set the Stop LossgetTp()/setTp($tp)- Get/set the Take ProfitgetPl()/setPl($pl)- Get/set the profit/lossgetCommission()/setCommission($commission)- Get/set the commissiongetSwap()/setSwap($swap)- Get/set the swap