The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
typo correction: should be SMA.
Lets make it a 20-period SMA, and 14-period RSI.
Hi Kevin,
From a purely coding standpoint, I think this can definitely be done. You'd be invoking six independent indicators, and then we'd set up the OnData() method to only evaluate our current position if ten minutes have passed since the last evaluation. During this evaluation, we'd determine the boolean (True/False) result of each of the six "checks" that you've mentioned:
price cross below SMV(timeframe)
price cross above SMV(timeframe)
RSI(timeframe) cross below 30
RSI(timeframe) cross above 30
RSI(timeframe) cross below 70
RSI(timeframe) cross above 70
I assume you'd like to evaluate all six of these checks for all three lookback periods? So three lookback periods times six checks is 18 checks. So far so good.
We'd then take all of this data and throw it into an object (let's call it RollingHistory.cs) declared up in the global space that "follows us" as we move through time. This object would be responsible for containing the resultant check data as we move through time.
So after the evaluation, we pump the results of all 18 checks into a new slot in our RollingHistory.cs object, then evaluate our history based on your choice of logic.
All of this can be done from OnData(). :-)
I could even help write this up if I have time. Currently busy, but I could let you know. But for the meantime, you should know that from what you've written, this is very doable.
If you need a rolling history of data, check out the RollingWindow<T> class, designed specifically for this purpose.
I just realized I reinvented the wheel in several of my algos, Michael. I need to read through the documentation more closely :-P
@Kevin, here's a list of the currently supported indicators. Here's a thread from this forum that goes into some of the features in the indicator system. Also, take a look through the many example algorithms in github. They explain most features offered by the platform.
As for creating an indicator with a certain time frame:var atr = ATR("SPY", 14); // uses data time frame
var atr2 = new AverageTrueRange(14);
// register atr2 to receive automatic data updates
RegisterIndicator("SPY", atr2, TimeSpan.FromMinutes(30));
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can
continue your Boot Camp training progress from the terminal. We
hope to see you in the community soon!