Login Page - Create Account

Support Board


Date/Time: Sun, 22 Dec 2024 15:35:44 +0000



Post From: ACSIL Accessing Data from Multiple Charts - Do you have to use Autoloop = 0?

[2015-08-08 23:25:28]
Sierra Chart Engineering - Posts: 104368
Here is an updated code example:

SCSFExport scsf_OpenChartOrGetChartReferenceExample(SCStudyInterfaceRef sc)
{
  SCSubgraphRef Output = sc.Subgraph[0];
  
  if (sc.SetDefaults)
  {
    // Set the configuration and defaults
    
    sc.GraphName = "OpenChartOrGetChartReference Example";
    
    sc.StudyDescription = "This study demonstrates using the OpenChartOrGetChartReference function. This study does not calculate anything.";
    
    sc.AutoLoop = 0;//Manual looping
    
    // During development set this flag to 1, so the DLL can be modified. When development is done, set it to 0 to improve performance.
    sc.FreeDLL = 0;
    
    Output.Name = "Output";
    Output.DrawStyle = DRAWSTYLE_LINE;
    Output.PrimaryColor = RGB(0,255,0);
    
    return;
  }
  
  
  // Do data processing
  
  // Remember the chart number in a persistent variable to make the chart
  // lookup more efficient.
  int& ChartNumber = sc.GetPersistentInt(1);

  //Only do this on a full recalculation. Could also use sc.UpdateStartIndex == 0 in the case of manual looping which we are using.
  if ( sc.IsFullRecalculation)
  {

    s_ACSOpenChartParameters OpenChartParameters;
    OpenChartParameters.PriorChartNumber = ChartNumber;
    OpenChartParameters.ChartDataType = INTRADAY_DATA; //This can also be set to: DAILY_DATA
    OpenChartParameters.Symbol = sc.GetRealTimeSymbol();//When want to use the symbol of the chart the study function is on, use sc.GetRealTimeSymbol()
    OpenChartParameters.IntradayBarPeriodType = IBPT_DAYS_MINS_SECS;
    OpenChartParameters.IntradayBarPeriodLength = 30*SECONDS_PER_MINUTE; // 30 minutes
    OpenChartParameters.DaysToLoad = 0;//same as calling chart
    // These are optional
    OpenChartParameters.SessionStartTime.SetTimeHMS(12, 0, 0);
    OpenChartParameters.SessionEndTime.SetTimeHMS(23,59,59);
    //OpenChartParameters.EveningSessionStartTime.SetTimeHMS(0,0,0);
    //OpenChartParameters.EveningSessionEndTime.SetTimeHMS(23,59,59);

    ChartNumber = sc.OpenChartOrGetChartReference(OpenChartParameters);

  }

  if (ChartNumber != 0)
  {
    SCGraphData ReferenceChartData;
    
    // Get the arrays from the reference chart
    sc.GetChartBaseData(ChartNumber, ReferenceChartData);
    if (ReferenceChartData[SC_LAST].GetArraySize() == 0)
      return; // The array is empty
    
    // Copy the reference chart array Last values to Subgraph 0.
    // Most likely the array from the reference chart is not
    // the same size as the array this study function is applied to.
    // Therefore, there is not going to be a correct column to column
    // correspondence. However, this is just a simple example.
    Output[sc.Index] = ReferenceChartData[SC_LAST][sc.Index];
  }


  //This is an example of opening a Historical Chart with a Weekly bar period
  int& WeeklyChartNumber = sc.GetPersistentInt(2);

  if ( sc.IsFullRecalculation)
  {
    OpenChartParameters.Reset();
    OpenChartParameters.PriorChartNumber = WeeklyChartNumber;
    OpenChartParameters.ChartDataType = DAILY_DATA;
    OpenChartParameters.HistoricalChartBarPeriod = HISTORICAL_CHART_PERIOD_WEEKLY;
    OpenChartParameters.Symbol = sc.GetRealTimeSymbol();
    OpenChartParameters.DaysToLoad = 0;

    WeeklyChartNumber = sc.OpenChartOrGetChartReference(OpenChartParameters);
  }
}

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, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing