Support Board
Date/Time: Sun, 16 Mar 2025 02:05:06 +0000
Post From: GetNumLinesUntilFutureIntersection() reports increasing numbers on recalculate
[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 ... ... |