Hello, retrieving historical value for an indicator is a pretty common task, I think it would be much easier if indicators could contain history values themselves, so we could use it like this:
ema = ExponentialMovingAverage(100, history=10)
…
ema_current = ema.Current.Value
ema_old = ema.History[10] # 1-based, because 0 means current value
Vladimir
Yuri Lopukhov,
This option already exist
IndicatorExtensions.Of(Delay(), ...)
If you are satisfied with my answer, please accept it and don't forget to like it.
Танцуй Россия!
Vladimir
Here is the code snippet from the backtest attached above.
Yuri Lopukhov
Good to know, but this is not the same, what if I need access to any or all of the last 10 values?
Also, my proposal feels more natural to use.
Vladimir
Yuri Lopukhov,
To access any or all of the last N values you may use talib indicators.
If you are satisfied with my answer, please accept it and don't forget to like it.
Vladimir
Here is the code snippet from the backtest attached above
Louis Szeto
Hi Yuri and Vladimir
RollingWindow has been supporting the use with Indicator all along. Please refer to this doc,
Best
Louis
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.
Vladimir
Louis Szeto.
Thank you.
Here is an example of what you recommended for accessing any of the last N values.
How to access all of them to calculate mean() for example?
Yuri Lopukhov
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!