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 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 bortz, 11-06-2023, 08:04 AM
                  47 responses
                  1,606 views
                  0 likes
                  Last Post aligator  
                  Started by jaybedreamin, Today, 05:56 PM
                  0 responses
                  9 views
                  0 likes
                  Last Post jaybedreamin  
                  Started by DJ888, 04-16-2024, 06:09 PM
                  6 responses
                  19 views
                  0 likes
                  Last Post DJ888
                  by DJ888
                   
                  Started by Jon17, Today, 04:33 PM
                  0 responses
                  6 views
                  0 likes
                  Last Post Jon17
                  by Jon17
                   
                  Started by Javierw.ok, Today, 04:12 PM
                  0 responses
                  15 views
                  0 likes
                  Last Post Javierw.ok  
                  Working...
                  X