# Complete formula for calculating forex pip value for XAUUSD with account funded in euros - page 2

You are missing trading opportunities:

- Free trading apps
- Free Forex VPS for 24 hours
- Over 8,000 signals for copying
- Economic news for exploring financial markets

Registration
Log in

You agree to website policy and terms of use

If you do not have an account, please register

Fernando Carreiro #:EDIT: In my example, I am using a positive Risk, not as a negative. If you want to use it as negative then adjust the calculation as such, by removing the "-" in front of "dbProfit".

As you can see, it is also returning units. When I use the same formula for forex currency pairs (including gold), it gives me the amount in lot sizes which is perfect. The value for the below should be 0.002 micro lot not 1.54. Or I'm simply missing a bit of logic that I will need to add in for each of these pairs that are an exception to the majority (BTCUSD, ETHUSD, US30).TraderLloyd #:You are mixing apples and oranges in your 2nd example.

You acquiring info on gold ...

But then doing the Profit calculation on bitcoin ...

Which one is it then?

EDIT: And in the 1st example, the answer seems correct. It is indeed 1.54, not 0.002.

EDIT2: However, besides the "BTCUSD" in your text in the 2nd example, the returned profit of -15000 is correct for XAUUSD, and the correct lot size is in fact correct at 1.67

Fernando Carreiro #:You are mixing apples and oranges in your 2nd example.

You acquiring info on gold ...

But then doing the Profit calculation on bitcoin ...

Which one is it then?

EDIT: And in the 1st example, the answer seems correct. It is indeed 1.54, not 0.002.

EDIT2: However, besides the "BTCUSD" in your text in the 2nd example, the returned profit of -15000 is correct for XAUUSD, and the correct lot size is in fact correct at 1.67

Sorry about that, I copied and pasted that line from BTC and didn't fix it. It is XAUUSD.

And you are correct...both are correct. It turns out the calculator I've been using on my mobile phone has the wrong value.

I can't thank you enough Fernando!

TraderLloyd #:Sorry about that, I copied and pasted that line from BTC and didn't fix it. It is XAUUSD. And you are correct...both are correct. It turns out the calculator I've been using on my mobile phone has the wrong value. I can't thank you enough Fernando!Hi Guys, If you don't mind me adding to this thread because I think it is related. I have been scratching my head on this one not sure what exactly is wrong if any.

Using the same formula above, I calculated for US30, risk amount is 500, open price 31920.40 and stop loss 31919.90. I got 1000lots. Please can anyone help me understand why this is.

More info

All currency in USD

Ticksize = 0.01

TickPoint = 0.01

minLot = 0.1

maxLot = 250

volume step = 0.1

I will be happy to provided anymore information if required. Thanks for the assistance

Henry Chigere #:Hi Guys, If you don't mind me adding to this thread because I think it is related. I have been scratching my head on this one not sure what exactly is wrong if any. Using the same formula above, I calculated for US30, risk amount is 500, open price 31920.40 and stop loss 31919.90. I got 1000lots. Please can anyone help me understand why this is. I will be happy to provided anymore information if required. Thanks for the assistanceShow your code then, because we will not be able to see what you are doing wrong in your code without seeing it.

As for example values you mention, a quote price difference between 31920.40 and 31919.90 for US30 would be 0.50. And given that each tick of size 0.01 is worth $0.01, that would be a risk of $0.50 for 1 lot.

So for a $500.00 risk, you would indeed require 1000 lots, but given that the maximum allowed is 250, your risk would be $125.00 for the 0.50 quote price change.

One more thing that should be considered by the OP or those following this thread ...

After you determine your volume (lots) for your risk amount, you should then check that against the free margin, useing the OrderCalcMargin (MQL5) or order_calc_margin (Python), to verify that the amount of margin that will be required is available in your free margin.

In fact, make sure that the required margin plus the risk is not greater than your free margin and that it will not cause a margin call or stop out.

I personally set a margin % limit and reduce the lot size if required. For example, I set a maximum % margin of 5-10% and use the OrderCalcMargin to adjust the volume to reduce the volume should the margin be higher than my limit.

The reason I set it to 5-10% is because I have to account for multiple positions in the market if I am trading on multiple symbols at the same time. If I were to allow a maximum margin on my balance, then I would not have any free margin left to trade on other symbols.

Fernando Carreiro #:Show your code then, because we will not be able to see what you are doing wrong in your code without seeing it.

As for example values you mention, a quote price difference between 31920.40 and 31919.90 for US30 would be 0.50. And given that each tick of size 0.01 is worth $0.01, that would be a risk of $0.50 for 1 lot.

So for a $500.00 risk, you would indeed require 1000 lots, but given that the maximum allowed is 250, your risk would be $125.00 for the 0.50 quote price change.

Thanks Fernando, thanks for confirming that at least the calculation is what it should be. I do normalise to the bounds of min and max lots size, please see extract

My confusion was that I could not execute 250 lot because I get error no money but based on your follow up comment, It is clear that I should have also calculate margin and adjust against my balance. I will revise my logic and see how it that goes. I really do appreciate your assistance on this, thanks again Fernando

Henry Chigere #:Thanks Fernando, thanks for confirming that at least the calculation is what it should be. I do normalise to the bounds of min and max lots size, please see extract. My confusion was that I could not execute 250 lot because I get error no money but based on your follow up comment, It is clear that I should have also calculate margin and adjust against my balance. I will revise my logic and see how it that goes. I really do appreciate your assistance on this, thanks again FernandoFernando Carreiro #:Don't use NormalizeDouble. The lots are already properly aligned with the Round and the LotStep. NormalizeDouble can actually cause problems, so don't use it.