Login Page - Create Account

Support Board


Date/Time: Sat, 15 Mar 2025 22:53:20 +0000



[Programming Help] - GetNumLinesUntilFutureIntersection() reports increasing numbers on recalculate

View Count: 462

[2022-08-02 23:29:18]
QnReally - Posts: 188
I have a chart with SC's scsf_ExtendBarGapUntilFutureIntersection() study added on an NQ chart. I then have a custom study which does the following where studyID is the SC's study ID.
int numLines = sc.GetNumLinesUntilFutureIntersection(sc.ChartNumber, studyID);

Each time I recalculate my chart, the numLines I get back is adding more lines (adding exactly the number of lines I got the first time). So, over time the number of lines I get keeps on increasing.

I am thinking there must be a mistake I am making but I can't figure it out yet. I just wanted to double-check to make sure there was no bug in how the future intersection code works on your end.

This is my simplified code:
SCSFExport scsf_ExtractNakedLines(SCStudyInterfaceRef sc)
{
  SCInputRef NakedGapsStudy = sc.Input[0];
  if (sc.SetDefaults)
  {
    sc.GraphName = "ExtractNakedLines";
    sc.AutoLoop = 0;
    sc.GraphRegion = 0;
    sc.GlobalDisplayStudySubgraphsNameAndValue = 0;
    sc.DisplayStudyInputValues = 0;
    sc.DisplayStudyName = 0;
    sc.DrawZeros = 0;
    sc.FreeDLL = gFreeDLL;
    NakedGapsStudy.Name = "Naked Gaps Study";
    NakedGapsStudy.SetDescription("Chart/Study/Subgraph for the Naked Gaps (gaps above / below previous day's range) study");
    NakedGapsStudy.SetStudyID(0);
  }
  if (NakedGapsStudy.GetStudyID() != 0) {
    SCString Buffer;
    unsigned studyID = NakedGapsStudy.GetStudyID();
    int numLines = sc.GetNumLinesUntilFutureIntersection(sc.ChartNumber, studyID);
    Buffer.Format("------------ numLines = %d", numLines); sc.AddMessageToLog(Buffer, 0);
    for (int i = 0; i < numLines; i++) {
      Buffer.Format("i = %d", i); sc.AddMessageToLog(Buffer, 0);
      int r_LineIDForBar = 0, r_StartIndex = 0, r_EndIndex = 0; float r_LineValue = 0.0f;
      sc.GetStudyLineUntilFutureIntersectionByIndex(sc.ChartNumber, studyID, i, r_LineIDForBar, r_StartIndex, r_LineValue, r_EndIndex);
      Buffer.Format("Gaps -- %.2f %d -> %d", r_LineValue, r_StartIndex, r_EndIndex); sc.AddMessageToLog(Buffer, 0);
    }
  }
}

This is the output I get on the first try followed by upon recalculate:
Chart: NQU2.CME [CBV] 405 Min #1 | Study: ExtractNakedLines | ------------ numLines = 4 | 2022-08-02 19:21:18.714
Chart: NQU2.CME [CBV] 405 Min #1 | Study: ExtractNakedLines | i = 0 | 2022-08-02 19:21:18.714
Chart: NQU2.CME [CBV] 405 Min #1 | Study: ExtractNakedLines | Gaps -- 11371.25 1 -> 3 | 2022-08-02 19:21:18.714
Chart: NQU2.CME [CBV] 405 Min #1 | Study: ExtractNakedLines | i = 1 | 2022-08-02 19:21:18.714
... ...
NQU2.CME [CBV] 405 Min #1 | Reloading chart. | 2022-08-02 19:21:24.062
NQU2.CME [CBV] 405 Min #1 | StartDateTimeForLoadingOrderFills: 00:00:00 | 2022-08-02 19:21:25.919
Chart: NQU2.CME [CBV] 405 Min #1 | Study: ExtractNakedLines | ------------ numLines = 8 | 2022-08-02 19:21:25.919
Chart: NQU2.CME [CBV] 405 Min #1 | Study: ExtractNakedLines | i = 0 | 2022-08-02 19:21:25.919
Chart: NQU2.CME [CBV] 405 Min #1 | Study: ExtractNakedLines | Gaps -- 11371.25 1 -> 3 | 2022-08-02 19:21:25.919
Chart: NQU2.CME [CBV] 405 Min #1 | Study: ExtractNakedLines | i = 1 | 2022-08-02 19:21:25.919
... ...
[2022-08-02 23:30:38]
QnReally - Posts: 188
https://www.sierrachart.com/image.php?Image=1659483021312.png
Date Time Of Last Edit: 2022-08-02 23:32:11
attachmentTSTest.Cht - Attached On 2022-08-02 23:31:51 UTC - Size: 3.94 KB - 210 views
[2022-08-04 16:58:35]
Sierra_Chart Engineering - Posts: 18793
We found the problem and resolved it. There are not more lines but there was a reference array that was not getting cleared.
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