For MQL5, just use the OrderCalcProfit() — MQL5 Book: Trading automation / Creating Expert Advisors / Estimating the profit of a trading operation: OrderCalcProfit
For many symbols, the maths is usually as follows, but not always, so it is best to use OrderCalcProfit().
Forum on trading, automated trading systems and testing trading strategies
How to calculate take profit from currency
Fernando Carreiro, 2022.09.05 17:00
These are all the same equation written in different ways ...
[Volume] = [Money Value] * [Tick Size] / ( [Tick Value] * [Stop Size] ) [Stop Size] = [Money Value] * [Tick Size] / ( [Tick Value] * [Volume] ) [Money Value] = [Volume] * [Stop Size] * [Tick Value] / [Tick Size] [Volume] in lots [Stop Size] in quote price change [Money Value] in account currency

- www.mql5.com
In case you are curious, the documentation describes the various calculations that OrderCalcProfit() and OrderCalcMargin() apply depending on the situation.
Identifier
Description
Formula
SYMBOL_CALC_MODE_FOREX
Forex mode - calculation of profit and margin for Forex
Margin: Lots * Contract_Size / Leverage * Margin_Rate
Profit: (close_price - open_price) * Contract_Size*Lots
SYMBOL_CALC_MODE_FOREX_NO_LEVERAGE
Forex No Leverage mode – calculation of profit and margin for Forex symbols without taking into account the leverage
Margin: Lots * Contract_Size * Margin_Rate
Profit: (close_price - open_price) * Contract_Size * Lots
SYMBOL_CALC_MODE_FUTURES
Futures mode - calculation of margin and profit for futures
Margin: Lots * InitialMargin * Margin_Rate
Profit: (close_price - open_price) * TickPrice / TickSize*Lots
SYMBOL_CALC_MODE_CFD
CFD mode - calculation of margin and profit for CFD
Margin: Lots * ContractSize * MarketPrice * Margin_Rate
Profit: (close_price - open_price) * Contract_Size * Lots
SYMBOL_CALC_MODE_CFDINDEX
CFD index mode - calculation of margin and profit for CFD by indexes
Margin: (Lots * ContractSize * MarketPrice) * TickPrice / TickSize * Margin_Rate
Profit: (close_price - open_price) * Contract_Size * Lots
SYMBOL_CALC_MODE_CFDLEVERAGE
CFD Leverage mode - calculation of margin and profit for CFD at leverage trading
Margin: (Lots * ContractSize * MarketPrice) / Leverage * Margin_Rate
Profit: (close_price-open_price) * Contract_Size * Lots
SYMBOL_CALC_MODE_EXCH_STOCKS
Exchange mode – calculation of margin and profit for trading securities on a stock exchange
Margin: Lots * ContractSize * LastPrice * Margin_Rate
Profit: (close_price - open_price) * Contract_Size * Lots
SYMBOL_CALC_MODE_EXCH_FUTURES
Futures mode – calculation of margin and profit for trading futures contracts on a stock exchange
Margin: Lots * InitialMargin * Margin_Rate or Lots * MaintenanceMargin * Margin_Rate
Profit: (close_price - open_price) * Lots * TickPrice / TickSize
SYMBOL_CALC_MODE_EXCH_FUTURES_FORTS
FORTS Futures mode – calculation of margin and profit for trading futures contracts on FORTS. The margin may be reduced by the amount of MarginDiscount deviation according to the following rules:
1. If the price of a long position (buy order) is less than the estimated price, MarginDiscount = Lots*((PriceSettle-PriceOrder)*TickPrice/TickSize)
2. If the price of a short position (sell order) exceeds the estimated price, MarginDiscount = Lots*((PriceOrder-PriceSettle)*TickPrice/TickSize)
where:
- PriceSettle – estimated (clearing) price of the previous session;
- PriceOrder – average weighted position price or open price set in the order (request);
- TickPrice – tick price (cost of the price change by one point)
- TickSize – tick size (minimum price change step)
Margin: Lots * InitialMargin * Margin_Rate or Lots * MaintenanceMargin * Margin_Rate
Profit: (close_price - open_price) * Lots * TickPrice / TickSize
SYMBOL_CALC_MODE_EXCH_BONDS
Exchange Bonds mode – calculation of margin and profit for trading bonds on a stock exchange
Margin: Lots * ContractSize * FaceValue * open_price * /100
Profit: Lots * close_price * FaceValue * Contract_Size + AccruedInterest * Lots * ContractSize
SYMBOL_CALC_MODE_EXCH_STOCKS_MOEX
Exchange MOEX Stocks mode – calculation of margin and profit for trading securities on MOEX
Margin: Lots * ContractSize * LastPrice * Margin_Rate
Profit: (close_price - open_price) * Contract_Size * Lots
SYMBOL_CALC_MODE_EXCH_BONDS_MOEX
Exchange MOEX Bonds mode – calculation of margin and profit for trading bonds on MOEX
Margin: Lots * ContractSize * FaceValue * open_price * /100
Profit: Lots * close_price * FaceValue * Contract_Size + AccruedInterest * Lots * ContractSize
SYMBOL_CALC_MODE_SERV_COLLATERAL
Collateral mode - a symbol is used as a non-tradable asset on a trading account. The market value of an open position is calculated based on the volume, current market price, contract size and liquidity ratio. The value is included into Assets, which are added to Equity. Open positions of such symbols increase the Free Margin amount and are used as additional margin (collateral) for open positions of tradable instruments.
Margin: no
Profit: no
Market Value: Lots*ContractSize*MarketPrice*LiqudityRate

- www.mql5.com
For MQL5, just use the OrderCalcProfit() — MQL5 Book: Trading automation / Creating Expert Advisors / Estimating the profit of a trading operation: OrderCalcProfit
For many symbols, the maths is usually as follows, but not always, so it is best to use OrderCalcProfit().
[Volume] = [Money Value] * [Tick Size] / ( [Tick Value] * [Stop Size] )
strangely it works well with TickSize = 1 ......
[Volume] = [Money Value] / ( [Tick Value] * [Stop Size] )
if I put a regular symbol ticksize, es: 0.000.1 it result in crazy results .... how is possible ? to be precise stop size is the number of pips...not the stopLoss price
strangely it works well with TickSize = 1 ......
if I put a regular symbol ticksize, es: 0.000.1 it result in crazy results .... how is possible ? to be precise stop size is the number of pips...not the stopLoss price
hence, why Fernando said "so it is best to use "OrderCalcProfit()".
For MQL5, just use the OrderCalcProfit() — MQL5 Book: Trading automation / Creating Expert Advisors / Estimating the profit of a trading operation: OrderCalcProfit
For many symbols, the maths is usually as follows, but not always, so it is best to use OrderCalcProfit().
Hi Fernando, just saw this thread and thank you for the answer.
How would you use this, for example, in a basket trading scenario - so multiple sell positions on the same symbol but with increasing volumes to hit a specific TP target? eg, you have positions at volume 0.04,0.04,0.06.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I've been trying to calculate target price for a given profit value (in account currency) but I have failed!
I've opened a position in USDJPY and with the following state:
Now I'm trying to calculate the profit in MQL5 which I was not able to!
ProfitPerUnit = Volume × ContractSize × TickSize / TickValue PriceChange = Profit / PerUnitProfit TargetPrice = CurrentPrice + PriceChange // Data from MT5 for USDJPY symbol ContractSize = 100,000 TickSize = 0.001 TickValue = 0.651313047102959564 ProfitPerUnit = 651.3130471029595 PriceChange = 3.60 / 651.313 = 0.005526
Which 0.005526 is obviously not the correct answer. the price change is (153.449 - 152.982 = 0.467) not 0.005526.
What is wrong with my calculation?