SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Tue Oct 16, 2018 1:34 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: GetBars() method
PostPosted: Tue Mar 15, 2011 8:02 pm 
Offline

Joined: Tue Mar 15, 2011 7:15 pm
Posts: 80
I understand how to use the GetBars method to specify the bar length (i.e. GetBars(300) returns a 5-minute bar), but I am not certain how to generate a bar measured in terms of ticks. For example, I would like to set each bar to represent 7 ticks. I can see how to do this via the GUI, but am not sure how to implement programatically (via C#) in openQuant. The GetBar method examples I have seen all take int parameters who values represents the number of seconds the bar length should capture, but I've not seen any calls showing how to set the bar length to a number of ticks.

Can someone explain how to set the bar length to x-number of ticks (i.e. set each bar to 7 ticks)?

Thanks.


Top
 Profile  
 
 Post subject: Re: GetBars() method
PostPosted: Tue Mar 15, 2011 8:15 pm 
Offline

Joined: Thu Jun 08, 2006 3:56 pm
Posts: 537
Location: BC Canada
This is not an exact answer, but I'm thinking of two things:

If you want to use 7 tick bars in your strategy and you have ticks (trades) in the historical database, then you could just define a 7-tick range bar in the GUI, and enable the BuildBarsFromTrades=true in the GUI. That way you'd get 7-tick range bars.

If you're trying to generate a BarSeries in the database, then I suppose you could write a script (I have not tested this, so I don't know if it's possible) to use CompressBars to compress trades into 7-tick Range bars (if that is even possible with CompressBars).

Otherwise, you might have to read and count the ticks yourself in code, and generate the range bars in a series, and then write the series to the historical database.

Maybe you could state exactly what your goal is? (range bars in a strategy, or range bars in the historical database?)

Maybe the SQ guys could comment on exactly how to achieve your goal?


Top
 Profile  
 
 Post subject: Re: GetBars() method
PostPosted: Tue Mar 15, 2011 8:34 pm 
Offline

Joined: Tue Mar 15, 2011 7:15 pm
Posts: 80
I am trying to incorporate range bars in a strategy. For example, my strategy would call certain indicators (i.e. SMA) on the bar (which would be defined as containing 7 ticks). If the long-term SMA (i.e. 100) on the close of the bar is above the short-term SMA (i.e. 25) on the close of the bar, the strategy would generate a long/short signal.

The lone problem remains as to how I can generate a bar which represents 7 ticks (i.e. captures trading activity rather than some measure of chronological time such as 1m, 5m, etc.). Thank you.


Top
 Profile  
 
 Post subject: Re: GetBars() method
PostPosted: Tue Mar 15, 2011 8:45 pm 
Offline

Joined: Thu Jun 08, 2006 3:56 pm
Posts: 537
Location: BC Canada
It sounds like you should just define a range bar series in the normal way, using the GUI.
Or here's a bit of code.

Code:
long   BarSizeRange = 7;
ops.RangeBars1 = GetBars (BarType.Range, BarSizeRange);


Top
 Profile  
 
 Post subject: Re: GetBars() method
PostPosted: Tue Mar 15, 2011 9:02 pm 
Offline

Joined: Tue Mar 15, 2011 7:15 pm
Posts: 80
kkkwj - The code syntax was precisely what I needed. All the samples I had seen took a single argument which was the bar length measured in seconds. I needed an overloaded version of method that took the "length" argument as a number of ticks. Thank you.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group