Support Board
Date/Time: Tue, 10 Mar 2026 05:19:12 +0000
Post From: Custom chart bars - how can new bar be time-aligned
| [2026-01-22 12:04:33] |
| User431178 - Posts: 849 |
|
How can the starting time of the latest emitted bar be set? The function GetChartBarDateTime() is const, that is, read-only. Setting the starting time can make sense, for instance, to time-align with a fixed period grid. Example: the latest trade (first trade of new bar) is at 09:50:00.121 and the previous trade (last trade of prior bar) was at 09:49:58.712. It would be desirable to set the start of the new bar to 09:50:00 rather than to the timestamp of the first trade in the new bar. How can that be done? You do the same in your time-based bars but so far I haven't seen how this can be replicated with custom chart bars.
Cast away the const - https://en.cppreference.com/w/cpp/language/const_cast.html - as it mentioned in the docs. It would also be helpful to have access to the timestamp of the last trade of the previous bar. You have the array sc.BaseDataEndDateTime[], but it seems this is not accessible as part of s_CustomChartBarInterface.
You have the ability to store timestamps using GetPersistentSCDateTime, maybe that is enough?
|
