It is common to keep track of historical values for various things. Sometimes we need to keep track of the last n bars of data, or sometimes we want to keep track of the last n values for an indicator. This is typically accomplished using a RollingWindow<T> and manually adding the values to the rolling window. In this algorithm, I've defined a HistoryTracker helper class which can make tracking the history of consolidators and indicators a one liner in Initialize!
This works by binding to the event handler on the indicator or consolidator and updating the rolling window from that!
Have a peek and let me know what you guys think!
Vincenzo Somma
Michael Handschuh
foreach (var tradeBar in tradeBarHistory) { myIndicator.Update(tradeBar.EndTime, tradeBar.Close); }
Desi Monk
Hi Michael,
Your easy history of indicator tracking method is very handy. I could not figure out syntax needed to add stochastic. Can you please help ?
Following is what I tried.
Stochastic sto = STO(sec.Symbol, 14, 1, 1, Resolution.Hour);
RollingWindow<IndicatorDataPoint> historySto = HistoryTrackerImpl.Track(sto, 3);
Michael Handschuh
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!