6/12/2023 0 Comments Colorize photosPrice_pep = #save PEP's most recent price to the price variable Hist_coke = self.History(ke, timedelta(365),Resolution.Daily) Hist_pep = self.History(self.pep, timedelta(365),Resolution.Daily) #save the high and low price of the last year - not efficient use rolling window If not self.sma_pep.IsReady and not self.sma_coke.IsReady: Self.sma_coke.Update(time, price) #update sma indicator is ready to use from the beginning Self.sma_pep.Update(time, price) #update sma indicator is ready to use from the beginningįor time, price in closing_price_(): #iterate over time and price information in the closing price dataframe Self.sma_coke = self.SMA(ke,5,Resolution.Daily) #create 5 simple moving average indicatorĬlosing_price_pep = self.History(self.pep,5,Resolution.Daily) #historic information for the past 5 bars.Ĭlosing_price_coke = self.History(ke,5,Resolution.Daily) #historic information for the past 5 bars.įor time, price in closing_price_(): #iterate over time and price information in the closing price dataframe Self.sma_pep = self.SMA(self.pep,5,Resolution.Daily) #create 5 simple moving average indicator ke = self.AddEquity("COKE", Resolution.Daily).Symbol # Add data for COKE Self.pep = self.AddEquity("PEP", Resolution.Daily).Symbol # Add data for PEP Self.SetStartDate(2020, 1, 1) # Set Start Date The offending code is at the end of the script: import numpy as npĬlass SquareLightBrownPanda(QCAlgorithm): I have created an indicator for the ratio between PEPSI (PEP) and Coca Cola (COKE) and am trying to create a 5 days simple moving average (sma) from this indicator using IndicatorExtension and then plot the result.
0 Comments
Leave a Reply. |