Hello All,
I am looking for a little help with my algorithm. I have calculated the Hull Moving Average (HMA) of "SPY", then have taken 2-period (in my case 2 minute) percent change "slope" of the HMA as my indicator of when to Buy or Sell. What I want to do next and what I am having trouble with is creating a Simple Moving Average (SMA) of that "slope" with a period of 25. I have tried several different methods with no luck. I have attached the code that contains the HMA and "slope" calculations, This issue that I can't seem to get over is: I calculate the "slope" in the "On Data" section, but then I can't initialize the SMA with data that hasn't been calculated yet. Any help with creating an SMA of the "slope" would be great.
Also, is there an easier to calculate the "slope" (even though it is only one line) by calculating the percent change of the HMA? Maybe a one-liner in the initialize section?
Thank you for your help.
Derek Melchin
Hi Tate,
A simpler approach of calculating the "slope" of the HMA would be to use an indicator extension. Specifically, taking the RateOfChangePercent of the HMA indicator. Then to calculate the SMA of this indicator extension, we can use another indicator extension.
See the attached backtest for reference.
Best,
Derek Melchin
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.
Tate Linzel
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!