Creating sub 1 second bars

Posted By: thumper14

Creating sub 1 second bars - 04/20/23 19:36

Hello all!

I am trying to develop a strategy that trades based on bars that are less than one second. Per the user manual, "...and since Zorro allows bar periods down to 1 millisecond..."

I cannot figure out how to take advantage of this feature. For example, in my script:

History = "*.t1";
BarPeriod = 60./60;
set(TICKS);
This yields 60 second bars.

History = "*.t1";
BarPeriod = 1./60;
set(TICKS);
This yields 1 second bars

History = "*.t1";
BarPeriod = 0.1/60;
set(TICKS);
This appears to round bars up to 1 second. I also tried ".1/60" as well, same apparent result.

How do I generate, for instance, 10ms bars?

Cheers!
Posted By: Grant

Re: Creating sub 1 second bars - 04/20/23 20:39

By using 'BarPeriod = 0.01/60', I believe.

https://zorro-project.com/manual/en/barperiod.htm
Posted By: thumper14

Re: Creating sub 1 second bars - 04/21/23 15:25

Grant, thanks for the reply.

Yes, that is correct, but after more digging, that's only the first step. Fill mode must be set to "8"

"Order filling and HFT Simulation"
https://zorro-project.com/manual/en/fill.htm

"Zorro can be used for testing HFT systems in Fill mode 8."

So, even though my original post had the correct syntax for "BarPeriod" I did not have the Fill Mode set to 8. This is what I was able to get to run to generate 10ms bars:
History = "*.t1";
BarPeriod = .01/60;
Fill = 8;
set(TICKS);

I missed this originally because, for the purpose of my work, I'm not attempting to do an "HFT" strategy, but instead, taking traditional strategy ideology (using candles and an indicator soup approach) and doing it fast.

NOTE - it would appear that, in this case, it's not "building" 10ms bars, as in accumulating the price changes across those 10ms (there's no Open, High, Low, Close like a traditional candle), but instead, getting the last price every 10ms and just plotting that. This begs the next question, what is the 10ms time change based on? Every 10ms since the market open, the backtest start period/time, systematically stepping through every 10ms (i.e. 10:00:00.010; 10:00:00.020;10:00:00.030...) or some other method, I don't know, but that is a future problem to solve.

Bottom Line, with Fill = 8, you can chart and backtest with sub one second bars, even if you're not doing an "HFT simulation." Fun facts!
Posted By: Grant

Re: Creating sub 1 second bars - 04/21/23 19:34

A .t1 data set is based on bid / ask tick data, which has no linear intervals, so there's no open-high-low pricing. A 10 ms interval simply checks the last bid or ask, so sometimes there's a price change, sometimes there isn't.

https://zorro-project.com/manual/en/history.htm
© 2024 lite-C Forums