Hi!
I'm building a more complex strategy, but for now let's say I want “just” to filter stocks in my universe based on the fact that their current price is > 200 day SMA. So this would be a filter for our strategy.
I think to have made it buy following this example here:
Emiliano Fraticelli
I would like that you confirm that the road I chose is the simplest and most convenient way of doing it as of today….
Here's my code, anyway. I would like to be sure that “fast” (sorry for bad naming, I just chose to reuse almost identically the code in the example) is the 200 day SMA and “slow” can be considered the latest price.
Thanks
Varad Kabade
Hi Emiliano Fraticelli,
The issue in the above logic is that the indicators created will never be ready/warmed up. To resolve the issue, we recommend using Historical data to warm up the indicator using the History method. We have created a demo algorithm that implements the above strategy. In this algorithm, we need to note that we are avoiding historical data requests for the securities that are already in the universe. We don't need to create another indicator object for the last price of the security cf.AdjustedPrice does that for us
Best,
Varad Kabade
Emiliano Fraticelli
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!