Is Zorro's rollover calculation wrong?

Posted By: pcz

Is Zorro's rollover calculation wrong? - 03/05/17 14:57

Let's take this minimal example:

Code:
#include <default.c>

function run()
{	
	StartDate = 20170101;
	BarPeriod = 60;
	LifeTime = 25;
	enterShort();
	set(LOGFILE);
}


When I check the trade log it seems that all the trades opened between 13:00 and 22:00 (and closed on the next day) have no rollover despite being held for 25 hours. From what I understand this is not how rollover usually works.
Posted By: jcl

Re: Is Zorro's rollover calculation wrong? - 03/06/17 09:42

It's indeed not, since there is no way rollover "usually works". Zorro adds rollover at any new day when the trade was longer open than 12 hours, which is a good approximation for most, but not all brokers.

If you need a different rollover calculation for a particular broker, just set RollLong/Short to zero and calculate it in the script.
Posted By: pcz

Re: Is Zorro's rollover calculation wrong? - 03/06/17 09:57

OK, good to know. Would be nice to have this information in the manual (sorry if I overlooked it by mistake).

Another thing is that for a test trade on EUR/USD opened on 31.12.2015 and closed on 4.1.2016 the calculated rollover is 142160 while the value in AssetFix file is 1.4216. I have no clue why but maybe it has something to do with the year switch?
Posted By: jcl

Re: Is Zorro's rollover calculation wrong? - 03/06/17 10:40

I have just tried it, but can not confirm a wrong rollover for trades between years. Can you post that script?
Posted By: pcz

Re: Is Zorro's rollover calculation wrong? - 03/06/17 10:53

I found out that this happens only when the AssetsFix file can't be opened between test runs (e.g. because it has been opened in a text editor). I didn't notice it before. My theory is that Zorro somehow remembered the rollover value from the previous test but not the other asset params. Therefore the value 142160 which is 100k times the right value. So probably it's just an unexpected behavior in unexpected situation, not real issue.
Posted By: jcl

Re: Is Zorro's rollover calculation wrong? - 03/06/17 11:02

Hmm, if the file can not be opened the values are certainly wrong, but did you not get an error message?
Posted By: pcz

Re: Is Zorro's rollover calculation wrong? - 03/06/17 11:06

Yes, there was a message in Zorro's main window which I didn't notice.
Posted By: pcz

Re: Is Zorro's rollover calculation wrong? - 03/06/17 14:10

This is somewhat related to the previous observation so I'll put it here.

I want to store RollLong/Short values from AssetsFix file in order to use a different rollover calculation as you suggested.

I have code like this:

Code:
if(is(INITRUN)){
	x = (var)RollShort;
}
RollShort = 0;



This works fine with a fresh Zorro start. But if I re-run the script Zorro remembers that RollShort = 0 from the previous run so the assignment to x variable is useless. Is it like this because of some other feature or would it make more sense to reset the rollover values with each new test run?
Posted By: jcl

Re: Is Zorro's rollover calculation wrong? - 03/06/17 16:54

Load the asset list again with assetList() in the INITRUN. The rollover is then set to the stored parameters from the list.
Posted By: pcz

Re: Is Zorro's rollover calculation wrong? - 03/23/17 15:12

Another thing related to rollover calculation I've noticed recently, although it's probably not a big issue:

When testing with T1 data I get sometimes different values than with T6 data. Is there a reason for that?

Example:
Code:
Type	        Open	                Close	                Entry	Exit	Profit	Roll
T1: Short	2014-01-10 19:00	2014-01-13 01:00	1.36704	1.3663	8.34	1.42		
T6: Short	2014-01-10 19:00	2014-01-13 01:00	1.36704	1.3663	9.76	2.84

T1: Long	2014-03-14 15:00	2014-03-17 07:00	1.39163	1.39024	-17.94	-4.94		
T6: Long	2014-03-14 15:00	2014-03-17 07:00	1.39163	1.39024	-22.88	-9.88

Posted By: jcl

Re: Is Zorro's rollover calculation wrong? - 03/23/17 18:15

Missing data, possibly. Maybe the T1 data had gaps and therefore less days for the rollover.
Posted By: pcz

Re: Is Zorro's rollover calculation wrong? - 03/24/17 09:43

In both cases the data are generated from Dukascopy's tick data. I even tried exporting M1 bars for T1 and T6 data and there's not a single difference between them as far as I can tell. It seems though that the difference in rollover calculation occurs only around weekends.
Posted By: jcl

Re: Is Zorro's rollover calculation wrong? - 03/24/17 17:30

Rollover is accumulated at any new day. So I would suspect that for some reason one data set had less day changes, possibly Friday or Sunday, than the other one.

Sum up the open rollover of all open trades and plot or print the result at any bar. Then you can see where the differences come from.

var RollSum = 0;
for(open_trades) RollSum += TradeRoll;
Posted By: pcz

Re: Is Zorro's rollover calculation wrong? - 03/25/17 16:13

Having this trade:
Code:
Type       Lots	  Open	                Close	                Entry	Exit	Profit	Roll
T1/Short   1	  2015-01-09 11:00	2015-01-12 07:00	0.8136	0.82442	-104.22	-3.03
T6/Short   1	  2015-01-09 11:00	2015-01-12 07:00	0.8136	0.82442	-107.25	-6.06



Printing the trade roll gives me this for T1 data (using hour() and minute() functions when printing; BarPeriod is 60):
Code:
...
2015-01-09 19:00, 0.000000
2015-01-11 23:00, 0.000000
2015-01-12 00:00, 0.000000
2015-01-12 01:00, -3.030200
2015-01-12 02:00, -3.030200
2015-01-12 03:00, -3.030200
2015-01-12 04:00, -3.030200
2015-01-12 05:00, -3.030200
2015-01-12 06:00, -3.030200



For T6 data this:
Code:
...
2015-01-09 19:00, 0.000000
2015-01-11 23:00, 0.000000
2015-01-12 00:00, -3.030200
2015-01-12 01:00, -6.060400
2015-01-12 02:00, -6.060400
2015-01-12 03:00, -6.060400
2015-01-12 04:00, -6.060400
2015-01-12 05:00, -6.060400
2015-01-12 06:00, -6.060400



9.1.2015 was Friday and 12.1. was Monday.
Posted By: jcl

Re: Is Zorro's rollover calculation wrong? - 03/27/17 09:16

The T6 rollover looks ok. The T1 rollover looks as if there were no prices on Sunday. Can you check if the T1 data had a Sunday gap? Rollover is only added when the asset had a price change since the last rollover.
Posted By: pcz

Re: Is Zorro's rollover calculation wrong? - 03/27/17 09:57

Both price files (.t1 and .t6) have prices on Sunday. The first Sunday entry in .t1 file has timestamp 2015-01-11 22:00:03.300 and the first entry in .t6 file has timestamp 2015-01-11 22:01. The Weekend variable has its default value in both cases.
Posted By: jcl

Re: Is Zorro's rollover calculation wrong? - 03/27/17 17:08

Hmm, if all is identical, then I do not know why the t1 and the t6 data have different rollover. So someone had to really look into it. If you want, you can send your script and the data sets to Support. They'll find out where the difference comes from.
Posted By: pcz

Re: Is Zorro's rollover calculation wrong? - 03/27/17 19:30

Thank you jcl, I will.
Posted By: pcz

Re: Is Zorro's rollover calculation wrong? - 04/20/17 11:43

I got response from the support. The issue was that in TICKS mode a tick in the historical data was evaluated even outside trading hours. It will be fixed in the next version.
© 2024 lite-C Forums