Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 Zinger357, 07-01-2024, 06:24 PM
      12 responses
      94 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by SteenLeold, Today, 06:25 AM
      0 responses
      1 view
      0 likes
      Last Post SteenLeold  
      Started by CMENDOZA878, Yesterday, 04:21 PM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by algospoke, 05-13-2024, 06:53 PM
      15 responses
      154 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by llanqui, Yesterday, 05:56 AM
      3 responses
      15 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Working...
      X