Login Page - Create Account

Support Board


Date/Time: Mon, 21 Apr 2025 23:30:21 +0000



sc.ReadIntradayFileRecordForBarIndexAndSubIndex appears to not work for Volume based bars

View Count: 185

[2025-02-13 10:20:27]
brianmonagha - Posts: 5
I have attempted to call sc.ReadIntradayFileRecordForBarIndexAndSubIndex referencing volume based bars using the example code from scsf_ReadChartBarRecordsFromUnderlyingIntradayFileExample in Studies2.cpp.

The first call is successful and reports total volume of 1, however once SubIndex is incremented to 1, sc.ReadIntradayFileRecordForBarIndexAndSubIndex returns false then. Is it correct that this function does not work with volume bars? I suspect this might be a limitation not mentioned in the documentation because the same code works fine for other types of bars, including tick based bars.

Is there a way that sc.ReadIntradayFileRecordForBarIndexAndSubIndex can work with volume based bars, or is this a known limitation?

Thanks
[2025-02-14 22:59:46]
Sierra_Chart Engineering - Posts: 19290
Should not be a problem. But we will not get to this for a long time before we will look at it.
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
[2025-02-15 14:02:03]
User431178 - Posts: 654
Is there a way that sc.ReadIntradayFileRecordForBarIndexAndSubIndex can work with volume based bars, or is this a known limitation?

Both the example code/study and custom studies using this functionality work fine for me on volume bars.
[2025-02-16 07:01:06]
Sierra_Chart Engineering - Posts: 19290
We are confirming there is no issue with Volume bars with that function. Here is an updated example of the function that is easier to follow.

Also disable this Chart Setting:
Chart Settings: Split Data Records (applies to Number of Trades, Volume and Range charts) (Chart >> Chart Settings >> Chart Data >> Chart Data menu)


SCSFExport scsf_ReadChartBarRecordsFromUnderlyingIntradayFileExample(SCStudyInterfaceRef sc)
{
  SCSubgraphRef SubGraph_Volume = sc.Subgraph[0];

  if (sc.SetDefaults)
  {
    // Set the configuration and defaults

    sc.GraphName = "Read Chart Bar Records from Underlying Intraday File Example";
    
    sc.AutoLoop = 0;

    // This must be set to 1 in order to use the sc.ReadIntradayFileRecordForBarIndexAndSubIndex function.
    sc.MaintainAdditionalChartDataArrays = 1;

    SubGraph_Volume.Name = "File Volume";
    SubGraph_Volume.DrawStyle = DRAWSTYLE_BAR;
    SubGraph_Volume.LineWidth = 2;
    SubGraph_Volume.PrimaryColor = RGB(255, 0, 128);
    SubGraph_Volume.DrawZeros = false;

    return;
  }

  if (sc.LastCallToFunction)
    return;

  s_IntradayRecord IntradayRecord;

  for (int BarIndex = sc.ArraySize - 10; BarIndex < sc.ArraySize; BarIndex++)
  {
    int ReadSuccess = true;
    bool FirstIteration = true;
    uint32_t TotalVolume = 0;
    int SubIndex = 0;//Start at first record within bar

    //Read records until sc.ReadIntradayFileRecordForBarIndexAndSubIndex returns 0
    while (ReadSuccess)
    {
      IntradayFileLockActionEnum IntradayFileLockAction = IFLA_NO_CHANGE;

      if (FirstIteration)
      {
        IntradayFileLockAction = IFLA_LOCK_READ_HOLD;

        FirstIteration = false;
      }

      ReadSuccess = sc.ReadIntradayFileRecordForBarIndexAndSubIndex(BarIndex, SubIndex, IntradayRecord, IntradayFileLockAction);

      if (ReadSuccess)
      {
        TotalVolume += IntradayRecord.TotalVolume;
        ++SubIndex;
      }
    }

    sc.ReadIntradayFileRecordForBarIndexAndSubIndex(-1, -1, IntradayRecord, IFLA_RELEASE_AFTER_READ);

    SubGraph_Volume.Data[BarIndex] = TotalVolume;
  }
  
}

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
[2025-02-17 11:51:50]
brianmonagha - Posts: 5
I have tried again using the new example and the setting you described, and it is successful now.

Thank you

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

Login

Login Page - Create Account