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:	177
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 NeverDownMoney, Today, 02:42 PM
                3 responses
                11 views
                0 likes
                Last Post NinjaTrader_ChrisL  
                Started by localappleseed, Today, 02:20 PM
                1 response
                13 views
                0 likes
                Last Post NinjaTrader_Jim  
                Started by asmmbillah, Today, 02:48 PM
                1 response
                19 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Started by KacemRhaz, Today, 01:31 PM
                3 responses
                15 views
                0 likes
                Last Post NinjaTrader_ChristopherD  
                Started by ronaldgreene828, Today, 12:08 PM
                1 response
                9 views
                0 likes
                Last Post NinjaTrader_Kate  
                Working...
                X