Hello, I am creating a new algorithm that uses the MACD indicator, but I would like to use Energy ETF Basket Universe Module from the algorithm creator through "self.SetUniverseSelection(VolatilityETFUniverse())" in the Initialize method.
How do I get the indicator to get the MACD values on each individual stock in the Universe, and then how do I reference that in OnData? Here is a sample:
def Initialize(self):
self.SetStartDate(2021, 1, 1)
self.SetCash(1000000)
self.SetExecution(ImmediateExecutionModel())
self.SetRiskManagement(MaximumDrawdownPercentPerSecurity(0.05))
self.UniverseSettings.Resolution = Resolution.Minute
self.SetUniverseSelection(VolatilityETFUniverse())
self.mac = self.MACD(*symbols*, 12, 26, 9, MovingAverageType.Exponential, Resolution.Minute)
def OnData(self, data):
if self.mac.Current.Value < 1:
self.SetHoldings(*symbols*, .1)
What exactly do I have to put in place of *symbols* ? Do I have to do something like create a variable and set it equal to the Universe, then reference it with variable.Symbol?
Thanks for the help
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!