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

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:	996
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


                  #9
                  Hi Paul Regarding what you mentioned in#6, can you show more the code how I can extract the values for my strategy from the rectangle as I am also using that "Repeater"indicator
                  > i am a beginner and donno how to extract those values for that rectangle

                  Many thanks
                  sst

                  Comment


                    #10
                    Hello stantenlee,

                    Thank you for your reply.

                    My colleague Paul has example code in a prior reply on this thread:

                    Originally posted by NinjaTrader_PaulH View Post
                    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);
                    }
                    }
                    }
                    As I mentioned in your other post regarding this indicator, you would need to loop through the drawing objects the indicator has created on the chart and then you can see if they are rectangles, get their anchor values and do what you like with them within the strategy. This cannot be done using the Strategy Builder and you would have to manually code the strategy to include this logic. I would personally recommend starting with smaller projects if you are a beginner to creating NinjaScript Strategies to get you more comfortable with coding manually using NinjaScript as this would require more advanced programming skill.

                    If you are interested in having the code written for you, you can also contact one of our professional NinjaScript Consultants or Educators who would be eager to create or modify a script at your request or assist you with your script. Please let me know if you would like a list of professional NinjaScript Consultants or Educators who would be happy to create or modify any script at your request or assist you in learning NinjaScript.

                    Please let us know if we may be of further assistance to you.
                    Kate W.NinjaTrader Customer Service

                    Comment


                      #11
                      I got the code you showed me and have no problem on managing the indicator part, what my question is how to make the values *the startY and End Y"that I got being called in the strategy. Is there any sample or example showing this(the strategy that call the startY and end Y) and I would know more clearly.

                      Sure if consultants or educators can help. Many thanks

                      Comment


                        #12
                        Hello stantenlee,

                        Thank you for your reply.

                        I've created a relatively simple example strategy that must be added to the chart and enabled after the Repeater indicator has been added to the chart. In creating the example I noted that it does not seem to be possible to call the indicator properly from a strategy, so the indicator would need to be manually added to a chart to test. Once the indicator has been added to the chart, apply the example strategy. It will loop through the drawing objects on the chart and find the rectangles it draws for each day. It then gets the time and price of the start and end points. If the rectangle is seen for the current day, it will assign the Y values of the start and end points to variables which it then compares to the current close price. If the close is above the end point (which is always higher) it enters short, if it goes below the start point (which is always the lower of the two) it enters long.

                        I will have our vendor support team reach out with information on NinjaScript Consultants as soon as they are able.

                        Please let us know if we may be of further assistance to you.
                        Attached Files
                        Kate W.NinjaTrader Customer Service

                        Comment


                          #13

                          Hello

                          Thank you for your post.

                          You can search our list of NinjaScript consultants through the link below. Simply enter a consultant name or search by using our filter categories. Once you have identified your consultants of choice, please visit each consultant's site for more information or contact them directly to learn more:
                          You can locate the contact information for the consultants on their direct websites for any additional questions you may have. Since these consultants are third-party services for NinjaTrader, all pricing and support information will need to be obtained through the consultant.

                          The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The companies and services listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem, LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.

                          Let me know if I may be of further assistance.
                          Thomas C.NinjaTrader Customer Service

                          Comment


                            #14
                            thanks thomas

                            Comment


                              #15
                              Originally posted by NinjaTrader_Kate View Post
                              Hello stantenlee,

                              Thank you for your reply.

                              I've created a relatively simple example strategy that must be added to the chart and enabled after the Repeater indicator has been added to the chart. In creating the example I noted that it does not seem to be possible to call the indicator properly from a strategy, so the indicator would need to be manually added to a chart to test. Once the indicator has been added to the chart, apply the example strategy. It will loop through the drawing objects on the chart and find the rectangles it draws for each day. It then gets the time and price of the start and end points. If the rectangle is seen for the current day, it will assign the Y values of the start and end points to variables which it then compares to the current close price. If the close is above the end point (which is always higher) it enters short, if it goes below the start point (which is always the lower of the two) it enters long.

                              I will have our vendor support team reach out with information on NinjaScript Consultants as soon as they are able.

                              Please let us know if we may be of further assistance to you.
                              Hi Kate,

                              Thanks for your help, how can I get the values too the next day,something like it would run if Anchor.Time.Date =time[0].Date OR equal to next day.Date
                              temp.StartAnchor.Time.Date == Time[0].Date || temp.StartAnchor.Time.Date == Time[0].Date+1?it does not work

                              How about if i delete this temp.StartAnchor.Time.Date == Time[0].Date, what will happen?
                              thanks for your help

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by algospoke, Yesterday, 06:40 PM
                              2 responses
                              19 views
                              0 likes
                              Last Post algospoke  
                              Started by ghoul, Today, 06:02 PM
                              3 responses
                              14 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by jeronymite, 04-12-2024, 04:26 PM
                              3 responses
                              45 views
                              0 likes
                              Last Post jeronymite  
                              Started by Barry Milan, Yesterday, 10:35 PM
                              7 responses
                              20 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by AttiM, 02-14-2024, 05:20 PM
                              10 responses
                              181 views
                              0 likes
                              Last Post jeronymite  
                              Working...
                              X