P&L calculation formula for different traded assets
- Stocks : P&L = (Sell price - Buy price) * Number of shares - Transaction fee.
- Bonds: P&L = (Sell price - Buy price) * Face value * Exchange rate - Transaction costs
- Commodities: P&L = (Sell Price - Buy Price) * Contract Size * Contract Price * Exchange Rate - Transaction Costs
- Currencies: P&L = (Sell Price - Buy Price) * Contract Size * Exchange Rate - Transaction Costs
- Derivatives: P&L = Contract size * (Closing price - Opening price) * Exchange rate - Transaction fees
- Exchange Traded Funds (ETFs): P&L = (Sale price - Purchase price) * Number of units * Exchange rate - Transaction fees
- are the assets "stocks", "bonds", "commodities", "currencies", "derivatives", "ETFs" exhaustive and do they concretely represent the "objects" traded?
- Are the above formulas correct? If not, what would be the correct formulas?
- how to take into account the currency of the trading account?
- what are the "units" of the terms appearing in the formulas?
- ea does not work
- Calculate break even point on a trade
- Profit to pips
I suggest reading up on the following two MQL5 trade functions ...
Calculates the margin required for the specified order type, in the deposit currency
Calculates the profit based on the parameters passed, in the deposit currency
They calculate the margin and the profit/loss respectively, adjusting automatically for the asset type, making it unnecessary to calculate it manually using the methods you have described.
They do however, not include Commission or Swaps. Those are only provided after the fact and are accessible via other functionality — Documentation on MQL5: Trade Functions
- 2023.02.22
- www.mql5.com