Hi,
I'm trying to consolidate minute data into 4H bars aligned with the regular OANDA exchange hours.
For example, I'd like the 4H bars to consolidate for 17:00, 21:00, 01:00, 05:00, 09:00, 13:00, etc.
I've followed Louis Szeto's example given in the following thread:
You can find my implementation in the attached backtest.
However, the logging of said backtest gives the following:
2024-05-27 00:00:00 : Algorithm starting warm up...
2024-06-02 17:04:00 : 2024-06-01 00:01:00 - EURUSD H4 Consolidated. EndTime: 2024-05-31 20:00:00
2024-06-02 17:05:00 : Algorithm finished warming up.
2024-06-02 21:03:00 : 2024-06-02 21:03:00 - EURUSD H4 Consolidated. EndTime: 2024-06-02 21:03:00
2024-06-03 01:03:00 : 2024-06-03 01:03:00 - EURUSD H4 Consolidated. EndTime: 2024-06-03 01:03:00
2024-06-03 05:03:00 : 2024-06-03 05:03:00 - EURUSD H4 Consolidated. EndTime: 2024-06-03 05:03:00
2024-06-03 09:03:00 : 2024-06-03 09:03:00 - EURUSD H4 Consolidated. EndTime: 2024-06-03 09:03:00
2024-06-03 13:03:00 : 2024-06-03 13:03:00 - EURUSD H4 Consolidated. EndTime: 2024-06-03 13:03:00
2024-06-03 17:04:00 : 2024-06-03 17:03:00 - EURUSD H4 Consolidated. EndTime: 2024-06-03 17:03:00
2024-06-03 21:03:00 : 2024-06-03 21:03:00 - EURUSD H4 Consolidated. EndTime: 2024-06-03 21:03:00
My question is: Why is the consolidated data coming through at 3 minutes past the desired time, and how can I make it consolidate appropriately, e.g., the EndTime of the consolidated bar is precisely on the 4H increment?
Many thanks in advance.
LE
You may not need to include the two lines “h4_consolidator” in your initial loop (place them before the loop). Just need the subscription manager to subscribe per ticker, not a separate time consolidator for each ticker. Consolidators arrive in order of creation, so maybe if it's creating more than one, that's the reason for the delay (one arrives per your base resolution, which is minute.) Not sure that this is the issue though.
Here is the code I use for for H4 OANDA consolidators dt, which was working last I checked. You could see if incorporating the logic like this helps. I only use a single ticker at a time, but I'm not sure if that changes anything.
Here's the daily version (17:00-17:00), note in both of these I had to add > “=” otherwise it would consolidate late.
Kayne Eccles
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!