Hi
When we use indicators (SMA,EMA,RSI etc) for particulatar timeframes like 1m,5m etc does indicator values keep updating in realtime before the latest candle closes? OR does it wait for the latest candle to form compltely and then that candle value will be used for indicator ? I see indicator values only updates when the candle completely formed.
say moving avg calculated till bar-10, now bar 11 is forming, is there anyway the moving average will continously use the bar11 tick data untill its closed? Just like MT5 or Amibroker. let me know if there are any switch to enable this behaviour?
Thanks
Keerthan
Mia Alissi
In QuantConnect, indicators are updated when a new bar is formed. This means that if you're using a 5-minute bar, the indicator will update every 5 minutes when the bar closes and a new one starts. This is the standard behavior in most trading platforms and is designed to avoid look-ahead bias.
However, if you want to update the indicator with live data, you would need to run your algorithm on a live deployment. But, as mentioned in the forum discussion, updating the indicator at every time step until it closes at the 5-minute mark is not possible. Furthermore, it is not good practice to use indicators in that way.
Here is an example of how you might set up an EMA indicator with a 5-minute bar:
In this code,
self.ema8
is an 8-period exponential moving average (EMA) indicator. Theself.RegisterIndicator
method is used to update the indicator with data from the "SPY" equity every time a new 5-minute bar is formed.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.
Keerthan kumar
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!