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

Create lines in the Chart from a list.

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

    Create lines in the Chart from a list.

    Hello, I have a list, to which I add price levels and I need to print all these lines and that they are not erased every time a new line appears, that they continue continuously on the chart.
    The code that I have only creates the last added line and deletes the previous one.





    protected override void OnBarUpdate()
    {

    if(cont>=_max){
    levelChangeList.Add(LastPrice); // Add to a list the prices that meet a certain condition
    }

    if(levelChangeList.Count > 0){
    for (int i = 0; i < levelChangeList.Count ; i++)
    {
    Draw.HorizontalLine(this, "tag1", levelChangeList[i], Brushes.Black); // what I need is that each price is printed in a continuous line and not erased.
    // With this code the previous ones are deleted every time there is a new one.
    // I need all the lines to be pushed all the time.
    }
    }

    }

    #2
    Hello iradielt,
    You should make the tag dynamic to retain all drawing objects, example : replace "tag1" with "tag1" + CurrentBar.
    Hope it helps!

    Comment


      #3
      Originally posted by s.kinra View Post
      Hello iradielt,
      You should make the tag dynamic to retain all drawing objects, example : replace "tag1" with "tag1" + CurrentBar.
      Hope it helps!
      Thank you very much, before I had a problem similar to this and I solved it as you say, I will try. Do you think that with this it will continue to show all the previous lines?

      Comment


        #4
        Hello iradielt,
        This is the standard behavior for Drawing Objects, they tend to retain unique tag names so if there is static tag it will always overwrite the older object & if dynamic tag is used it doesn't affects the older object & creates a new one. Hope it helps!

        Comment


          #5
          Originally posted by s.kinra View Post
          Hello iradielt,
          This is the standard behavior for Drawing Objects, they tend to retain unique tag names so if there is static tag it will always overwrite the older object & if dynamic tag is used it doesn't affects the older object & creates a new one. Hope it helps!
          I already solved it, thanks

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by FishTrade, 05-13-2024, 11:11 PM
          3 responses
          11 views
          0 likes
          Last Post FishTrade  
          Started by Graci117, Yesterday, 09:02 PM
          1 response
          12 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by ETFVoyageur, Yesterday, 07:55 PM
          0 responses
          9 views
          0 likes
          Last Post ETFVoyageur  
          Started by janio973, Yesterday, 07:24 PM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by aligator, 01-06-2022, 12:14 PM
          4 responses
          250 views
          0 likes
          Last Post john_44573  
          Working...
          X