Login Page - Create Account

Support Board


Date/Time: Wed, 27 Nov 2024 23:25:41 +0000



Post From: GetStudyLineUntilFutureIntersection example

[2023-06-30 07:00:41]
User431178 - Posts: 544
GetStudyLineUntilFutureIntersectionByIndex assigns 4 parameters how to iterate properly through this? Is it simply from 0 to (number of total lines)?
Yes, you just interate the index parameter.

int GetStudyLineUntilFutureIntersectionByIndex(int ChartNumber, int StudyID, int Index, int& r_LineIDForBar, int& r_StartIndex, float& r_LineValue, int& r_ExtensionLineChartColumnEndIndex);


I've attempted several times and keep checking if lineEndIndex != 0 and exactly 0 lines show 'closed', when on the chart, they've clearly been closed (above/below), and visually the extension stops drawing.
Is your study using manual looping? If so, lineEndIndex is not going to be populated until the subsequent call into your study function.


Here is a working example that check for and deletes any intersected lines at the close of each bar.
To modify the line instead of deleting it you would just need to change DeleteLineUntilFutureIntersection for AddLineUntilFutureIntersection and re-add/edit the line using the parameter set by GetStudyLineUntilFutureIntersectionByIndex.


if (!sc.IsFullRecalculation
&& sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_CLOSED)
{
auto lineIndex{ 0 };
auto lineID{ 0 };
auto startIndex{ 0 };
auto endIndex{ 0 };
auto lineValue{ 0.0f };

while (sc.GetStudyLineUntilFutureIntersectionByIndex(sc.ChartNumber
, sc.StudyGraphInstanceID
, lineIndex
, lineID
, startIndex
, lineValue
, endIndex))
{
if (endIndex > 0)
sc.DeleteLineUntilFutureIntersection(startIndex, lineID);
else
lineIndex++;
}
}


GetStudyLineUntilFutureIntersection only assigns 1 : how is this function to be used in a loop, is the study expected to manage the lineID and indexes and prices for every line in order to use this function?

int GetStudyLineUntilFutureIntersection(int ChartNumber, int StudyID, int BarIndex, int LineIndex, int& LineIDForBar, float &LineValue, int &ExtensionLineChartColumnEndIndex));

GetStudyLineUntilFutureIntersection assigns 3 parameters, shown in bold above, and no you don't need to manage anything (although you can use the lineID for your purposes).
With this function you iterate the LineIndex parameter from 0 until the function returns 0 (i.e. until no more lines are found for that bar). This does mean that if you want to look at multiple bars you would also need an outer loop that iterates the BarIndex parameter.
Date Time Of Last Edit: 2023-07-01 09:08:53