Hello Everyone!
I like to see if this is possible with QuantConnect. My trading signal would be like 3 steps processes as the following:
1. For each 10 minute price update, calculate the the simple moving average and RSI for different time frames :
SMV(timeframe) :
SMV(10 minutes)
SMV(1 hour)
SMV(1 day)
RSI(timeframe) :
RSI(10 minute)
RSI(1 hour)
RSI(1 day)
2. for each indicator calculated, fire an event if the following condition is met:
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
3. process the event queue. Based on the history of event queue, I have some logic to determine whether an event is to be ignored, or to be used to trigger a trade.
The reason to keep an event queue is I need the whole event history, not just the event itself to determine how to use the event
It would be great if you can suggest how to structure, or provide some sample code to accomplish this.
Thanks!
Kevin
Kevin W
typo correction: should be SMA. Lets make it a 20-period SMA, and 14-period RSI.
Stephen Oehler
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.
Michael Handschuh
If you need a rolling history of data, check out the RollingWindow<T> class, designed specifically for this purpose.
Stephen Oehler
I just realized I reinvented the wheel in several of my algos, Michael. I need to read through the documentation more closely :-P
Kevin W
Michael Handschuh
@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));
Kevin W
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!