SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Thu Oct 21, 2021 1:41 am

All times are UTC + 3 hours

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Cross Above/Below
PostPosted: Wed Apr 13, 2011 6:48 pm 

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

I have figured out the highest value of my instrument during the trading day (defined as a 24 hour period) using:

double daysHigh = Bars.HighestHigh(startOfTrdDay,endOfTrdDay);

Now I want to figure out if the most recent bar's closing price (Bars.Last.Close) crosses above some arbitrary threshold such as (daysHigh - x%).

SQ support team had suggested I try the following:

double prevBid = -1;
double level = 0;

public override void OnQuote(Quote quote)
if (prevBid != -1)
if (prevBid <= level && quote.Bid > level)

prevBid = quote.Bid;

I would like to know if there is a way to do this using the CrossesAbove method of the BarSeries class. I have a barSeries that compiles 1-minute bars created using:
BarSeries barSeries_1Min = GetBars(BarType.Time,60);

The bars must ascend from belowand cross above the daysHigh threshold. I do not want the trigger breached if the threshold is crossed from below.

The code SQ provided would effectively do this, but I am trying to better understand SQ's methods. Can what I am trying to do be done using the Cross indicator? Or the CrossAbove/CrossBelow methods of other indicators?

Thank you.

 Post subject: Re: Cross Above/Below
PostPosted: Thu Apr 14, 2011 2:37 pm 

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

basically you can create a series in the strategy init and add daysHigh - x% to this series in OnBar and then use CrossBelow/Above for the combination of this series and bar series.


Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 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