Hello,
I am trying to put my MACD consolidated 5min data into rolling window.
I've been reading the documents and other post about this but cant seem to figure it out.
When I update the rolling window im getting the data 1min at a time.
I know im adding the wrong value to the window, idk how to add the correct value which is self.macd3
Any help or advice would be greatful!
Thanks in advance!
class ParticleNadionThrustAssembly(QCAlgorithm):
def Initialize(self):
self.syl = 'FB'
self.SetStartDate(2019, 1, 1)# Set Start Date
self.SetEndDate(2019,8,30)
self.SetCash(27000) # Set Strategy Cash
self.asset = self.AddEquity(self.syl, Resolution.Minute)
self.macd_3 = self.MACD(self.syl, 3, 6, Resolution.Minute)
self.SetTimeZone('America/Chicago')
#Consolidating Data (5m)
self.fiveMinuteConsolidator = TradeBarConsolidator(timedelta(minutes=5))
self.fiveMinuteConsolidator.DataConsolidated += self.FiveMinuteBarHandler
self.SubscriptionManager.AddConsolidator(self.syl, self.fiveMinuteConsolidator)
#Macd_3 Bar Data
self.macd3 = MovingAverageConvergenceDivergence(3, 6,MovingAverageType.Exponential)
# create the 5-minutes data consolidator
fiveMinuteConsolidator = TradeBarConsolidator(timedelta(minutes=5))
self.SubscriptionManager.AddConsolidator(self.syl, fiveMinuteConsolidator)
# register the 5-minute consolidated bar data to automatically update the indicator
self.RegisterIndicator(self.syl, self.macd3, fiveMinuteConsolidator)
#macd3 5min rolling Window
def MacdUpdated(self, sender, updated):
self.macd3Win.Add(updated)
Daniel Chen
Hi Tom,
You can use the MACD indicator with 5 min consolidated data in only a few lines of code. Please check out the following backtest for details. Also, this page provides helpful information. Hope it helps!
Tom vang
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!