How to know the value, in euros, of a pip for a leverage of 100 ? - page 2

 
AYMERIC75 #:

Ok, I have created an indicator based on the indications of @Dominik Christian Egert , here is what it looks like:



Even if I wrote it in Pine, I share the code here, you can also check it as I'm still not completely sure  about it (I commented it):


Thanks a lot!


Aymeric


Looks good.

You are missing the volume, right?


Don't forget, you need to normalize the volume, then recalculate the margin requirements. And the profit per tick based on that volume.

 
Dominik Christian Egert #:

Looks good.

You are missing the volume, right?


Don't forget, you need to normalize the volume, then recalculate the margin requirements. And the profit per tick based on that volume.

In my code the "normalized volume" corresponds to:

100000*investment_in_lots_percentage

Where 100 000 is the contract size and investment_in_lots_percentage is the ratio between my investment in the base currency and my margin (e.g: 29AUD / 1000).


Then the finale variable profit_loss_value is :

closing_price * 0.0001 * ( 100 000 * investment_in_lots_percentage )


Which (I hope) should correspond to the profit or loss I am getting from the movement of one pip (0.0001)

 
Yes, but volume has a certain "granularity".

You cannot have a volume of 1.25347 or 0.1875

These values need to be normalized to like 1.25 or 0.19 respectively.

Thus changing the outcome of the calculations.


By the way, in MQL, these specific definitions are given for each symbol. Also the contract size is given by symbol.

Next comes the asset type for Wich you are calculating, there are 4 formulas in total to calculate the profit or the tick value of an asset.

Take a look here, everything you need is described here:


 
Indeed, code updated for who's interested
Reason: