Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (1 invisible), 672 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Plotting and using my one second bar data? #475540
12/20/18 13:18
12/20/18 13:18
Joined: Dec 2018
Posts: 24
K
Kaga Offline OP
Newbie
Kaga  Offline OP
Newbie
K

Joined: Dec 2018
Posts: 24
Hi all,

I converted a .csv file with 1 second bar data to .t6, but Zorro still complains that there is no data, what should I do?

Here is what I did:

The .csv file I have has entries like

Code:
1/2/2018,09:30:05,27.89,27.9,27.88,27.88,4600
1/2/2018,09:30:06,27.88,27.88,27.86,27.86,6500
1/2/2018,09:30:07,27.85,27.85,27.84,27.84,2600
1/2/2018,09:30:08,27.82,27.82,27.82,27.82,100
1/2/2018,09:30:09,27.81,27.83,27.81,27.83,4500
1/2/2018,09:30:10,27.83,27.83,27.83,27.83,0


So I use the following script to convert it to .t6 format

Code:
string InName = "E:\Zorro1.96\History\VXX.csv";  // name of a single year CSV file
string OutName = "E:\Zorro1.96\History\VXX_2018.t6";
string Format = "%m/%d/%Y,%H:%M:%S,f3,f1,f2,f4,f6,f";
function main()
{
	int Records = dataParse(1,Format,InName);
	dataSave(1,OutName);
}


Somehow, if I look at the result in ZHistoryViewer, the time is resolved only up to minutes, not seconds:



And if I try to run a simple script:

Code:
function run()
{
	BarPeriod = 1./60;	// 1 second bars
	LookBack = 500;
	StartDate = 20180201;
	EndDate = 20180202; 	// fixed simulation period
	asset("VXX");
// calculate the buy/sell signal
	vars Price = series(price());
// plot signals and thresholds
	plot("plot",Price,NEW,BLUE);
	PlotWidth = 600;
	PlotHeight1 = 300;
	set(PLOTNOW);
}



Zorro 1.96 complains:



What am I doing wrong?

Last edited by Kaga; 12/20/18 13:22.
Re: One second bar data? [Re: Kaga] #475541
12/20/18 13:28
12/20/18 13:28
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
I believe BarPeriod < 1 requires t1 data.

So try converting to t1 instead.

Re: One second bar data? [Re: AndrewAMD] #475542
12/20/18 13:37
12/20/18 13:37
Joined: Dec 2018
Posts: 24
K
Kaga Offline OP
Newbie
Kaga  Offline OP
Newbie
K

Joined: Dec 2018
Posts: 24
Oh, but doesn't t1 require tick data instead of bars?
How to convert bars to t1?

Re: One second bar data? [Re: Kaga] #475543
12/20/18 13:54
12/20/18 13:54
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
Just use the time and the close price, and you’re all set.

Re: One second bar data? [Re: AndrewAMD] #475544
12/20/18 13:58
12/20/18 13:58
Joined: Dec 2018
Posts: 24
K
Kaga Offline OP
Newbie
Kaga  Offline OP
Newbie
K

Joined: Dec 2018
Posts: 24
Good point! Thank you, I'll give it a try.

Re: One second bar data? [Re: Kaga] #475545
12/20/18 14:30
12/20/18 14:30
Joined: Dec 2018
Posts: 24
K
Kaga Offline OP
Newbie
Kaga  Offline OP
Newbie
K

Joined: Dec 2018
Posts: 24
Just converted the data to .t1, it looks ok I guess:



but now zorro complains that .t6 data is missing!



Do I still have a mistake in the script? Perhaps I have to specify somehow that t1 data should be used?

Re: One second bar data? [Re: Kaga] #475546
12/20/18 14:54
12/20/18 14:54
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
From the manual:

Quote:
On bar periods less than ~ 10 minutes, setting the TICKS flag and using high resolution .t1 price data is recommended for backtesting. It's mandatory on bar periods of less than a minute. For this set History to ".t1" and BarPeriod to the number of seconds divided by 60, f.i. BarPeriod = 5./60. for 5 seconds. Mind the decimal; 5/60 would be considered an int and thus evaluate to 0. For extremely short bar periods, make sure that TickTime is always less than a bar period.
https://zorro-project.com/manual/en/barperiod.htm

History variable:
https://zorro-project.com/manual/en/script.htm

TICKS flag:
https://zorro-project.com/manual/en/mode.htm

Re: One second bar data? [Re: AndrewAMD] #475547
12/20/18 15:04
12/20/18 15:04
Joined: Dec 2018
Posts: 24
K
Kaga Offline OP
Newbie
Kaga  Offline OP
Newbie
K

Joined: Dec 2018
Posts: 24
Thank you again! Can see progress, but there is a different error message now.
Changed the script to:

Code:
function run()
{
	set(PLOTNOW|TICKS);  // generate and use optimized parameters
	History=".t1";
	BarPeriod = 1./60;	// 1 second bars
	LookBack = 500;
	StartDate =20180201;
	EndDate =StartDate+4; 	// fixed simulation period
	
	if(is(INITRUN)) {
		assetList("History\AssetsTest.csv"); // load asset list
	}
	asset(Assets[0]);

		
// calculate the buy/sell signal
	vars Price = series(price());


// plot signals and thresholds
	plot("plot",Price,NEW,BLUE);
	PlotWidth = 600;
	PlotHeight1 = 300;
	set(PLOTNOW);
}


And zorro gives the error:



That date error is confusing, since I did not select december at all...?

Re: One second bar data? [Re: Kaga] #475548
12/20/18 15:40
12/20/18 15:40
Joined: Dec 2018
Posts: 24
K
Kaga Offline OP
Newbie
Kaga  Offline OP
Newbie
K

Joined: Dec 2018
Posts: 24
Turns out, I was missing a dataSort(1); before dataSave in the .t1 conversion script. After fixing this I now get a plot from the script. Thank you again for your help, AndrewAMD!


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1