SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Tue Dec 07, 2021 3:52 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Tue May 03, 2016 8:33 pm 
Offline

Joined: Thu Sep 17, 2015 5:52 am
Posts: 133
Hi SQ,

Can you please show me an example of what I'd change in OQ2014's SMACrossover example so that it will enter long if the fast moving average crossed above the slow moving average 5 bars ago?

(FYI: I know the "How to access n-bars ago bar in a bar series" section OQ2014's FAQ's documentation mentions how to access data from N-bars ago, however I'm still having trouble figuring out how to get it to work in the use case mentioned above.)

Thanks


Top
 Profile  
 
PostPosted: Thu May 05, 2016 4:30 pm 
Offline

Joined: Wed May 05, 2010 9:49 pm
Posts: 583
Hi M101,
It will be looks like:
Code:
         DateTime time = Bars.Ago(5);
         Cross cross = sma1.Crosses( sma2, time );

Don't forget check available amount of Bars.


Top
 Profile  
 
PostPosted: Tue May 10, 2016 1:08 am 
Offline

Joined: Thu Sep 17, 2015 5:52 am
Posts: 133
Hi skuvv,

I tried that and am getting this error message when I press the compile button
Quote:
Cannot implicitly convert type 'SmartQuant.Bar' to 'System.DateTime'


Just to make totally sure I get it right this time, can you please post a full Solution file example of how to do this?

I'm sure other OQ2014 users will appreciate the Solution file example as well.

Thanks


Top
 Profile  
 
PostPosted: Tue May 10, 2016 9:52 am 
Offline

Joined: Wed May 05, 2010 9:49 pm
Posts: 583
Little mistake, this will work:
Code:
         DateTime time = Bars.Ago(5).DateTime;
         Cross cross = sma1.Crosses( sma2, time );


Top
 Profile  
 
PostPosted: Fri May 13, 2016 1:36 am 
Offline

Joined: Thu Sep 17, 2015 5:52 am
Posts: 133
Great, that works, thanks!


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