Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to get the Variables from a list of Rectangles

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

    How to get the Variables from a list of Rectangles


    I have drawn several Rectangles in a strategy that I use as Support and Resistance, but I need to update them

    I would like to get all the data of the rectangle for reading, basically startY, endY, StartTime

    I have tried to obtain the data of the list without any result



    foreach (DrawingTool draw in DrawObjects.ToList()){

    if (draw is DrawingTools.Rectangle && myZona !=null) {

    Print("List de Rectangle " + myZona.Anchors.ToList());

    }
    }

    #2
    Hello HGTrader,

    A code sample exists in the help guide.
    https://ninjatrader.com/support/help...rawobjects.htm

    May I confirm myZona is not null?

    if (myZona !=null)
    Print("myZona is not null");

    What is the DrawObjects.Count?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3

      I would like to get all the data of the rectangle for reading, basically startY, endY, StartTime

      I can see the information of these Variables, but when I print them only the last rectangle information comes out, but I need the information of each object in the list individually

      Print("Rectangle Object: " + draw.Tag + " Star Anchor " + myZona.StartAnchor);
      Print("Rectangle Object: " + draw.Tag + " End Anchor " + myZona.EndAnchor);
      Print("Rectangle Object: " + draw.Tag + " End Anchor " + myZona.StartAnchor.Time);


      Comment


        #4
        Hello HGTrader,

        I am not able to reproduce this behavior using the sample code from the help guide.

        Below is a link to a video of the test.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5

          Thank you very much I will try this to see if it works for me

          Comment


            #6
            Hello, what they sent me was very helpful, but when I run the strategy, it performs the search during all the past days, please can you help me to know how I can initialize so that the search begins at the time I have established.

            I need to initialize on every first Bar of the Session

            Comment


              #7
              Hello HGTrader,

              You can reset a variable when Bars.IsFirstBarOfSession (and optionally IsFirstTickOfBar) is true.

              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Hello, I understand that part perfectly, but how do I reset a Drawing list?

                drawing ??? .Clear()?

                Comment


                  #9
                  Hello HGTrader,

                  Are you trying to remove a drawing object from the chart?

                  That would be done with RemoveDrawObject().


                  Do you have a List<Rectangle> and you are want to reset the list? myList.Clear() would work.
                  Chelsea B.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  566 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  330 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