Login Page - Create Account

Support Board


Date/Time: Mon, 10 Mar 2025 02:34:52 +0000



[Programming Help] - Reading the Intraday chart data file records from the chart data file

View Count: 949

[2022-03-13 22:26:38]
User891636 - Posts: 5
Hi,
I developed a study where I'm reading the Intraday chart data file using the function:

sc.ReadIntradayFileRecordForBarIndexAndSubIndex()

I successfully made everything working and I'm able to get all the data I need, 2 or 3 days of information. As the documentation says, when I have a chart having settings that produce many bars (like Range per bar and a bar by tick) Sierra freezes for a long time. What I don't get here is why if I choose a greater number how many ticks by bar, the same study is loaded after few seconds, the only difference is the number of bar present in the graph needed to be processed, but at the end the number of Intraday records I get is exactly the same, there's no data aggregation the records are by trade. Also the function

sc.ReadIntradayFileRecordAtIndex()


doesn't make better.
It is related to the lock management? Is there any smart way to get the data via scid without depending on chart settings?
Thank you in advance for the support.
Regards.
[2022-03-13 23:33:37]
1+1=10 - Posts: 270
If you’re using “sc.Autoloop = 1” then by default the study will be called for every single chart bar.

If so, you need to add an if statement such as “if(sc.Index == 0)” or perhaps “if(sc.Index == sc.ArraySize - 1)” depending on whether you only need to read the intraday file records when the study is placed on the chart or if you need to read the record every time new market data comes in.

If you’re unsure what I mean please consider pasting your code as it will be easier for the forum members to help you troubleshoot.
[2022-03-14 06:18:30]
User891636 - Posts: 5
Hi,
Thank you for your answer. Indeed I had to explain better my strategy.
I'm using “sc.Autoloop = 0” and no actions taken when sc.UpdateIndex==0 (first function call) then, at the others call I have two approaches: the first time where the function reads the historical data, calling sc.ReadIntradayFileRecordForBarIndexAndSubIndex(), from the last bar index (sc.ArraySize-1) to 0 but it stops when the amount of data requested is reached; and then the "normal call" to get the updates where is used sc.UpdateIndex.
I have issues only during the historical data loading and only if the chart has many bars. As I said, I realized that at the end the number of intraday records got after the first load is the same and it does not depends on chart settings. I can post part of the code later during the day.
Thank you.
[2022-03-14 13:50:32]
1+1=10 - Posts: 270
Did you see SC's example in /ACS_Source/Studies2.cpp? Did you use sc.ReadIntradayFileRecordAtIndex() the way they did in the example? I'm posting it below. Note that they are looping over the IntradayRecords themselves and not adding the additional processing required to determine which IntradayRecords apply to each BarIndex:


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

    sc.GraphName = "Read from Underlying Intraday File Example";


    sc.AutoLoop = 0;

    return;
  }

  if (sc.LastCallToFunction)
    return;

  s_IntradayRecord IntradayRecord;

  for (int FileIndex = sc.FileRecordIndexOfLastDataRecordInChart; FileIndex >= sc.FileRecordIndexOfLastDataRecordInChart - 10; FileIndex--)
  {
    bool FirstIteration = FileIndex == sc.FileRecordIndexOfLastDataRecordInChart;
    bool LastIteration = FileIndex <= sc.FileRecordIndexOfLastDataRecordInChart - 10;
    IntradayFileLockActionEnum IntradayFileLockAction = IFLA_NO_CHANGE;

    if (FirstIteration && LastIteration)
      IntradayFileLockAction = IFLA_LOCK_READ_RELEASE;
    else if (FirstIteration)
      IntradayFileLockAction = IFLA_LOCK_READ_HOLD;
    else if (LastIteration)
      IntradayFileLockAction = IFLA_RELEASE_AFTER_READ;

    sc.ReadIntradayFileRecordAtIndex(FileIndex, IntradayRecord, IntradayFileLockAction);

    SCDateTimeMS TradeTimestampInChartTimeZone = IntradayRecord.DateTime;

  }

  // Could also use this line of code to release the lock if not sure when will be complete
//with reading and want to do it as a separate operation. An index of -1 signifies not actually to
// perform a read.
  
///sc.ReadIntradayFileRecordAtIndex( -1, IntradayRecord, IFLA_RELEASE_AFTER_READ);
    

}



Date Time Of Last Edit: 2022-03-14 13:52:20
[2022-03-14 22:17:33]
User891636 - Posts: 5
Hi,
yes I started from the examples. Here's is my code:


as I said I'm using the function sc.ReadIntradayFileRecordForBarIndexAndSubIndex() but also with a quick test of sc.ReadIntradayFileRecordAtIndex() I got issue at the first loading, so I'm wondering if I'm missing something...
Date Time Of Last Edit: 2022-03-24 10:59:52
[2022-03-14 22:48:10]
1+1=10 - Posts: 270
You're a good programmer. A quick read didn't turn up anything obvious, but it would take me hours to really unpack each line. (Sadly, I've never tried to read intraday file records so the lack of familiarity doesn't help.) Anyway, hopefully a community member or SC Engineering will have a helpful thought. Good luck!

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

Login

Login Page - Create Account