• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Retrieve Data from Screen (or Drawing Objects box)

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

    Retrieve Data from Screen (or Drawing Objects box)

    Hello,

    I am coding a strategy based on zones that trader enters manually on the chart using a drawing object (rectangles, in this case).

    I need to retrieve the values from these rectangles (start Y and End Y, for example, see screenshot attached) to use in the strategy code.

    Any ideas?

    Thank you

    #2
    Hello federicoo,

    Thanks for your post.

    You can loop through the Drawing objects collection on the chart and identify if manually drawn.

    Please see the help guide here with examples; https://ninjatrader.com/support/help...rawobjects.htm

    Here are the properties; https://ninjatrader.com/support/help...rawingtool.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks for your response.

      I can detect the drawing objects as in the examples you sent me, but I need to retrieve the values from these rectangles (start Y and End Y). I could not get these values.

      Have you some examples or ideas to do this?

      Thank you

      Comment


        #4
        Hello federicoo,

        Thanks for your reply.

        Here is an example:

        Code:
        if (DrawObjects.Count > 0)
                    {
                        foreach (DrawingTool draw in DrawObjects.ToList())
                          {    
                            if (draw is DrawingTools.Rectangle )
                            {
                                Print ("Tag name: "+draw.Tag);
                                DrawingTools.Rectangle temp = draw as DrawingTools.Rectangle;
        
                                Print("startYPrice: " + temp.StartAnchor.Price); 
                                Print("startXTime: " + temp.StartAnchor.Time);
                                Print("endYPrice: " + temp.EndAnchor.Price);
                                Print("endXTime: " + temp.EndAnchor.Time);
                            }
                        }
                    }
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Thank you so much Paul,

          This code works great to retrieve data from manually drawed rectangles.

          Now, what If I would want to retrieve data from rectangles drawed by scripts?

          I'm loosing these script-drawed rectangles.

          Thank in advance

          Comment


            #6
            Hello federicoo,

            Thanks for your reply.

            While I could not speak for 3rd party purchased indicators drawing, the code would be able to pull rectangle data from script or manually drawn rectangles. In the attached screenshot, I have run an indicator called "Repeater" which draws a rectangle at the same time every day colored Yellow. I manually drew a blue rectangle. Another indicator that draws one red outline rectangle and also has the code shown above in Post#4 reads all of the rectangles (Manually, drawn by other indicators and drawn by its own indicator). In the output window I drew like colored rectangles to show the data from those same colored rectangles. NOTE: I did change the above code to add the Drawn BY: Here is the code: Print ("Tag name: "+draw.Tag+" Drawn by: "+draw.DrawnBy);

            Click image for larger version

Name:	fredericoo.PNG
Views:	30
Size:	100.1 KB
ID:	1085932
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Thank you Paul,

              Is any way to retrieve the color of the rectangles? Could I see some example?

              Thanks in advance,
              Fede

              Comment


                #8
                Hello federicoo,

                Thanks for your reply.

                Continuing the example from post #4

                Code:
                                        Print ("Area Brush: "+temp.AreaBrush);
                                        Print ("OutLine Stroke: "+temp.OutlineStroke.Brush);
                                        Print ("Area Opacity: "+  temp.AreaOpacity);
                Paul H.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by ralett, Yesterday, 07:29 PM
                1 response
                7 views
                0 likes
                Last Post NinjaTrader_Marco  
                Started by bboyle1234, Yesterday, 10:46 PM
                1 response
                7 views
                0 likes
                Last Post bltdavid  
                Started by swcooke, Yesterday, 04:29 PM
                0 responses
                5 views
                0 likes
                Last Post swcooke
                by swcooke
                 
                Started by bboyle1234, Yesterday, 04:27 PM
                0 responses
                2 views
                0 likes
                Last Post bboyle1234  
                Started by swcooke, Yesterday, 03:31 PM
                2 responses
                12 views
                0 likes
                Last Post swcooke
                by swcooke
                 
                Working...
                X