I am trying to create 50-day and 200-day Simple Moving Average indicators for multiple stocks. Does this setup work?

### In Initialize Function self.tickers = ["TSLA", "FB", "SPY"] self.sma_slow = {} self.sma_fast = {} for ticker in self.tickers: self.AddEquity(ticker, Resolution.Daily) self.sma_slow[ticker] = self.SMA(ticker, 200, Resolution.Daily) self.sma_fast[ticker] = self.SMA(ticker, 50, Resolution.Daily)

My goal is to call the SMA values later in the following form:

### In other function for ticker in self.tickers: if self.sma_slow[ticker].Current.Value < self.sma_fast[ticker].Current.Value: ### Do something

Is this method doing what I think it is? The goal is to be able to call the 50-day and 200-day SMA values separately for each ticker. I have seen other examples where people don't index the fast and slow values by ticker, and it still seems to work, but that method is rather confusing.

 

Another question: How do I add history to my SMA indicators without having to wait 200 days for a warm-up period to finish? I would prefer to be able to run my code and have it decide things without waiting 200 days for the slow SMA to be initialized.

Author