SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Mon Nov 23, 2020 7:43 pm

All times are UTC + 3 hours

Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Wed Nov 07, 2007 6:46 am 

Joined: Tue Sep 11, 2007 6:36 am
Posts: 28

I'm trying to access indicators from multiple time frames in the strategy. In particular, I have 2 bar series, one for 30 minutes and one for 4 hours. The indicator is the stochastic indicator. I cannot find how to get access to the indicator for the 4 hour time frame.

Consider this OnStrategyStart method:
public override void OnStrategyStart()
      _dSlow = new D_Slow(Bars, 5, 3, 3, Color.Red);
      _kSlow = new K_Slow(Bars, 5, 3, Color.Blue);
      Draw(_dSlow, 2);
      Draw(_kSlow, 2);         

I note that the above code produces two bar charts for each time frame. When I switch between the 30m and 4h charts, I can clearly see the correct (30m or 4h) stochastic indicator chart at the bottom. Therefore, somehow the indicator for 4h is being built - I just can't get access to it in code.

I tried two things. First, the member variable _dSlow always refers to the indicator in the 30 minute timeframe, even when OnBar() is called with a 4 hour bar. So that's not it.

I also tried making a new indicator and specifying the 4h bar series like this (in OnStrategyStart):

_fourDSlow = new D_Slow(GetBars(BarType.Time, 14400), 5, 3, 3, Color.Red);

however, the indicator is also built with 30minute bars - it is identical to the _dSlow indicator.

How can I get the 4h indicator???

- AO

PostPosted: Wed Apr 06, 2011 6:10 pm 

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

Did you ever figure out the solution to this problem? I am encountering the same issue and would appreciate any guidance you can provide.

Thank you.

PostPosted: Fri Apr 22, 2011 6:34 am 

Joined: Mon Dec 06, 2010 2:15 am
Posts: 47

PostPosted: Fri Apr 22, 2011 8:58 am 

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

- add 30 min and 4 hour bars to the market data folder of your strategy. Make sure you are getting these bars into your strategy.
- get reference to these bar series in your strategy

bars30m = GetBars(30*60);
bars4h = GetBars(4*60*60);

This is the key point. You should not use default Strategy.Bars if you have more than one time frame. You have no guarantee if Bars refers to 30 min or 4 hour series.

- use these series as inputs to corresponding indicators.

Though I still don't fully understand the original question. What do you mean you can not access indicators?


Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 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:  
Powered by phpBB® Forum Software © phpBB Group