Hi I'm new and trying to get my trading strategy operating in code. For my alogorithm, I'm trying to use ATR on the 15 minute time frame. The problem is that it doesn't seem to be consolidating the indicator and I'm getting the same values as I would on the 1 minute time frame when I'm expecting the values to be much larger since they are the range from 15 mins instead of just 1 min. I'm also not sure if my symbol prices are getting consolidated properly either?
I made a quick backtest that shows the issues I'm having. All the values that I'm comparing between the minutes and the 15 minute consolidator are in the log.
Thanks and I appreciate this forum!
Derek Melchin
Hi Lee,
The reason the ATR values are so similar is because the indicator is updated with both minute bars and 15-minute consolidated bars. To get this working as intended, we can create indicators for both of the time frames.
self.AtrIndicatorMinute = self.ATR(self.MySymbol, self.IndicatorLength) self.MaxIndicatorMinute = self.MAX(self.MySymbol, self.IndicatorLength) self.AtrIndicator15Minute = AverageTrueRange(self.IndicatorLength) self.MaxIndicator15Minute = Maximum(self.IndicatorLength)
We then need to ensure we select an apprropriate warm-up period
self.TimeFrame = 15 #15 minute bars self.SetWarmup(self.IndicatorLength * self.TimeFrame)
We setup the consolidation process with
self.consolidator = QuoteBarConsolidator(self.TimeFrame) self.consolidator.DataConsolidated += self.CustomHandler self.SubscriptionManager.AddConsolidator(self.MySymbol, self.consolidator)
With each 15-minute interval, the data is consolidated with this handler
def CustomHandler(self, sender, consolidated): self.AtrIndicator15Minute.Update(consolidated) self.MaxIndicator15Minute.Update(consolidated.Time, consolidated.High)
See the attached backtest and logs for reference. Note the 15-minute ATR value is now much larger than the minute version.
For full understanding of what we did here, I recommend reviewing our documentation on data consolidation and basic indicator usage.
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.
Lee Renshaw
Hi Derek, Thanks for the help! I'm going to give this a try and report back.
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!