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 3 of 3 1 2 3
Re: PnL calculation [Re: Purri] #423642
06/02/13 15:51
06/02/13 15:51
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Ok, here's the function:

Code:
function convertProfit(string Rate)
{
	char OldAsset[40];
	strcpy(OldAsset,Asset); // store original asset
	if(!asset(Rate)) return;
	var Price = price();
	asset(OldAsset);
	if(Price > 0.) 
		PIPCost = PIP*LotAmount/Price;
}



In your run function, call

convertProfit("EUR/USD");

when your account currency is EUR and the counter currency is USD.

- No, forward peeking is something quite different. What you're doing here is training the strategy to trade more often in the months with better exchange rate. But there's most likely no correlation between your trade signals and the exchange rate, so you'll get distorted parameters and less profit in real trading.

At least that's what I suspect. I don't think that many people simulate a strategy this way, so there are no experiences how this really affects the profit, and my objections are purely theoretical. Just try it!

You can easily check the result of your method with walk forward analysis f.i. with the strategies from workshop 5, 6, or 7, or with your own strategies. Let me know how it worked.

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

Joined: May 2013
Posts: 15
Thanks for the function. I did plot pipcost on a eur/usd chart and it works.

But i dont yet understand how often i need to call this. Do i have to call this function on each run() call? Or does Zorro remember it throughout the rest of the simulation if i set it once?


I dont know, to me this just makes sense. If i make a trade today, my pnl will be with current rates. When i look back in 5 years time, this fact will not have changed, regardless of what the exchange rates will be in 5 years. And since a simulation should be as close to reality as possible, i would then, if i had to do a simulation of this trade, of course simulate the rates from today, because that is just what happened. If i would use rates from 2018 to convert pnl, the outcome would be different to what actually did take place in the past, thus lessening the quality of the simulation. But lets just disagree..

Last edited by Purri; 06/02/13 17:14.
Re: PnL calculation [Re: Purri] #423659
06/02/13 17:31
06/02/13 17:31
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
You have to call it when you want the rate to adapt. Normally on each run(), but I think once per day would do also. The function is fast though, so it won't matter much for simulation speed how often you call it.

The simulation must only be close to reality where the trade signals are involved. In all other regards, implementing 'realism' does no good when it affects your strategy parameters. System developers normally try to remove external factors, not add them. I would certainly not include factors such as the account currency. But that's just my advice - Zorro is a tool and you can use it in any way you want.

Theoretical discussions are futile anyway. You can easily test your ideas with the workshop strategies or your own strategies, and then see if they work or not.

Re: PnL calculation [Re: jcl] #423684
06/03/13 08:58
06/03/13 08:58
Joined: May 2013
Posts: 15
P
Purri Offline OP
Newbie
Purri  Offline OP
Newbie
P

Joined: May 2013
Posts: 15
Hi, one more question: i entered a limit order for a specific price:

enterShort(1, -1.2930);

But the fill comes back with 1.29274 according to the CSV. I assume the spread of 2.6 pips has been deducted from the limit price - although a limit entry should be no worse than the limit price, in contrast to stop or market orders. Is it possible to change this behaviour?

Also i dont understand the slippage setting, which is set to 10 seconds by default. The docs are a bit ambigous about how this works exactly. I understand the minimum barperiod in Zorro is 1 minute?

Re: PnL calculation [Re: Purri] #423685
06/03/13 09:24
06/03/13 09:24
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
All prices in stops, limits, targets, indicators etc. are generally Ask prices - no matter if it's for a long or short order. If you want to use the Bid price instead, you must subtract resp. add the spread.

Slippage determines a range on the price curve that contains the likely price at which the order is filled or closed. So with 1-minute bars and 10 seconds slippage the order is filled from within 1/6 of the estimated price curve inside the bar.

Re: PnL calculation [Re: jcl] #423692
06/03/13 11:40
06/03/13 11:40
Joined: May 2013
Posts: 15
P
Purri Offline OP
Newbie
Purri  Offline OP
Newbie
P

Joined: May 2013
Posts: 15
Still, in live trading a limit-order will fill no worse than the limit-price (if it is filled at all).

Re: PnL calculation [Re: Purri] #423695
06/03/13 13:29
06/03/13 13:29
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
It does not. What you entered was the Ask Price. Short orders fill at the Bid price.

Page 3 of 3 1 2 3

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1