Hey Guys!
I am new to Python and just trying to figure out a something. I want to run the backtest on a minute resolution but have the SMA run on a daily resolution. My current SMA I have added:
self.sma = self.SMA("SPY", 5)
I tried for a while to change the resolution of the indicator by adding Resolution.Daily i.e.
self.sma = self.SMA("SPY", 5, Resolution.Daily)
but this didn't seem to work.
If anyone is able to give some guidance that would be such a huge help. I am just looking to run a daily resolution on the SMA and a minute resolution on the equity.
Thanks for your time
Rahul Chowdhury
Hey Sebastian,
To subscribe to minute resolution data, while also having a daily indicator, we need to
self.AddEquity("SPY", Resolution.Minute)self.sma = self.SMA("SPY", 5, Resolution.Daily)
We can verify that our indicator is a daily indicator by checking how often it is updated. This can be accomplished by using the Updated event handler for our indicator.
self.sma.Updated += self.OnSMA
In our event handler let's debug when the time it is updated.
def OnSMA(self, sender, updated): if self.sma.IsReady: self.Debug(f"SMA Updated on {self.Time} with value: {self.sma.Current.Value}")
I highly recommend you checkout the bootcamps, they cover many different aspects of using indicators. If you have any other issues or concerns, please don't hesitate to ask! Hope that helped!
Sebastian Bunney
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!