Hi all, I'm facing some troubles running a hourly indicator on a lower time frame (1 min) and I hope someone would be able to clarify my doubts.
Let's say the time now is 03:39PM, when I call my_hourly_indicator.Current.Value within the OnData() method, is the hourly indicator value at 03:00PM being returned?
If so, is there any way to obtain the latest hourly indicator value based on most recent data at 03:39PM?
Thanks in advance for the help.
ARam Kim
Hi, You need to set 'Resolution.Minute' to get minute data. See the attachment. Hope it helps. Thanks.
Tony Shacklock
Hi Malcolm
If you set up an indicator to use hourly data, it will be calculated every time the hourly data is feed to it, i.e. every hour. At 3:39 pm, the value at 3:00 pm is the latest value. The next value will be calculated at 4:00 pm.
Cheers, Tony
Alexandre Catarino
Hi Malcolm Tok
Good question! I know of some graphic platforms that keep updating indicators and bars with the latest data available.
The answers from both ARam Kim and Tony Shacklock (thank you!) are right and complementary.
Let me fill the gaps.
When the algorithm has subscribed to hourly data, the hourly-resolution indicator will be updated when new data is streamed through the algorithm. On the other hand, if the algorithm has subscribed to higher-resolution data (minute, second or tick), the bars/ticks will be consolidating until they form an hourly bar. At this moment the hourly bar is consolidated, the indicator will be updated.
It means that there is no intermediate indicator value in Lean/QuantConnect.
Tegster
Hi Alexandre Catarino
Is it possible to get the time frame that the indicator was computed over? for example
symbolData.momentum = self.MOM(security.Symbol, 2, Resolution.Minute)
if the above indicator value was computed over [10:00-10:02], is it possible to get the time [10:00-10:02] somehow to attach along the indicator value computed?
Shile Wen
Hi Tegster,
We can achieve this by accessing the indicator’s .Current.EndTime field, which will be the ending datetime of our time frame, and subtracting a timedelta according to the indicator’s .Period (the number of past data points used to calculate our indicator), and this will yield the starting datetime of our time frame. I’ve shown how to do this in the attached backtest.
Best,
Shile Wen
Malcolm Tok
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!