Discussion of article "Market math: profit, loss and costs"

 

New article Market math: profit, loss and costs has been published:

In this article, I will show you how to calculate the total profit or loss of any trade, including commission and swap. I will provide the most accurate mathematical model and use it to write the code and compare it with the standard. Besides, I will also try to get on the inside of the main MQL5 function to calculate profit and get to the bottom of all the necessary values from the specification.

To develop an efficient trading system, first of all, it is necessary to understand how the profit or loss of each order is calculated. We are all able to calculate our profits and losses somehow to maintain our money management system. Someone does that intuitively, someone performs rough estimations, but almost any EA has the necessary calculations of all the necessary quantities.

The image below develops the idea further making it easier to understand. It shows opening and closing two types of market orders:

buy & sell

Author: Evgeniy Ilin

 

I would like to point out that there is a major flaw regarding the calculations of profit/loss in this article.

You are using Tick Value and Point Size together. That is incorrect. You should be using Tick Value with Tick Size, not Point Size.

Also the Point Size is not the smallest change in price. That would be the Tick Size. Point Size is the smallest numerical resolution required to represente the price quote, not the smallest price change.

Here are examples of symbols with different point and tick sizes ...

Forum on trading, automated trading systems and testing trading strategies

Symbol Point Value

Fernando Carreiro, 2022.06.02 01:14

Here are two examples from AMP Global (Europe):

  • Micro E-mini S&P 500 (Futures): point size = 0.01, tick size = 0.25, tick value = $1.25
  • EURO STOXX Banks (Stock Index): point size = 0.01, tick size = 0.05, tick value = €2.50

 

There is another flaw with your approach: you use the sell rate of the conversion pair (Bid or 1/Ask if indirect) for all trade types, whether buy or sell.


This is not correct. The rate used for conversion of profits/losses from profit currency -> account currency, must match the trade type on the traded pair.

It is a simple rule: The trade type on the conversion pair is the same as that of the traded pair.

  • Conversion of buy profit is done by longing the cross conversion pair (multiply by Ask, or 1/Bid if indirect).
  • Conversion of sell profit is done by shorting the cross conversion pair (multiply by Bid, or 1/Ask if indirect).

The choice of price type (BID/ASK) of the profit/account conversion pair depends to two things: (a) the type of the order (b) position of account currency in the conversion pair (first or second).

Reason: