I'm currently developping forex robot using Python API for Metatrader 5. Among different things, this robot places trades given by external signals (with price, SL and TP).

I use euro funded account, trade XAUUSD, and have a 1:100 leverage ratio. In order to implement 1% strategy (meaning never risk more than 1% of capital in one trade), I would like to calculate precise SL/TP level in euro, my account money, and fail to compute same results as given in my MT5 terminal.

If I take a trade as example (informations sourced from MT5):

  • SELL XAUUSD, price \$1849.32
  • lot size : 0.01
  • date : 2022.05.31 13:31:05
  • closed at price $1848.03
  • profit announced by MT5 : 2,4€

What's the formula used to calculate this amount, placing leverage and exchange rate from USD to EUR ?

My method so far:

AFAIK, pip value for an USD account with USD as last currency in pair (i.e XAUUSD) is:


Applied to given trade above (result in dollars):


Total trade value (in dollars, without any leverage)


From this point, I can't find any way to include leverage and exchange rate for finding this 2,4€ profit.


1 Answer 1


You'll need to account for the change in the EUR_USD rate over the duration of the trade.

When you initiate the trade you are shorting XAU and going long USD, which means you buy USD at the going EUR_USD rate at trade entry time, which will also mean a EUR "debit" to your account since your account is denominated in EUR.

When you exit the trade, you get your USD profit which is then converted or "credited" to your EUR denominated account at the EUR_USD rate prevailing at trade exit time. Your total profit in the trade (in your example 2.4 EUR) is then the difference between these "credit" and "debit" amounts in EUR.

Implicit in all this is the fact that not only are you placing an XAU trade but also a EUR_USD trade, i.e. the classic "currency risk" when you trade in a different currency than that in which your base account is denominated. I believe, without being in a position to prove it, that this hidden risk trips up many traders.

You could, of course, avoid this "currency risk" by shorting XAU_EUR instead as a standalone XAU play.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.