Skip to content

Position profit and equity calculation#

MetaApi retrieves position profits only on initial terminal state initialization and when a trade happens. In between these moments of time, the position profits and equities are calculated based on current price and tick value as described below. This solution is implemented in order to reduce traffic between metatrader terminal and application when synchronizing terminal state. You can use the same approach so that you do not have to constantly query MetaApi for position profits and account equity.

Position profit calculation#

The total profit of the position is considered the sum of the profit of the already closed part (realized) of the position and the profit of the still open part of the position (unrealized).

profit = realized profit + unrealized profit

Profit from the unclosed part of the position (unrealized) is calculated as the product of the current tick value by the position volume and the difference between the current price and opening price, divided by tick size

                           (current position price - open position price) * current tick value * position volume
unrealized profit = sign * --------------------------------------------------------------------------------------
                                                                  tick size                                       

The current position price is bid if it is a purchase or ask if a sale

The sign is +1 if position is a buy position, otherwise the sign value is -1.

The current tick value used depends on the position profitability. For profitable positions you should use profitTickValue field value. For loosing positions you should use lossTickValue field value.

Account equity calculation#

equity is the previous equity and the sum of all increments

equity = current account equity + sum of increments

increment is the difference between current unrealized profit and previous unrealized profit

increment = current unrealized profit - previous unrealized profit