Support Board
Date/Time: Wed, 19 Mar 2025 18:44:30 +0000
[Programming Help] - ACSIL: sc.AddLineUntilFutureIntersection() delete lines
View Count: 880
[2022-10-30 12:55:45] |
User213910 - Posts: 17 |
Hi, I am using the sc.AddLineUntilFutureIntersection() function to draw horizontal rays. Is there a way to delete the lines that have already been intersected, so that only the lines that have not yet been intersected remain? Thanks for help. |
[2022-10-30 17:05:14] |
User183724 - Posts: 194 |
this may work. sc.DeleteLineUntilFutureIntersection() I'm new to ACSIL so I have no idea. I read posts like yours and try to figure out an answer. Please let me know if this works for you and mayba post a section of code using this so I can get smarter. thx and good luck |
[2022-10-30 17:35:15] |
User213910 - Posts: 17 |
Yes I think so too "sc.DeleteLineUntilFutureIntersection()" is the key, but how do I identify the already intersected lines?
Date Time Of Last Edit: 2022-10-30 17:35:50
|
[2022-10-30 17:54:07] |
User183724 - Posts: 194 |
this is from the documentation The sc.DeleteLineUntilFutureIntersection function deletes a line added by the sc.AddLineUntilFutureIntersection function. Parameters StartBarIndex: This is the array index of the chart bar which was previously specified to the sc.AddLineUntilFutureIntersection() function, for the line to delete. LineIDForBar: This is the identifier of the extension line for the chart bar which was previously specified by the sc.AddLineUntilFutureIntersection() function, for the line to delete. when you set up the line orginally, you used the StartBarIndex and the LineIDForBar. I'm assuming this function would use those same index/id to delete the line that the sc.AddLineUntilFutureIntersection function used to draw it. remember, new guy here so the details are sketchy... i used to program in c++ back when dinosaurs walked the earth but am just now getting into acsil.. good luck |
[2022-10-30 18:30:21] |
User183724 - Posts: 194 |
you would need to compare the value of the line to the value of the intersect and if they match, delete the line. may want to put a small marker there for a couple bars just to show where the intersect was... delete it later... maybe not.
|
[2022-10-30 18:40:54] |
User431178 - Posts: 617 |
Take a look at the following items: ACSIL Interface Members - Functions: sc.GetStudyLineUntilFutureIntersectionByIndex() ACSIL Interface Members - Functions: sc.GetNumLinesUntilFutureIntersection() You can iterate through the lines checking to see if 'r_ExtensionLineChartColumnEndIndex' has a value set, which would indicate that it had beed intersected. If you can't get to a solution, post again and I will show an exmaple tomorrow. |
[2022-10-30 19:31:45] |
User183724 - Posts: 194 |
I would appreciate an example... thanks in advance
|
[2022-10-31 08:59:06] |
User431178 - Posts: 617 |
As requested, here is one possible method. Just add this code at an appropriate point in your study. // only perform check for intersected line on close of bar if (sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_CLOSED) { const int32_t numLines = sc.GetNumLinesUntilFutureIntersection(sc.ChartNumber, sc.StudyGraphInstanceID) - 1; if (numLines != 0) { for (int32_t lineIndex = numLines; lineIndex >= 0; --lineIndex) { int32_t lineID{ 0 }; int32_t startIndex{ 0 }; int32_t endIndex{ 0 }; float lineValue{ 0.0f }; if (sc.GetStudyLineUntilFutureIntersectionByIndex(sc.ChartNumber , sc.StudyGraphInstanceID , lineIndex , lineID , startIndex , lineValue , endIndex)) { if (endIndex > 0) sc.DeleteLineUntilFutureIntersection(startIndex, lineID); } } } } Note, if you are not using autoloop then the line below would need the index value added. if (sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_CLOSED)
Date Time Of Last Edit: 2022-10-31 09:01:17
|
[2022-10-31 12:40:05] |
User213910 - Posts: 17 |
Thank you for your work!!
|
[2022-10-31 16:05:08] |
User183724 - Posts: 194 |
thanks again for the example. I'm trying to learn ACSIL and having good examples really helps.
|
[2022-10-31 19:13:48] |
User213910 - Posts: 17 |
Code works well, but with a bit of performance problems. Because SierrChart first draws all lines and then goes through all again to delete the broken ones. Wouldn't there be a possibility to find out directly after creating ONE line if it is broken and then deletes it right away? |
[2022-10-31 19:44:45] |
User431178 - Posts: 617 |
No, not exactly, because at the point of creation you do not know that it is intersected, being as the bars are processed sequentially. If you query the line immediately after adding it, you will see that endIndex is not set. There are other ways to approach this, but you cannot get away from first creating and then destroying the lines. When you say performance problems, I would assume that this is during initial calculation? What you can do to improve this is only run the code to delete the lines once the initial calculation is complete. For example: if (!sc.IsFullRecalculation) { //// Delete lines in here } Date Time Of Last Edit: 2022-10-31 19:45:21
|
To post a message in this thread, you need to log in with your Sierra Chart account: