Plotting and using my one second bar data?

Posted By: Kaga

Plotting and using my one second bar data? - 12/20/18 13:18

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?
Posted By: AndrewAMD

Re: One second bar data? - 12/20/18 13:28

I believe BarPeriod < 1 requires t1 data.

So try converting to t1 instead.
Posted By: Kaga

Re: One second bar data? - 12/20/18 13:37

Oh, but doesn't t1 require tick data instead of bars?
How to convert bars to t1?
Posted By: AndrewAMD

Re: One second bar data? - 12/20/18 13:54

Just use the time and the close price, and you’re all set.
Posted By: Kaga

Re: One second bar data? - 12/20/18 13:58

Good point! Thank you, I'll give it a try.
Posted By: Kaga

Re: One second bar data? - 12/20/18 14:30

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?
Posted By: AndrewAMD

Re: One second bar data? - 12/20/18 14:54

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
Posted By: Kaga

Re: One second bar data? - 12/20/18 15:04

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...?
Posted By: Kaga

Re: One second bar data? - 12/20/18 15:40

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!
© 2024 lite-C Forums