Support Board
Date/Time: Wed, 04 Mar 2026 19:57:10 +0000
Historical market depth for chart with custom bars
View Count: 499
| [2026-01-17 08:58:38] |
| curious16 - Posts: 36 |
|
I found that historical market depth does not take into account custom bars. For a chart constructed with (sc.IsCustomChart = 1), the call to sc.GetMarketDepthBars() links to the underlying bars (base chart bars) that were used to build the custom output bars, not to the custom bars themselves. This results in incorrect mapping between custom bar index and depth data. I found the same problem also with your built-in Market Depth Historical Graph study. It works fine on a base chart but shows incorrect data when a study that generates custom bars is loaded. It appears that the GetMarketDepthBars() call is hard-linked to the underlying base bars of the chart. A custom study can aggregate base bars in some customized way (e.g. a study uses underlying 10-trade bars and aggregates them to bars representing a different total number of trades depending on the time of the day). Such custom charts have fewer output bars than underlying base bars. The expected behaviour would be for GetMarketDepthBars() to sync with the custom bars. Could this be changed or can this already be done in code? It would be very valuable to get market depth data also for custom charts. |
| [2026-01-17 09:46:42] |
| Sierra_Chart Engineering - Posts: 23138 |
|
There is definitely not going to be any changes regarding this, because (sc.IsCustomChart = 1) is considered out of date. You need to use this replacement functionality: ACSIL Interface - Custom Chart Bars Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, use the Teton service: Sierra Chart Teton Futures Order Routing Date Time Of Last Edit: 2026-01-17 10:13:54
|
| [2026-01-17 12:49:43] |
| curious16 - Posts: 36 |
|
Thanks for your quick response. The method described in the link you provided seems a lot more complex/convoluted than what I used so far with sc.IsCustomChart = 1 and using sc.AddElements(1) to emit new output bars. By all means please keep supporting what you describe here as "out of date" - I have a considerable amount of code that uses this approach, and I'd expect others do as well since this works fine for basic functionality but, as I now found, does not work with book depth data. I'll try to understand the newer method and gradually rewrite custom chart code with this alternate approach. Can you confirm that this approach is fully compatible with loading historical market depth data? Apart from being able to load historical market depth into a custom chart, what advantages does this approach have compared to what I use now and what you describe as "out of date"? |
| [2026-01-20 07:00:42] |
| Sierra_Chart Engineering - Posts: 23138 |
|
Yes: Can you confirm that this approach is fully compatible with loading historical market depth data?
This is a very efficient method to create chart bars: The building of chart bars occurs on another thread. Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, use the Teton service: Sierra Chart Teton Futures Order Routing |
| [2026-01-21 12:38:40] |
| curious16 - Posts: 36 |
|
I started looking into this method using your sample code. One question came up regarding the use of persistent variables that are set in the calling study function by the custom chart bar function. The custom chart bar function gets a reference to a s_CustomChartBarInterface struct. This has methods for loading persistent scalar variables (Int, Float etc), but there is no method for getting a persistent pointer, that is, passing a pointer to a vector of values. Could this be added or is there a fundamental limitation that makes it impossible to pass, e.g., a pointer to a std::vector<int> to the custom chart bar function? Another question I have is about selectively setting the color of selected custom bars. Can this be done by adding a manual loop, for (int i=sc.UpdateStartIndex; i<sc.ArraySize; i++), to the calling study function and do the coloring there? Your examples do not do any manual looping in the calling study function. They only manage the input parameters and let the custom chart bar function know when an input has changed and the entire chart needs to be redrawn. |
| [2026-01-22 16:43:42] |
| Sierra_Chart Engineering - Posts: 23138 |
|
We can add support for this: but there is no method for getting a persistent pointer, that is, passing a pointer to a vector of values.
You can try to do this. We just do not know if it is going to work properly: Another question I have is about selectively setting the color of selected custom bars. Can this be done by adding a manual loop,
for (int i=sc.UpdateStartIndex; i<sc.ArraySize; i++), to the calling study function and do the coloring there? Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, use the Teton service: Sierra Chart Teton Futures Order Routing Date Time Of Last Edit: 2026-01-22 16:44:23
|
| [2026-01-22 17:04:33] |
| curious16 - Posts: 36 |
|
I found that it is possible to define and update subgraphs in the calling study (the study that sets sc.UsesCustomChartBarFunction = 1). This is quite convenient as we can define custom bars and calculate some analytics on these bars in the same function. What I find a bit problematic is the limited functionality to exchange data between the calling study and the custom chart bar function. As said before, we have only scalar persistent variables for this purpose. I found a partial workaround by using the two Renko price traces (SC_RENKO_OPEN, SC_RENKO_CLOSE) for sending data back from the chart bar function back to the calling study. This can be done unless the custom chart is a Renko and needs these data traces. It works but having the option to pass vectors via persistent pointers would be nicer and more flexible. Overall I am quite positive about using this custom bar mechanism. It is still early days but what I tested so far runs well. However, it appears that this part of ACSIL is less commonly used as there are only very few posts on the support board explaining how to work with custom bars. This means it takes a bit of experimentation to fully understand the method. |
| [2026-01-22 22:18:44] |
| curious16 - Posts: 36 |
|
Regarding the coloring of custom bars, I believe this would be possible by using a sc.Subgraph of the custom bar study and setting its DrawStyle accordingly (e.g. to DRAWSTYLE_COLOR_BAR_CANDLE_FILL). The problem I encountered is that the custom bar study is always hidden and this cannot be changed. I understand that this normally makes good sense because the custom bar study provides no sc.Subgraphs but only a custom version of sc.BaseData. However, if a custom bar study does provide sc.Subgraphs, it would be helpful to get the option to unhide these. Is there a fundamental limitation that makes it impossible to unhide custom bar studies, or could that be added as an option? |
To post a message in this thread, you need to log in with your Sierra Chart account:
