Support Board
Date/Time: Wed, 17 Dec 2025 19:56:09 +0000
[Programming Help] - Controlled Order Chart Updating interval question
View Count: 13
| [2025-12-17 15:10:49] |
| C_Money - Posts: 90 |
|
Referring to this link: General Settings Window: Use Controlled Order Chart Updating (Global Settings >> General Settings >> Charts >> Charts) "When using Controlled Order Chart Updating the minimum update interval is 250 milliseconds. The Chart Update Interval is controlled by the Global Chart Update Interval setting." The first part of the quote sounds like I cant change it from 250ms to a smaller number. The second part suggests I might be able to. I have my chart update interval set to 50ms and the chart still updates incredibly slowly with controlled order chart updating. (Use OS timer is on). I expected CPU usage to be higher but its actually much lower when controlled order is on. I am a scalper and I have my main low time frame chart which receives data from 4 higher time frame charts using custom studies. The main problem I've been dealing with is, even though I feel like I covered all my bases with keeping data properly synchronized, sometimes I'll hit Ctrl + Insert and I see buy / sell signals that weren't there before. Here is an example of some code to keep the data fresh between charts. // Safety: clear the most recent bars of all subgraphs to prevent stale data.
// Throttled to ~100ms and only runs on the last bar. Bars-to-clear is configurable. static int LTF_DataConsistency(SCStudyInterfaceRef sc, const bool logging_enabled) { // Only run data consistency checks on the most recent bar (last index) // This prevents unnecessary processing on historical bars during recalculation if (sc.Index != sc.ArraySize - 1) return -1; // Throttle execution to approximately 100ms intervals to prevent excessive clearing // Convert 100ms to days for SierraChart's date/time format (86400 seconds per day) const double now = sc.CurrentSystemDateTime.GetAsDouble(); double& last_run_time = sc.GetPersistentDouble(1000); const double one_hundred_ms = 0.1 / 86400.0; // 100 ms in days if (last_run_time != 0.0 && (now - last_run_time) < one_hundred_ms) return -1; last_run_time = now; // Safety check: ensure we have valid array data if (sc.ArraySize == 0) return -1; // Get configurable number of recent bars to clear (prevents stale cross-chart data) const int bars_to_clear_setting = sc.Input[1].GetInt(); const int bars_to_clear = (bars_to_clear_setting > 0) ? bars_to_clear_setting : 1; // Calculate the starting index for clearing (most recent N bars) const int current_index = sc.ArraySize - 1; const int target_start = current_index - (bars_to_clear - 1); int clear_start = (target_start >= 0) ? target_start : 0; if (clear_start < sc.DataStartIndex) clear_start = sc.DataStartIndex; if (clear_start >= sc.ArraySize) return -1; // Clear all 60 subgraphs from clear_start to end of array // This forces fresh recalculation of recent bars to ensure cross-chart data freshness const int total_subgraphs = 60; for (int sg = 0; sg < total_subgraphs; ++sg) { SCSubgraphRef subgraph = sc.Subgraph[sg]; for (int idx = clear_start; idx < sc.ArraySize; ++idx) { subgraph[idx] = 0.0f; } } // Force SierraChart to recalculate from clear_start index onward // This ensures the cleared bars get recalculated with fresh data if (sc.EarliestUpdateSubgraphDataArrayIndex == -1 || clear_start < sc.EarliestUpdateSubgraphDataArrayIndex) { sc.EarliestUpdateSubgraphDataArrayIndex = clear_start; } // Optional debug logging when enabled if (logging_enabled) { SCString message; message.Format("LTF_DataConsistency fired: cleared bars %d-%d (ArraySize=%d).", clear_start, sc.ArraySize - 1, sc.ArraySize); sc.AddMessageToLog(message, 0); } return clear_start; } And then on lower time frame charts I have this: inline int ForceRecentBarsRecalculation(SCStudyInterfaceRef sc, int bars_to_recalc)
{ if (sc.ArraySize == 0 || bars_to_recalc <= 0) return sc.DataStartIndex; int start = sc.ArraySize - bars_to_recalc; if (start < 0) start = 0; if (start < sc.DataStartIndex) start = sc.DataStartIndex; if (sc.EarliestUpdateSubgraphDataArrayIndex == -1 || start < sc.EarliestUpdateSubgraphDataArrayIndex) { sc.EarliestUpdateSubgraphDataArrayIndex = start; } return start; } I call that second function on bar close on my lower time frame charts. The reason I'm running the higher time frame recalculation code every 100ms is because my lowest time frame chart is 300 volume per bar on NQ, so you can imagine its volatile and fast. So I need data that travels downstream to be as fresh as possible. |
To post a message in this thread, you need to log in with your Sierra Chart account:
