Hey guys,
Some could telling me why am I getting this error?
Runtime Error: AttributeError : 'IndicatorDataPoint' object has no attribute 'UpperBand'
at BolbandUpdated_30 in main.py:line 67
AttributeError : 'IndicatorDataPoint' object has no attribute 'UpperBand' (Open Stacktrace)
Thank you
I did not attached any backtest because it does not found backtest in this project but I'm sure I have back tested this algorithm
from System import *
from QuantConnect import *
from QuantConnect.Algorithm import *
from QuantConnect.Indicators import *
from QuantConnect.Data.Market import TradeBar
import decimal as dclass RollingWindowAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2018, 6, 1) #Set Start Date
self.SetEndDate(2019, 3, 22) #Set End Date
self.SetCash(100000) #Set Strategy Cash
self.SetBrokerageModel(BrokerageName.FxcmBrokerage)
self.SetTimeZone("Europe/Rome")
self.SetWarmUp(100)
self.symbols = ["EURUSD","EURAUD","GBPUSD","AUDUSD"]
self.forex = self.AddForex(self.symbols[0], Resolution.Minute, Market.FXCM)
consolidator_30 = QuoteBarConsolidator(30)
consolidator_30.DataConsolidated += self.On30Data
self.SubscriptionManager.AddConsolidator(self.symbols[0], consolidator_30)
self.window_30 = RollingWindow[QuoteBar](2) consolidator_60 = QuoteBarConsolidator(60)
consolidator_60.DataConsolidated += self.On60Data
self.SubscriptionManager.AddConsolidator(self.symbols[0], consolidator_60)
self.window_60 = RollingWindow[QuoteBar](2)
#consolidator_240 = QuoteBarConsolidator(240)
#self.SubscriptionManager.AddConsolidator(self.symbols[0], consolidator_240)
#b240 = self.RegisterIndicator(self.symbols[0], self.Bolband, consolidator_240)
self.Bolband_30 = self.BB(self.symbols[0], 20, 2, MovingAverageType.Simple, Resolution.Minute)
self.Bolband_30.Updated += self.BolbandUpdated_30
self.RegisterIndicator(self.symbols[0], self.Bolband_30, consolidator_30)
self.SubscriptionManager.AddConsolidator(self.symbols[0], consolidator_30)
self.BolbandWindow_30 = RollingWindow[IndicatorDataPoint](3)
self.Bolband_60 = self.BB(self.symbols[0], 20, 2, MovingAverageType.Simple, Resolution.Minute)
self.Bolband_60.Updated += self.BolbandUpdated_60
self.RegisterIndicator(self.symbols[0], self.Bolband_60, consolidator_60)
self.SubscriptionManager.AddConsolidator(self.symbols[0], consolidator_60)
self.BolbandWindow_60 = RollingWindow[IndicatorDataPoint](3)
#self.AddEquity("SPY", Resolution.Minute)
#consolidator = TradeBarConsolidator(30)
#self._sma = SimpleMovingAverage(10)
#self.RegisterIndicator("SPY", self._sma, consolidator)
#self.SubscriptionManager.AddConsolidator("SPY", consolidator)
def BolbandUpdated_30(self, sender, updated):
self.BolbandWindow_30.Add(updated)
UpperBand_30 = self.BolbandWindow_30[0].UpperBand.Current.Value
LowerBand_30 = self.BolbandWindow_30[0].LowerBand.Current.Value
def BolbandUpdated_60(self, sender, updated):
self.BolbandWindow_60.Add(updated)
UpperBand_60 = self.BolbandWindow_60[0].UpperBand.Current.Value
LowerBand_60 = self.BolbandWindow_60[0].LowerBand.Current.Value
def On30Data(self, sender, bar):
self.window_30.Add(bar)
close_price_30 = self.window_30[0].Close
def On60Data(self, sender, updated):
self.window_60.Add(bar)
close_price_60 = self.window_60[0].Close
def OnData(self, data):
#fxOpen = data['EURUSD'].Open
#fxClose = data['EURUSD'].Close
#self.window.Add(data["EURUSD"])
if not (self.window_30.IsReady and self.window_60.IsReady):
return
#holdings = self.Portfolio["EURUSD"].Quantity
#previousPrice = self.window[1].Close
#stop_price_ = self.Securities['EURUSD'].Price * 0.50
#stop_price = self.Securities['EURUSD'].Price * 1.20
def OnOrderEvent(self, orderEvent):
order = self.Transactions.GetOrderById(orderEvent.OrderId)
if order.Status == OrderStatus.Filled:
if order.Type == OrderType.Limit or order.Type == OrderType.StopMarket:
self.Transactions.CancelOpenOrders(order.Symbol)
if order.Status == OrderStatus.Canceled:
self.Log(str(orderEvent))
Douglas Stridsberg
I'm not sure triple posting your question is going to lead to more answers.
I suspect Upper/Lower windows are not passed through when an indicator is consolidated. I'd probably try to make a rolling window for each (Upper, Middle & Lower) - that's guaranteed to work but may not be the most elegant solution.
Halldor Andersen
Hi Patrik.
I provided you with an example on how to use consolidator in combination with a rolling window in this post.
Patrik Pavan
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!