|
PnL calculation
#423483
05/30/13 15:31
05/30/13 15:31
|
Joined: May 2013
Posts: 15
Purri
OP
Newbie
|
OP
Newbie
Joined: May 2013
Posts: 15
|
Hello, i am just trying out Zorro and writing a few simple scripts to get familiar with it. I wrote a script that trades only on a single day, that goes long at 12:00PM and exits the trade at 16:00. I have tested this with EUR/USD data from the Zorro-website.
function run()
{
set(LOGFILE);
vars Price = series(price());
if(NumOpenLong == 0 && hour(0) >= 12 && lhour(0) < 16)
enterLong();
if(NumOpenLong != 0 && hour(0) >= 16)
exitLong();
StartDate = 20120921;
EndDate = 20120921;
PlotWidth = 1024;
PlotHeight1 = 768;
}
Now Zorro produces a performance report, a trade log and a CSV-file with the trades. The log says i entered at 1.2978 and exited at 1.2992 for a PnL of $1 (+14 pips). The CSV says i entered at 1.29781 and exited at 1.29896 for a PnL of $0.84 (+11.5 pips). The performance report says i made +10.4 pips or $0.84. Why are there such differences, and how do you calculate the $0.84 ? A gain of 10 pips (the minimum of the three) should be $1 straight. I also did the same on USD/JPY. Again the exit-prices from the csv and the log are differing by ~3 pips. And the PnL calculation is off: according to the csv-file i lost 3.1 pips or $0.32. This cannot be correct with usd/jpy exchange-rate at 78.xx. Maybe i have to adjust some flags or something? One last question: can Zorro correctly calculate the PnL in USD of, for example, a EUR/CHF trade? Regards, Purri
|
|
|
Re: PnL calculation
[Re: Purri]
#423484
05/30/13 15:47
05/30/13 15:47
|
Joined: Jul 2000
Posts: 27,986 Frankfurt
jcl
Chief Engineer
|
Chief Engineer
Joined: Jul 2000
Posts: 27,986
Frankfurt
|
The trade entry, exit, and profit values are recorded in the CSV file. The log does not record trades. It just records the events during the simulation. It lists the asset price at the moment of entry and exit. The price at which you really bought and sold the asset is recorded in the CSV, and it's normally different due to Spread, Slippage, and Rollover. Look here for details: http://manual.zorro-trader.com/spread.htm. The EUR 0.84 in your above example is the profit of that trade. Where values are rounded, 84 cents are displayed as $1 and 10.4 pips are displayed as 10p. The "$" sign in the message window has nothing to do with US-Dollars, it just means money. What currency it is depends on the simulated broker account. The default account is a micro lot EUR account.
|
|
|
Re: PnL calculation
[Re: Purri]
#423486
05/30/13 16:33
05/30/13 16:33
|
Joined: Jul 2000
Posts: 27,986 Frankfurt
jcl
Chief Engineer
|
Chief Engineer
Joined: Jul 2000
Posts: 27,986
Frankfurt
|
No, the $0.84 are correct, but your objection is justified. PnL calculation is not really difficult, but there are many factors involved.
For spread, rollover, and conversion from price differences to profit, the current broker's parameters are used, not the historic rates. The reason behind that is that you want to use a developed system today, at current rates, and not in the past. So the simulation does not really simulate history, it simulates the present, but with a history price curve. For the conversion from asset price differences to account money, the broker publishes a value named "PipCost" or similar on his website. This value is used for the conversion. It changes from time to time when the counter currency and the account currency are different.
You can find details about the account simulation in the manual under "Data import/export". There are about 10 parameters per asset that determine how PnL is calculated. You can set up different parameters for emulating different accounts, also in US-$, so you then won't have the conversion issue.
|
|
|
Re: PnL calculation
[Re: Purri]
#423514
05/31/13 13:37
05/31/13 13:37
|
Joined: Jul 2000
Posts: 27,986 Frankfurt
jcl
Chief Engineer
|
Chief Engineer
Joined: Jul 2000
Posts: 27,986
Frankfurt
|
Hmm, the Fx brokers that I know all calculate profits in the same way as FXCM.
For EUR/USD, the current Pip-EUR conversion rate is 0.0800. You can normally see the conversion rate when you start your broker's platform, f.i. the FXCM trading station, and look into the currency detail view. The rate is named like "PipCost" or "PipValue" dependent on the broker.
The rate does indeed change, but infrequently. It does not follow the daily dollar price. The current value, 0.0800, was the same in 2012. So your trade had earned exactly the same 84 cents profit when you had executed it back then on a real EUR account. In 2011 the rate was lower, like 0.078.
A change of the rate does however not affect the PnL in the simulation. The simulation only uses the current pip cost, not the USD exchange rate and also not the broker's historic pip costs. Otherwise the equity curve would not reflect the performance of your strategy, but also the USD price or the broker's conversion rates.
Anyway: if you want to convert the profits of your trade to another currency at the real exchange rate, you can do that in the script. You can set PipCost to a different value, so you can use the price of an asset, f.i. EUR/USD, for calculating an artificial PipCost that changes daily.
|
|
|
|