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

Accessing the DrawingTool properties window programmatically

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

    Accessing the DrawingTool properties window programmatically

    Hi! How can I programmatically access a properties window of a DrawingTool? For example if I need to scan all objects on the chart and check which of them are Text and which text in particular these objects contain?

    #2
    Hello akuntysh, and thank you for your question.

    This code example demonstrates how to do this with a generic drawing tool, as well as how to access other features only available to certain drawing tools. Please let us know if there are any other ways we can help.

    Code samples we provide are for educational purposes, and are not intended for live trading, and are not guaranteed to accomplish any user goal or to be maintained.
    Attached Files
    Last edited by NinjaTrader_JessicaP; 03-27-2017, 03:24 PM.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Hello Jessica! Thank you for your answer! However this code

      foreach (IDrawingTool myDrawObject in DrawObjects){
      DrawingTools.Rectangle rect = myDrawObject as DrawingTools.Rectangle;
      }

      or this code

      foreach (IDrawingTool myDrawObject in DrawObjects){
      Rectangle rect = myDrawObject as Rectangle;
      }


      returns a null to the "rect" variable. I have drawn a rectangle on a chart of course. Am I missing something?

      Comment


        #4
        This definitely should not be the case. When you run the script with the print statement that prints out the IDrawingTool's tag, before trying to cast as a DrawingTools.Rectangle, what is the tag that gets output for the relevant drawing object?
        Jessica P.NinjaTrader Customer Service

        Comment


          #5
          Jessica, I am very sorry... Seems that I have had some technical issues with my current installed NT8 instance. After reinstalling I have managed to get the same code working. Thank you for your assistance! Best regards!

          Comment


            #6
            Hi Jessica! I have identified the issue. To some reason if I draw an object before I applied an indicator to a chart - the indicator is unable to covert the drawing tool to a specific type and so returns null (despite it can "see" the object on the chart). However, after a modification of any parameter of a drawn object (even simply accessing the properties window and closing it) the indicator is able to "see" the object and convert it to a specific type.
            If I draw an object after I applied the indicator to a chart - it can "see" and convert it without any problems.
            Could you please advise on if there is a possible solution for this?

            Comment


              #7
              I was not able to see quite the same thing on my end that you are seeing on yours. The attached script can display information about rectangles added before the script. Please review your code against the attached test. We are happy to help with any questions we may.
              Attached Files
              Jessica P.NinjaTrader Customer Service

              Comment


                #8
                Hi Jessica! Thank you! I have created a script with the code you have sent me and it still can recognize only those rectangles that I have drawn/changed-properties-of after I have applied the script on the chart. However, I have found that I need to open and close the properties window of only one (any) of the objects that are on the chart to make the script "see" all objects. So it is a very minor problem now and I don't want to waste your time any more. Thank you for your attention!

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by kujista, Today, 05:44 AM
                3 responses
                13 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by samish18, Yesterday, 08:57 AM
                9 responses
                26 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Started by samish18, Today, 08:31 AM
                0 responses
                0 views
                0 likes
                Last Post samish18  
                Started by RookieTrader, Today, 07:41 AM
                2 responses
                8 views
                0 likes
                Last Post RookieTrader  
                Started by trilliantrader, Today, 08:16 AM
                0 responses
                3 views
                0 likes
                Last Post trilliantrader  
                Working...
                X