I am trying to get data from SMA on High and Low on 1m timeframe but consolidated for 15m timeframe.
As it obvious on the chart, SMA05 Hi/Lo used data from 1m timeframe, but not 15m. What am I doing wrong?
QUANTCONNECT COMMUNITY
I am trying to get data from SMA on High and Low on 1m timeframe but consolidated for 15m timeframe.
As it obvious on the chart, SMA05 Hi/Lo used data from 1m timeframe, but not 15m. What am I doing wrong?
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.
Derek Melchin
Hi Alex,
The issue above is that the indicators are updated every minute and every 5 minutes because they are registered twice. The first register occurs when we call
self.sma05_hi = self.SMA(self.sym, 5, Resolution.Minute, Field.High)
the second is when we call
self.RegisterIndicator(self.sym, self.sma05_hi, Consolidator)
To resolve the issue, we can first replace
self.sma05_hi = self.SMA(self.sym, 5, Resolution.Minute, Field.High) self.sma05_lo = self.SMA(self.sym, 5, Resolution.Minute, Field.Low)
with
self.sma05_hi = SimpleMovingAverage(5) self.sma05_lo = SimpleMovingAverage(5)
. We should then replace
self.RegisterIndicator(self.sym, self.sma05_hi, Consolidator) self.RegisterIndicator(self.sym, self.sma05_lo, Consolidator)
with
self.RegisterIndicator(self.sym, self.sma05_hi, Consolidator, Field.High) self.RegisterIndicator(self.sym, self.sma05_lo, Consolidator, Field.Low)
See the attached backtest for reference.
Best,
Derek Melchin
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.
Alex Matt
Thank you very much, Derek!
Finally, I realized how consolidated indicators work! This example is worth being included in documentation pages)) My last question how to trade in pre- and post-market hours? (since 4 am to 9:30 am and from 4 pm up to 8 pm PDT? or if it not possible, how to display it on the chart at least?
Thanx a lot, I even lost any hope to be answered ))
Sincerely,
     Alex.
Derek Melchin
Hi Alex,
Refer to this related thread for an example of trading during extended market hours.
Best,
Derek Melchin
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.
Alex Matt
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!