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.
      Paul H.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by XXfea, Yesterday, 07:01 PM
      2 responses
      17 views
      0 likes
      Last Post XXfea
      by XXfea
       
      Started by mrgreentrading, 04-11-2025, 08:41 PM
      10 responses
      94 views
      0 likes
      Last Post NinjaTrader_Eduardo  
      Started by ulisesguerrero, Today, 08:17 AM
      0 responses
      12 views
      0 likes
      Last Post ulisesguerrero  
      Started by raysinred, Yesterday, 10:32 AM
      2 responses
      26 views
      0 likes
      Last Post raysinred  
      Started by momchi, 04-26-2025, 10:22 AM
      1 response
      15 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Working...
      X