Should the indicator extension not return a value of the std of the 20 most recent momp values? It appears it is only making the calculation with one data point, not 20, so the values for std and momp when logged are identical?
Also, could I use the abs() function to produce a positive value to perform the calculation on irrespective of whether the stock gained or lost value?
Jack
Fred Painchaud
Hi Jack,
I'm not 100% sure I got what you want but here is a try… Hope I got it right.
Fred
Vladimir
Jack Bueller, Fred Painchaud
Some notes.
To calculate momentum for 1 period, we need 2 data points: current and previous.
     self.SetWarmUp(STD_PERIOD + MOM_PERIOD + 1, res)
2022, 4, 10 was Sunday
Also we need this
     if self.IsWarmingUp or not self.std.IsReady: return
Jack Bueller
Â
Â
Â
Â
Thank you Fred and Valdimir. You are both very helpful. Any thoughts on my second question? Â Obviously the calculation is thrown off as a negative value percentage is included in the standard deviation, but understandably, I cannot manipulate the momp indicator with py abs() function without receiving an error. I am trying to find how much the stock moved, regardless if it was positive or negative, then extract statistically significant outlier with the std deviation
Vladimir
Jack Bueller,
--> Also, could I use the abs() function to produce a positive value to perform the calculation on irrespective of whether the stock gained or lost value?
We can do this using self.History().
If you are satisfied with my answer, please accept it and don't forget to like it.
Jack Bueller
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!