Support Board
Date/Time: Thu, 22 Jan 2026 22:03:21 +0000
[Programming Help] - Custom chart bars - how can new bar be time-aligned
View Count: 37
| [2026-01-22 11:47:35] |
| curious16 - Posts: 28 |
|
I have a question regarding the use of your s_CustomChartBarInterface. After a new bar has been emitted, the custom bar generating function gets called with the flag IsFinalProcessingAfterNewOrCurrentBar set. In this call the custom bar generating function can modify past and current bars such as setting ChartBarInterface.GetChartBarValue(SC_LAST, ChartBarInterface.CurrentBarIndex - 1) = ChartBarInterface.GetChartBarValue(SC_HIGH, ChartBarInterface.CurrentBarIndex - 1); 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. 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. |
| [2026-01-22 12:04:33] |
| User431178 - Posts: 835 |
|
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?
|
| [2026-01-22 12:25:05] |
| curious16 - Posts: 28 |
|
Thanks for clarifying these points - I'll try this out.
|
To post a message in this thread, you need to log in with your Sierra Chart account:
