Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Ayumi), 662 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 3 1 2 3
Re: PnL calculation [Re: jcl] #423529
05/31/13 18:06
05/31/13 18:06
Joined: May 2013
Posts: 15
P
Purri Offline OP
Newbie
Purri  Offline OP
Newbie
P

Joined: May 2013
Posts: 15
Maybe we can still archive success. Here is an experiment:

Make a trade with 100K units of EUR/USD on a fxcm euro demo account. Lets suppose you make +15 pips on this. Your PnL will be $150. These $150 will then be automatically converted to Euro with the actual excahnge rate at 1.2960 (current rate) - so PnL will show up in your account report with $150 / 1.2960 = €115.7

This isnt rocket science and can easily be verified with a few clicks.


Here is another way to put it: Say you buy 100K units of eur/usd at 1.2500. That means you have now a credit of 100K EUR and a debit of 125K USD. Now you are in luck and the eur/usd exchange-rate rises to 1.2550 and then you sell 100K units of eur/usd to go flat which essentially means you exchange your 100K Euro credit into USD with a rate of 1.2550 to repay your 125k USD debit. For your 100K Euro you now get 125500 USD - so $500 are left over, which is your proft. Now these $500 will be converted to Euro at a rate of 1.2550 (~€398).

You could ovserve the actual currency balances with (for example) an oanda demo account, they do list the exposures in their platform. But no matter if you express this in floating pip values or any other representation, this is how it works, and has always worked in fx.

Last edited by Purri; 05/31/13 18:07.
Re: PnL calculation [Re: Purri] #423531
05/31/13 18:57
05/31/13 18:57
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
I'm a little pessimistic about the success, as my lengthy explanations so far seem not to have been arrived. So, my final attempt with a small calculation and no much words:

Your profit = 15 pips
The pipcost = 0.0800 EUR
What ends up in your account = 15*0.08*100 micro lots = 120.00 EUR.

You can now complain to FXCM that your profit ought to be EUR 115.7 due to the exchange rate, but they will insist to pay you EUR 120. I can really not help it frown. But that's what you get and what the program simulates.

Re: PnL calculation [Re: jcl] #423541
05/31/13 19:52
05/31/13 19:52
Joined: May 2013
Posts: 15
P
Purri Offline OP
Newbie
Purri  Offline OP
Newbie
P

Joined: May 2013
Posts: 15
No they wont. I can post a screenshot with an actual trade on fxcm demo and its pnl on monday. Would that help?

Re: PnL calculation [Re: Purri] #423548
05/31/13 20:56
05/31/13 20:56
Joined: May 2013
Posts: 15
P
Purri Offline OP
Newbie
Purri  Offline OP
Newbie
P

Joined: May 2013
Posts: 15
http://i.imgur.com/lFWRlGg.jpg

As you can see, there is a trade with 1.7 pips loss on a minilot for a pnl of €-1.31

$1.7 / 1.29966 = €1.31

According to you, it should be €1.36

Re: PnL calculation [Re: Purri] #423565
06/01/13 07:58
06/01/13 07:58
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
No, it's 1.309. You can follow my example above for the calculation, only pipcost is 0.77 EUR for the account in your screenshot because it's a minilot account. Microlot pipcost are the mentioned 0.08 EUR. You can see the pipcost in your asset detail view.

1.7 * 0.77 = 1.309 EUR. Rounded up it's the 1.31 that you can see in your screenshot.

On the broker website you'll usually find all parameters explained for calculating the PnL of your trade. For FXCM, it's here: http://support.fxcm.com/fxts/user-guide/rates/

- You might wonder why the pipcost is 0.77 on a minilot account and 0.08 on a microlot account. These values are also really used in their trading API. FXCM gave us the explanation that this has technical reasons due to the internal parameter representation by their server software. But this is a detail specific to FXCM and not relevant for general trading.

In their trading API, the broker specifies how the PnL is calculated. We have no choice here and can not invent our own PnL calculation method. Otherwise Zorro would record different trade profits than FXCM in real trading. The platform receives the current pipcost value through the API, and that value is then stored in the account parameters and also used for the simulation.

Re: PnL calculation [Re: jcl] #423586
06/01/13 13:27
06/01/13 13:27
Joined: May 2013
Posts: 15
P
Purri Offline OP
Newbie
Purri  Offline OP
Newbie
P

Joined: May 2013
Posts: 15
But your 0.77 is the same thing: 1 / 1.29966 = 0,7694

