Support Board
Date/Time: Wed, 27 Nov 2024 07:34:00 +0000
[Programming Help] - How to code future intersection till cross over?
View Count: 326
[2023-09-19 04:12:38] |
rajeshh - Posts: 8 |
Hello, I am trying to code a variation of the the AddLineUntilFutureIntersection whereby the line drawn does not stop at any intersection, but at the intersection after a crossover ( up or down indicated by the parameter). So the idea of this to be in cases, where the line was originally support, but now is resistance, I want the line to continue till it reaches a bar that is crossing it from below. I am doing this in ACSIL. I wanted to get your general sense if the approach below makes sense - I am using autoloop. Essentially, in the subgraph which is drawing the lines, I also store a value in one if its internal arrays to indicate if it has crossed over already, so I can skip the checks in the future. So in each call of my study, I go backwards through the subgraph, check if its a non-zero value, check if not crossed over, and then call the sc.crossover(sc.High,new array with the constant value corresponding to that subgraph). If its None, then set set subgraph for the most recent bar to the value, and keep going on. If it has crossed over, then set subgraph value to zero, and the internal array value tracking crossover to true. Will this be OK from a performance point of view? I am hoping most of these crossover within 10-15 bars, so they dont need the cross over check past that? I have attached an image to make it clear. I see there is sc.AddLineUntilFutureIntersectionEx() which gives the ability for providing the end index. Is there any advantange to using this instead of the above? It looks like I would have to do most of the work above anyways to determine the ending index based on whether the cross over has happened or not? p.s - This would be a nice enhancement to the Ex() function above. Date Time Of Last Edit: 2023-09-19 04:17:01
|
crossover check.JPG / V - Attached On 2023-09-19 04:10:16 UTC - Size: 16.65 KB - 93 views |
[2023-09-20 01:43:05] |
rajeshh - Posts: 8 |
I ended up having to use sc.AddLineUntilFutureIntersectionEx() to accomplish this. I started by having endIndex be 0, with the idea to call it with endindex once the cross over had happened. It did take me most of the day to figure out though that I had to keep calling sc.AddLineUntilFutureIntersectionEx() on every update with endIndex=0 even if CrossOver hadnt happened. I figured I would have to only call the function after the initial call once CrossOver had happened to provide the endIndex. I went back and looked at the documentation. Is this expected when I am doing autoloop?
|
To post a message in this thread, you need to log in with your Sierra Chart account: