# How to calculate loss/win for a index trade?

134

Good morning Community!

I am struggling to calculate the loss/win of a trade for the SP500 when account currency is in EUR.

DAX example:

Buy in: 12000, Buy out: 12050 -> 50 Points; My Broker sets 1 Point equal to 25 EUR. Having a lot size of 0.1 the win is: 50 * 25 * 0.1 = 125 EUR

The same way, I can calucalte the win/loss for the SP500. However, the result is still in USD and not in EUR as the base currency is apparently in USD. Therefore, I need the current exchange rate EUR/USD to convert USD into EUR.

I actually went through all available

`SYMBOL_`

functions in MQL5 but there wasn't anything useful to use.

Any ideas?

1277

syrvn 0:

Good morning Community!

I am struggling to calculate the loss/win of a trade for the SP500 when account currency is in EUR.

DAX example:

Buy in: 12000, Buy out: 12050 -> 50 Points; My Broker sets 1 Point equal to 25 EUR. Having a lot size of 0.1 the win is: 50 * 25 * 0.1 = 125 EUR

The same way, I can calucalte the win/loss for the SP500. However, the result is still in USD and not in EUR as the base currency is apparently in USD. Therefore, I need the current exchange rate EUR/USD to convert USD into EUR.

I actually went through all available

functions in MQL5 but there wasn't anything useful to use.

Any ideas?

If you just want the current exchange rate EUR/USD you can use this:

`double exchangeRate=SymbolInfoDouble("EURUSD",SYMBOL_BID);`

But this isn't a general way for profit/loss calculation. At my brokers the Tick Value currency depends on a value of profit calc mode. If the value is 0 or 1 then the tick value is in account currency but if the value is 2 then the tick value is in the base currency. Could you try, please, what a value of profit calc mode you have for SP500?

```int profitCalcMode=(int)SymbolInfoInteger(_Symbol,SYMBOL_TRADE_CALC_MODE);
printf("Symbol: %s has profit calc mode: %d",_Symbol,profitCalcMode); ```
134

Hi Petr,

The "trick" to get the current EUR/USD ratio works fine! Good to know, but as said your second suggestion seems much more straight forward.

The SYMBOL_TRADE_CALC_MODE returns the value 4!

I checked the enum for SYMBOL_TRADE_CALC_MODE and it makes sense that it is set to 4 as can be seen in the image. However, I think, that this is not what I want?!

Maybe it is also possible to set

```SYMBOL_CURRENCY_BASE
SYMBOL_CURRENCY_PROFIT
SYMBOL_CURRENCY_MARGIN```

to EUR?

36133

syrvn 0:

Hi Petr,

The "trick" to get the current EUR/USD ratio works fine! Good to know, but as said your second suggestion seems much more straight forward.

The SYMBOL_TRADE_CALC_MODE returns the value 4!

I checked the enum for SYMBOL_TRADE_CALC_MODE and it makes sense that it is set to 4 as can be seen in the image. However, I think, that this is not what I want?!

Maybe it is also possible to set

to EUR?

Why are you thinking that 4 is 'SYMBOL_CALC_MODE_EXCH_STOCKS' ?

```ENUM_SYMBOL_CALC_MODE profitCalcMode=(ENUM_SYMBOL_CALC_MODE)SymbolInfoInteger(_Symbol,SYMBOL_TRADE_CALC_MODE);
printf("Symbol: %s has profit calc mode: %s",_Symbol,EnumToString(profitCalcMode));
```
134

Hi Alain!

that is because the link highlighted in yellow links to the above Screenshot...might be wrong though. not an expert yet :-)

So, how can I check which number is right for my purpose? and how can I set the CALC_MODE to a different value?

36133

syrvn 0:

Hi Alain!

that is because the link highlighted in yellow links to the above Screenshot...might be wrong though. not an expert yet :-)

Nothing to do with my question.

The SYMBOL_TRADE_CALC_MODE returns the value 4!

4 is NOT SYMBOL_CALC_MODE_EXCH_STOCKS. Don't work with value, work with enum.

The same way, I can calucalte the win/loss for the SP500. However, the result is still in USD and not in EUR as the base currency is apparently in USD. Therefore, I need the current exchange rate EUR/USD to convert USD into EUR.

@Petr Nosek said you how to get EURUSD rate. Once you have your profit in USD, just convert it in EUR by dividing by EURUSD rate.

Or use TICK_VALUE / TICK_SIZE.
134

Thank you!

I am not sure what the result of TICK_VALUE / TICK_SIZE is representing? Could you just briefly point out how the formula should look like using TICK_VALUE / TICK_SIZE?

36133

syrvn 0:

Thank you!

I am not sure what the result of TICK_VALUE / TICK_SIZE is representing? Could you just briefly point out how the formula should look like using TICK_VALUE / TICK_SIZE?

Buy in: 2620.5, Buy out: 2635.0 -> 145 Ticks (TICK_SIZE = 0.1); My Broker sets 1 Tick equal to 8.1 EUR (TICK_VALUE). Having a lot size of 0.1 the win is: 145 * 8.1* 0.1 = 117.45 EUR

However, as noted by Petr, it appears that it's not always clear what TICK_VALUE is (depends on Broker/Symbol).

1277

syrvn 0:

Hi Petr,

The "trick" to get the current EUR/USD ratio works fine! Good to know, but as said your second suggestion seems much more straight forward.

The SYMBOL_TRADE_CALC_MODE returns the value 4!

I checked the enum for SYMBOL_TRADE_CALC_MODE and it makes sense that it is set to 4 as can be seen in the image. However, I think, that this is not what I want?!

SYMBOL_CURRENCY_BASE
SYMBOL_CURRENCY_PROFIT
SYMBOL_CURRENCY_MARGIN

Maybe it is also possible to set

to EUR?

I didn't know you use MT5 (I thought MT4). In this case you should use Alain's code to find out the profit calc mode:

```ENUM_SYMBOL_CALC_MODE profitCalcMode=(ENUM_SYMBOL_CALC_MODE)SymbolInfoInteger(_Symbol,SYMBOL_TRADE_CALC_MODE);
printf("Symbol: %s has profit calc mode: %s",_Symbol,EnumToString(profitCalcMode));```

If my code returns 4 then it should mean SYMBOL_CALC_MODE_CFDLEVERAGE. But it was information for me and it doesn't have to do with your problem. I'm sorry if I got you confused.

You can't set

SYMBOL_CURRENCY_BASE
SYMBOL_CURRENCY_PROFIT
SYMBOL_CURRENCY_MARGIN

These parameters are set by your broker.

TICK_VALUE is value of one tick (tick (TICK_SIZE) is minimal price change in points) and it should be in the deposit (account) currency. But sometimes it is in the base currency. And it was the reason I wanted you to give me information about your profit calc mode. I'm trying to find out if there's any connection

TICK_SIZE is minimal price change in points.

134

thank you guys very much for your satements!

I will go through your ideas thoroughly and see how I get along with these.

When I try to compile the code

```ENUM_SYMBOL_CALC_MODE profitCalcMode=(ENUM_SYMBOL_CALC_MODE)SymbolInfoInteger(_Symbol,SYMBOL_TRADE_CALC_MODE);
printf("Symbol: %s has profit calc mode: %s",_Symbol,EnumToString(profitCalcMode));```

I get the error message: 'profitCalcMode' - initialization of variable skipped by 'case' label, use { }

1277

Alain Verleyen:

Buy in: 2620.5, Buy out: 2635.0 -> 145 Ticks (TICK_SIZE = 0.1); My Broker sets 1 Tick equal to 8.1 EUR (TICK_VALUE). Having a lot size of 0.1 the win is: 145 * 8.1* 0.1 = 117.45 EUR

However, as noted by Petr, it appears that it's not always clear what TICK_VALUE is (depends on Broker/Symbol).

BTW have you noticed that the note about deposit currency has disappeared from the documentation? See