Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to merge the lines drawn on the same index?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to merge the lines drawn on the same index?

    Hi everyone.

    I want to remove some lines drawn on the chart by my script conditionally but I'm having trouble sequencing them.
    I suppose that to have all the lines 'tags' arranged in sequence one after the other, it is enough to use the same 'tag' start plus 'CurrentBar' regardless of the 'Draw.Line' method being in different conditions.
    In my script, I try to unify the 'tags' in the same index with ' "lA"+(CurrentBar) ' as stated above. However, as I do so, some lines disappear, this is not the result I want.
    It is the case that the 'Draw.Line' methods are in separate conditions. Is that the problem?
    I need to merge the lines in the same index because I will conditionally remove the previous line in function of the current one.
    When I do this with separate tags (' "lA"+(CurrentBar) ' and ' "lB"+(CurrentBar) ') everything works fine but there are still some lines to be removed and the reason is that the tags are not unified in the same index.

    Is there any way to merge the lines in an index with different tags but in the correct order, and still remove them with the 'RemoveDrawObject' method?
    Last edited by rafaelcoisa; 11-01-2022, 09:08 AM.

    #2
    I did a similar thing in a script. The script simply tracks the daily High/Lows... and marks when those lines were broken. I have it set up two ways, one where it totally removes the line upon a cross, and another when it simply stops the line at the moment it is touched. You can see an image of this attached below.

    It seems you simply want to remove the line. If you want to DL the indie, you can find it HERE. Also attaching the .cs file below(for some reason they dont show up right away when I attach .cs files).

    But, just a general explanation...

    I create a List Structure(not sure what they are called?), but they are essentially multi-dimensional Lists, similar to the one dimensional list you have. You could also do multiple lists that are all the same length(but I typically will create a multi-dimensional list).

    My script will only have one line per bar, so my sequence is based on the bar number. The string identifier I am using for a line is basically 'BarNo+PriorHigh' or 'BarNo+PriorLow'.

    I iterate through the list with a loop, and check if a crossing has occurred... if so, I remove that item from the list, while at the same time, removing that line using "RemoveDrawObject(myIdent+"priorHigh")"... Since that item is removed... the next iteration, it will just be like that item is gone.

    I dunno if this is helpful... but it may be somewhat similar to what you are trying to accomplish? Click image for larger version  Name:	local_resize.gif Views:	0 Size:	131.7 KB ID:	1174317

    Last edited by forrestang; 10-09-2021, 11:00 AM.

    Comment


      #3
      Thanks for sharing your script, man.
      I'm currently transitioning from Tradingview to Ninjatrader and I have a tradingview script that do precise the same thing then yours.
      So, that going to help in a way or in other.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      633 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      364 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      105 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      567 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      568 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X