Bit of a late post but since I've had the same confusions as the op and believe I know the answer, thought I should share... :)
John - both of your calculations A and B seem to be based on the assumption that you traded USD 100,000 and need to convert the value of 1 pip per US dollar back to EUR. If that were true, B would be the answer since 1.0003 is the price at which the position closed.
However, the 100,000 units you bought are actually in EUR already. And the amount of USD you bought (which would've been 100,000 / 1.0002 = 99,980 ... doesn't matter), has netted you a profit of EUR 0.0001 per unit. Therefore the calculation is as simple as 100,000 x 0.0001 = 10 euros profit exactly.
Funnily enough in your example all formulas would have produced 10.00 anyway due to rounding. ;) But this should be the correct (and simplest!) way to calculate.
--- On a side-note...
If your base currency doesn't match your account currency things get trickier, since volumes and prices are expressed in the base currency whilst all profit figures and commissions are expressed in the account currency. This forces you to actually do conversions between those currencies, e.g. when deciding volumes based on account balance (to control leverage/risk) or doing profit projections like the one you posted.
It wouldn't be so bad if not for a big limitation in cAlgo - the fact that it throws an error when you attempt to access other symbols during a back-test! The only workaround I know of is to use Symbol.PipValue (which is actually the value converted to your account's currency) but sadly it only seems to get set when your bot first starts up. i.e. It never updates, even during a live run...! Not exactly accurate. :(
So yeah, expect some pain if you ever want to trade on a different base currency. If anybody has a nice solution to this I'd be very grateful.
ikariya
21 Oct 2016, 19:12
Bit of a late post but since I've had the same confusions as the op and believe I know the answer, thought I should share... :)
John - both of your calculations A and B seem to be based on the assumption that you traded USD 100,000 and need to convert the value of 1 pip per US dollar back to EUR. If that were true, B would be the answer since 1.0003 is the price at which the position closed.
However, the 100,000 units you bought are actually in EUR already. And the amount of USD you bought (which would've been 100,000 / 1.0002 = 99,980 ... doesn't matter), has netted you a profit of EUR 0.0001 per unit. Therefore the calculation is as simple as 100,000 x 0.0001 = 10 euros profit exactly.
Funnily enough in your example all formulas would have produced 10.00 anyway due to rounding. ;) But this should be the correct (and simplest!) way to calculate.
--- On a side-note...
If your base currency doesn't match your account currency things get trickier, since volumes and prices are expressed in the base currency whilst all profit figures and commissions are expressed in the account currency. This forces you to actually do conversions between those currencies, e.g. when deciding volumes based on account balance (to control leverage/risk) or doing profit projections like the one you posted.
It wouldn't be so bad if not for a big limitation in cAlgo - the fact that it throws an error when you attempt to access other symbols during a back-test! The only workaround I know of is to use Symbol.PipValue (which is actually the value converted to your account's currency) but sadly it only seems to get set when your bot first starts up. i.e. It never updates, even during a live run...! Not exactly accurate. :(
So yeah, expect some pain if you ever want to trade on a different base currency. If anybody has a nice solution to this I'd be very grateful.
@ikariya