Support Board
Date/Time: Tue, 03 Jun 2025 07:22:55 +0000
Post From: Issue with sc.OpenChartOrGetChartReference() – Intraday Chart Timeframe Not Updating
[2025-05-05 18:32:41] |
Moogroo - Posts: 5 |
Hello everyone, I’m running into a strange issue when using sc.OpenChartOrGetChartReference() to open an external intraday chart from my study. Here’s a summary of what’s happening: 1. What I’m Trying to Do Use sc.OpenChartOrGetChartReference() to open (or reuse) an external chart at a user-selected intraday timeframe (e.g. 1m, 5m, 15m). Later, when the user changes the timeframe input on the study, I expect the external chart to update to the new period. 2. Code Snippet #include "sierrachart.h" SCDLLName("Open Intraday Chart Example"); SCSFExport scsf_OpenIntradayChartExample(SCStudyInterfaceRef sc) { SCInputRef TimeFrame = sc.Input[0]; if (sc.SetDefaults) { sc.GraphName = "Open Intraday Chart Example"; sc.GraphRegion = 1; sc.AutoLoop = 0; //Manual looping TimeFrame.Name = "TimeFrame in minutes"; TimeFrame.SetInt(30); return; } int& r_ChartNumber = sc.GetPersistentIntFast(0); if (sc.IsFullRecalculation) { s_ACSOpenChartParameters OpenChartParameters; OpenChartParameters.PriorChartNumber = r_ChartNumber; OpenChartParameters.ChartDataType = INTRADAY_DATA; OpenChartParameters.Symbol = sc.GetRealTimeSymbol(); OpenChartParameters.IntradayBarPeriodType = IBPT_DAYS_MINS_SECS; OpenChartParameters.IntradayBarPeriodLength = TimeFrame.GetInt() * SECONDS_PER_MINUTE; OpenChartParameters.DaysToLoad = 0; //same as calling chart OpenChartParameters.LoadWeekendData = 0; OpenChartParameters.UseEveningSession = 1; OpenChartParameters.HideNewChart = 0; OpenChartParameters.UpdatePriorChartNumberParametersToMatch = 1; r_ChartNumber = sc.OpenChartOrGetChartReference(OpenChartParameters); } } 3. The Issue - I add the study to a chart with the TimeFrame Input set to 30 minutes by default. External Chart opens with Time Frame of 30m as expected. - I Change Study Input TimeFrame to 5 minutes → chart briefly “reopens”, but the chart reverts and remains at 30m bars. - Repeat with other intraday values (1 m, 15 m, etc.) → external chart always falls back to the originally-opened period. - If I manually close it and reload, the new timeframe loads correctly. - Changing the Timeframe Input to a different timeframe causes the same issue, (reverts back to the original timeframe that was first opened). 4. Questions - Is this a known limitation or bug in OpenChartOrGetChartReference() for intraday periods? - Am I missing a required flag or parameter to force the bar period to update? - Does anyone have a reliable workaround? Any insights or suggestions would be greatly appreciated. Thanks in advance for your help! Moogroo Date Time Of Last Edit: 2025-05-05 18:39:49
|