SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Tue Oct 20, 2020 12:06 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 27 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Wed Aug 31, 2011 7:20 am 
Offline

Joined: Tue Mar 15, 2011 7:15 pm
Posts: 80
Hello,

I am preloading bars at OnStrategyStart by importing a historical trade series from my provider using:

TradeSeries histTrdSeries = GetHistoricalTrades(provider, histInstr, startOfTrdDay,
DateTime.UtcNow.AddSeconds(-1));
barSeries_3T = DataManager.CompressBars(histTrdSeries,BarType.Tick, 3);

I am able to see that this successfully loads the trades and creates bars (and stores them into the BarSeries) because I can see the BarSeries trade count. However, the historical bars do not display on the charts. Am I doing something wrong? Could someone please explain what I need to do to have the preloaded bars display on the charts?

Thank you.


Top
 Profile  
 
PostPosted: Wed Aug 31, 2011 8:16 am 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6817
Do you draw this series on the bar chart?

Regards,
Anton


Top
 Profile  
 
PostPosted: Wed Aug 31, 2011 8:43 am 
Offline

Joined: Tue Mar 15, 2011 7:15 pm
Posts: 80
The live bars display on the chart automatically. I didn't realize I had to explicitly instruct the program to draw the bars. Can I just use Draw(myBarSeries) as I would with the indicators? Thanks.


Top
 Profile  
 
PostPosted: Wed Aug 31, 2011 9:37 am 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6817
Hi,

I am not sure you can draw bar series different from the main bar series (i.e. Strategy.Bars) on the bar chart. Why don't you want to preload historical bars into Strategy.Bars series so that it's automatically drawn on the bar chart?

Regards,
Anton


Top
 Profile  
 
PostPosted: Wed Aug 31, 2011 3:47 pm 
Offline

Joined: Tue Mar 15, 2011 7:15 pm
Posts: 80
It certainly is not that I don't want to...I'm just not clear how I would do that.

Can you please give me a line of code explaining how I would do that? Can you also explain where I am loading the bars to with my current code if not to the Strategy.Bars? Thanks.


Top
 Profile  
 
PostPosted: Wed Aug 31, 2011 4:16 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6817
viewtopic.php?f=64&t=6227


Top
 Profile  
 
PostPosted: Wed Aug 31, 2011 4:39 pm 
Offline

Joined: Tue Mar 15, 2011 7:15 pm
Posts: 80
Yes. I am familiar with this FAQ and used it to determine that I needed to use DataManager.CompressBars to build my BarSeries from the historical TradeSeries. However, I am still unclear about implementing your suggestion to add bars to the Strategy.Bars. I have multiple BarSeries in my strategy. Would I then need to use something like GetBars(instrument, BarType.Time, 300) to add 5m bars to the Strategy.Bars instead of using Bars.Add(bar)?

I thought GetBars was used to create a BarSeries? Would I then not use DataManager.CompressBars to create my BarSeries from historicals?

Could you please explain what my current code is adding bars to if not the Strategy.Bars?

These questions are admittedly a bit rudimentary, but I am still not clear on how data import works. The rest of my strategy code works quite well in SQ, but the historical import process leaves me with a bit of uncertainty.

Thank you.


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

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6817
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.


Top
 Profile  
 
PostPosted: Wed Aug 31, 2011 4:47 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6817
BarSeries series = GetBars(...);

foreach(Bar bar in barSeries_3T)
series.Add(bar);


Top
 Profile  
 
PostPosted: Wed Aug 31, 2011 4:56 pm 
Offline

Joined: Tue Mar 15, 2011 7:15 pm
Posts: 80
I add live bars to the BarSeries in the OnBar event using :

if ((bar.Type == BarType.Tick) && (bar.Size == barSize_3T)) barSeries_3T.Add(bar);

I would have assumed that when I assign the compressed bars to barSeries_3T using
barSeries_3T = DataManager.CompressBars(histTrdSeries,BarType.Tick, 3);
that this would have added the bars to that BarSeries.

Is this not the case? Or should I do the following:

1. create the bars in the series using DataManager.CompressBars()
2. create a new BarSeries (i.e. named series as in your example below)
3. iterate thru the original BarSeries adding the bars to "series"
4. continue adding live bars to "series" in the onBar event.

As noted, my impression was that combining steps 1 and 4 would be sufficient.


Top
 Profile  
 
PostPosted: Wed Aug 31, 2011 4:59 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6817
What is barSeries_3T ?


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

Joined: Tue Mar 15, 2011 7:15 pm
Posts: 80
I think my confusion stems from the API Help which states that CompressBars "Generates bar series with new bar size from bars". I interpreted this to mean that it also appends the compressed bars to the series. This appears to be the case since if I preload, for example, 1 hour of trades and compress them into 5m bars, I see 12 completed bars in the BarSeries.Count.

I am not sure what I am missing here...


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

Joined: Tue Mar 15, 2011 7:15 pm
Posts: 80
barSeries_3T is just my name for a 3 tick barseries.


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

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6817
How you create it?


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

Joined: Tue Mar 15, 2011 7:15 pm
Posts: 80
Created using barSeries_3T = DataManager.CompressBars(historicalTradeSeries, BarType.Tick, 3);

In the end, all I want to do is preload several barseries (3t, 1m, 5m) with historical bars and append the corresponding live bars to each of those series.


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

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:  
Powered by phpBB® Forum Software © phpBB Group