SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Wed Dec 13, 2017 6:35 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: How to pass BarSeries ?
PostPosted: Wed Feb 11, 2015 3:24 pm 
Offline

Joined: Thu Dec 29, 2011 5:59 am
Posts: 87
A C# question. I've been using onBar for all my calculations so far. Now I need to pass a barseries from onBar to another routine. That routine will be called by others as well. Does something like below workable ?

public override void OnBar(Bar bar)
{
BarSeries FiveMinutesBars = GetBars(BarType.Time,300);
calculateXYZ(FiveMinutesBars);
}


public void calculateXYZ (BarSeries inputSeries)
{
if (inputSeries.Count > 1)
{ do something }
}


Top
 Profile  
 
PostPosted: Wed Feb 11, 2015 3:30 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6783
Yes, why not? You can also call

BarSeries FiveMinutesBars = GetBars(BarType.Time,300);

in your calculateXYZ method and you will get a reference to the same bar series (via the DataManager) as in OnBar.

PS. I guess you have these two methods working in the same thread.

Regards,
Anton


Top
 Profile  
 
PostPosted: Wed Feb 11, 2015 3:47 pm 
Offline

Joined: Thu Dec 29, 2011 5:59 am
Posts: 87
Thanks for the advice. Then if I use

BarSeries FiveMinutesBars = GetBars(BarType.Time,300)

in my calculateXYZ method I wouldn't need to pass the barseries as parameter to this method at all.

Eventually I guess I would better to code the calculateXYZ into a customs indicator.


Top
 Profile  
 
PostPosted: Wed Feb 11, 2015 4:24 pm 
Offline

Joined: Wed Sep 18, 2013 10:50 am
Posts: 67
Location: London
Hi Dr Anton

Can you please elaborate on your thread comment?

Regards
Maddy

Dr. Anton Fokin wrote:
PS. I guess you have these two methods working in the same thread.


Top
 Profile  
 
PostPosted: Wed Feb 11, 2015 7:24 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6783
Well, just a normal assumption. If you call OnBar from one thread and CalculateXYZ from another thread you should add locks when you access the same object (bar series). You don't need to do it if you call these two methods from the same thread, which is obviousely the case if you call CalculateXYZ from OnBar.

Regards,
Anton


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 4 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