Login Page - Create Account

Support Board


Date/Time: Sun, 01 Jun 2025 16:49:08 +0000



Issue with sc.OpenChartOrGetChartReference() – Intraday Chart Timeframe Not Updating

View Count: 147

[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
[2025-05-06 05:27:41]
ticinotrader - Posts: 415
+1

Thank you for posting this. We're actively collaborating with @Moogroo and are really hoping for a solution—any fix or advice would be greatly appreciated.
Thank you in advance!
[2025-05-30 22:14:02]
Sierra_Chart Engineering - Posts: 19772
This will be resolved in the next release.
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

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account