The pip-cost will fluctuate according to the exchange-rate, internally probably with 5 digit precision, rounded off to 2 digits is what fxcm displays in the platform as pip-cost. Your 0.08 is probably 0.07694 rounded to 2 digits. Its not a value that is arbitrarily set by the broker.

Your link(that describes the behavior of a USD account) actually says that it is fluctuating too. In an USD account xxx/USD pairs have a fixed pip-cost of $1 per pip and minilot. But for example xxx/JPY pairs will hae a fluctuating pip-cost. Consequently in an EUR account, xxx/EUR pairs (that do not exist) would have a fixes pip cost, other paris don't.

Last edited by Purri; 06/01/13 13:35.
Re: PnL calculation [Re: Purri] #423587
06/01/13 13:37
06/01/13 13:37
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
No, they have no internal 5 digit precision - or in fact they have, but the remaining digits are normally zero. The values internally used by the broker API are really the same as displayed in the FXCM platform, with no hidden digits.

The values do indeed fluctuate. FXCM changes them from time to time and adapts them to the exchange rate. When you look into the file "AssetsMini.dat" in your History folder, which is for simulating a mini lot account, you can see that the value was 0.78 in 2012. So in this way you're right that the simulation does not reflect the current situation. But you can update that file anytime to your current account parameters with the procedure described under "Data Import".

Re: PnL calculation [Re: jcl] #423621
06/02/13 09:20
06/02/13 09:20
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
How about the follwing solution to conclude this discussion: You use a script function that modulates your profits with the exchange rate.

I can not recommend this, for several reasons. For instance it adds a level of overfitting to the simulation and reduces the quality of trained parameters. So your strategy will probably become less profitable. But if you want to do that nevertheless, I can post a short function here that replaces the broker's pip cost with an exchange rate that you can select. Would that work for you?

Re: PnL calculation [Re: jcl] #423635
06/02/13 14:17
06/02/13 14:17
Joined: May 2013
Posts: 15
P
Purri Offline OP
Newbie
Purri  Offline OP
Newbie
P

Joined: May 2013
Posts: 15
jcl: that sounds like it would help. My initial idea would have been to calculate the pip-values for each pair and each day (daily is sufficient for this) and store it in a csv-file or similar. I suppose its possible to write a Zorro script to update said files. The pip-values could then be adjusted by looking it up everytime the strategy detects a new date.

With eur/usd and an EUR-based account its easy, because you only need the eur/usd rate for calculation. But with i.e. usd/chf its more complicated, you need the eur/chf rate to calculate the pip-values. Thats the reason i would have suggested pre-generated files, but maybe you have a better idea?

There is a more wholistic solution that is used by other backtesting software, where each asset is set up with information in which currency it is quoted. For example, if you have a portfolio of stocks of Citi, BP and BMW, you have postions as C/USD, BP/GBP and BMW/EUR, the pnl is calculated in the quote currency, and in a second step converted to the account currency according to fx rates. Likewise with USD/CHF it is represented as a position of asset USD quoted in currency CHF (= the usd/chf rate). The pnl in CHF is then converted to the account currency of eur with the eur/chf rate. But i suppose you need a full blowen symbol manager and a major redesign for this and im not sure if this is compatible with the light-weight spirit of zorro.


Not to belabour the point from the previous post, but the screenshot i posted is a microlot demoaccount, and pip-cost is displayed as 0.08 in the software - while clearly in the report 0.077 is used. That seems like they are infact rounding the 0.077 (and possibly even more digits) to 2 digits for display purposes. And i would be surprised if this value wouldnt be adapted on at least a daily basis, and the day-to-day changes are behind the first 2 digits, so they are not displayed, while still used for pnl calculation. But i can ask a fxcm rep next week for details.

http://i.imgur.com/ew3Cp4R.jpg

Re: PnL calculation [Re: jcl] #423636
06/02/13 14:23
06/02/13 14:23
Joined: May 2013
Posts: 15
P
Purri Offline OP
Newbie
Purri  Offline OP
Newbie
P

Joined: May 2013
Posts: 15
Originally Posted By: jcl

I can not recommend this, for several reasons. For instance it adds a level of overfitting to the simulation and reduces the quality of trained parameters. So your strategy will probably become less profitable.


I dont understand your objection to this. If i want to simulate a trade in for example the year 2005, i want to use the pip-value from 2005 for the pnl-calculation. Using the the pip-value from 2013 would make no sense - i want to know what the result would have been - not the result with the pip-value of 2013. And it would be forward-peeking, the pip-value of 2013 is not knowen in 2005. Its not fitting anything, it just simulates what would have happened in 2005.

Last edited by Purri; 06/02/13 14:34.
Page 2 of 3 1 2 3

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1