I need some help handling multiple symbols for my strategy.  My goal is to buy multiple securities (UNH and DIS for simplicity sake) if the price for each symbol is <= to Lower Bollinger Band Indicator.  Assuming my Initialize block is ok, I need help getting the price for each symbol for comparison to each symbol's bolinger band and then buy each security if the condition is met.  Please see attached backtest.  I was able to do this successfully with one symbol but cannot pull it off with multiple.  Any help would be greatly appreciated!

from QuantConnect.Data.Market import TradeBar from datetime import timedelta from System import * from QuantConnect import * from QuantConnect.Algorithm import * from QuantConnect.Indicators import * import decimal as d class BollingerBreakoutAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2017, 1, 1) self.SetEndDate(2019, 11, 25) self.SetCash(100000) Symbols = ["UNH", "DIS"] for symbol in Symbols: securities = self.Securities[Symbols].Price equity = self.AddEquity(Symbols, Resolution.Daily).Symbol self.bband = self.BB(Symbols, 20, 2, MovingAverageType.Simple, Resolution.Daily) self.SetWarmUp(20, Resolution.Daily) self.SetBenchmark("SPY") def OnData(self, data): if not (self.bband.IsReady): return #get price for each symbol prices = self.Securities[Symbols].Price #compare price for each symbol to the indicator if Symbols <= self.bband.LowerBand.Current.Value: #buy stock for each symbol that meets the criteria self.MarketOrder(Symbols, 1)

 

Author