SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Sat Sep 26, 2020 6:53 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 27 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Wed Aug 31, 2011 5:19 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6817
Only Strategy bar series are drawn on the bar chart (and automatically updated when a new live bar comes in). They can be accessed by calling Strategy.Bars or Strategy.GetBars(). I don't see any connection between these series and your 3T series in your code.


Top
 Profile  
 
PostPosted: Wed Aug 31, 2011 5:27 pm 
Offline

Joined: Tue Mar 15, 2011 7:15 pm
Posts: 80
Fair enough. I will add the GetBars code you have provided. Your responses clarified that CompressBars does not do exactly what I thought given the information in the API help.

If the BarSeries are not being applied to the Strategy bars, where are they actually going? I know they exist as I see the BarSeries count increment at each call of the OnBar event.

Thanks.


Top
 Profile  
 
PostPosted: Wed Aug 31, 2011 5:37 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6817
ivb73077 wrote:
CompressBars does not do exactly what I thought given the information in the API help.


Why?


Top
 Profile  
 
PostPosted: Wed Aug 31, 2011 5:40 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6817
ivb73077 wrote:
If the BarSeries are not being applied to the Strategy bars, where are they actually going? I know they exist as I see the BarSeries count increment at each call of the OnBar event.


This line I don't understand. What are BarSeries? BarSeries is a class name...

You can create your own

BarSeries myBars = new BarSeries(...);

or

BarSeries myBars = DataManager.CompressBars(...) or DataManager.GetHistoricalBars(...)

and you can add bars to this series manually in OnBar but it has nothing to do with bar series registered in your Strategy to be automatically drawn and updated, as I explained above.


Top
 Profile  
 
PostPosted: Wed Aug 31, 2011 5:51 pm 
Offline

Joined: Tue Mar 15, 2011 7:15 pm
Posts: 80
You stated that " You code doesn't add bars to any series. It gets a reference to a bar series created in CompressBars and assigns it to barSeries_3T." I assumed that CompressBars appended the compressed bars to a series.

I have been struggling with the data import issue for some time now as evidenced in viewtopic.php?f=44&t=8986

As per your second reply "What are BarSeries? BarSeries is a class name...", I understand that.

You stated I had to add the bars to Strategy.Bars. I am adding bars in the OnBar event to a BarSeries that I named barSeries_3T. If this does not actually add them to the Strategy.Bars, I am unclear what these bars are being added to.

I use BarSeries myBars = DataManager.CompressBars(...). You are suggesting this does not add these to the bar series registered. Presumably, this can only be done by also using Strategy.GetBars(). If that is correct, could I then use:

1. BarSeries oldBars= DataManager.CompressBars(...)
2. BarSeries barSeries_3T= GetBars(...)
3. foreach(Bar bar in oldBars)
barSeries_3T.Add(bar);
4. in OnBar, add live bars to myBars using if ((bar.Type == BarType.Tick) && (bar.Size == barSize_3T)) barSeries_3T.Add(bar);

Would this then display the historicals in the chart and allow live updating?


Top
 Profile  
 
PostPosted: Wed Aug 31, 2011 6:31 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6817
You don't need to add live bars yourself to a bar series thet you reference using GetBars(..)


Top
 Profile  
 
PostPosted: Wed Aug 31, 2011 6:34 pm 
Offline

Joined: Tue Mar 15, 2011 7:15 pm
Posts: 80
2 quick items:

1. Per your comment that I need not add live bars myself if referenced using GetBars, is this the case even if I have >1 BarSeries? How would the event know which BarSeries to add the live bar to if I do not instruct it?

2. Are the other steps I delineated then correct?


Top
 Profile  
 
PostPosted: Wed Aug 31, 2011 7:20 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6817
There is a table of Strategy bar seris indexed by bar size and type. Every incoming bar is automatically added to a corresponding bar series in this table. A particular series is created either when a first live bar with corresponding bar size and type comes in or when a user calls GetBars with such size and type for the first time.


Top
 Profile  
 
PostPosted: Wed Aug 31, 2011 7:29 pm 
Offline

Joined: Tue Mar 15, 2011 7:15 pm
Posts: 80
Ah. Very useful to know.

Then all I need to do to have preloaded bars is:

1. BarSeries oldBars= DataManager.CompressBars(...)
2. BarSeries barSeries_3T= GetBars(...)
3. foreach(Bar bar in oldBars)
barSeries_3T.Add(bar);

and the live bars with then take care of themelves because I used step #2?


Top
 Profile  
 
PostPosted: Wed Aug 31, 2011 7:37 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6817
Just try and tell us if it works. To me it looks ok but who can be sure without trying hard ? :D


Top
 Profile  
 
PostPosted: Wed Aug 31, 2011 7:45 pm 
Offline

Joined: Tue Mar 15, 2011 7:15 pm
Posts: 80
I will try it this evening as I am not connected to SQ at this time. Thanks for all the help.


Top
 Profile  
 
PostPosted: Thu Sep 01, 2011 5:16 am 
Offline

Joined: Tue Mar 15, 2011 7:15 pm
Posts: 80
Doing the following worked successfully and displays the historical bars to the chart. Thanks.

1. BarSeries oldBars= DataManager.CompressBars(...)
2. BarSeries barSeries_3T= GetBars(...)
3. foreach(Bar bar in oldBars)
barSeries_3T.Add(bar);


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 27 posts ]  Go to page Previous  1, 2

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 3 guests


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