Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to draw multiple lines on chart without overriding the previous

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

    How to draw multiple lines on chart without overriding the previous

    Hello,
    I have a rather stupid question, for which I apologize in advance.

    I have an automated strategy that I draw pivot lines onto the RSI indicator.

    I use the following code:

    RSI(14, 3).DrawLine("LowPivot", (CurrentBar - BarOfFirstLow), RSIFirstLow, 0, RSIThirdLow, Color.Green);


    The problem is when I load the strategy and look at the chart, I only see the most recently drawn line, since (I assume) it overrides all the previous ones.

    Any help will be much appreciated.

    Thanks.

    #2
    You need to use a unique tag name for each time the Line is drawn so that it doesn't override the previous.

    Try this -
    Code:
    DrawLine("LowPivot"[B] + CurrentBar[/B], (CurrentBar - BarOfFirstLow), RSIFirstLow, 0, RSIThirdLow, Color.Green);

    Comment


      #3
      Hello nikolaalx,

      Thanks for your post and we do appreciate all questions as you will not be the only one asking!

      Member Calonious is bang on correct.

      When any drawn object is placed on the chart, if a new object is drawn using the same exact name the original object is first removed then the new object created. This can be handy when you are only interested in the latest occurrence, such as moving a line.

      If however you want to keep all historical objects then assigning a unique name by adding +CurrentBar will allow that to happen.

      Also, you can keep a limited history of items by using a counter and then resetting the counter. As the counter is advanced the older item with the same name is erased while the new one is drawn.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      563 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      329 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      547 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      548 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X