Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Accessing custom drawing object properties

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

    Accessing custom drawing object properties

    Hello, is there any way to access and change properties of a custom drawing object such as https://ninjatraderecosystem.com/use...-drawing-tool/ this one. It is overloaded, so I can easily access it, but the author says that in order to change the Text label, the template needs to be changed. Can I access, create and edit a template somehow using code? If not, is it possible to access the object using it's tag like I would any other (picture).

    Click image for larger version  Name:	image.png Views:	0 Size:	5.1 KB ID:	1307790
    Attached Files
    Last edited by Matt Skinner; 06-19-2024, 02:10 AM.

    #2
    Hello Matt Skinner,

    Thank you for your post.

    To clarify, are you trying to change the Text of the drawing object through code? Or are you trying to edit a drawing object template through code?

    Are you actually using the Labeled Lines drawing tool you linked, or another script? If you are using another script, I would ask the developer for clarity as whether or not you can access a custom tool's properties / edit them depends wholly on how the developer coded the script.

    You can access a drawing object using its tag through code using the DrawObjects collection. The Help Guide page below has sample code demonstrating:



    Please let us know if you need further assistance.

    Comment


      #3
      Yes, I am actually using the Labeled Lines drawing tool that I linked. It is possible with this one.

      Comment


        #4
        Hello Matt Skinner,

        Unfortunately it is not possible to edit a drawing object template through code - however, you can access the tag through the DrawObjects collection as previously mentioned.

        Please let us know if you have any further questions.

        Comment


          #5
          I undestand that It is possible to access the object, but in my case the object is this( https://ninjatraderecosystem.com/use...-drawing-tool/​) custom addon drawing tool. When I use this code (picture).
          Click image for larger version  Name:	image.png Views:	0 Size:	5.0 KB ID:	1307860
          Error gets shown that drawObject doesn't have any property called "Text". But on the next picture you can clearly see that a property like that exists, how would I go about accessing it? If it is even possible in this case, you mentioned that the creator can decide if properties can be accessed. How can I check that? Thank you for your time!

          Click image for larger version  Name:	image.png Views:	0 Size:	30.1 KB ID:	1307861​​

          Comment


            #6
            Hello Matt Skinner,

            You would use the DisplayText property.

            Code:
            foreach (DrawingTool draw in DrawObjects.ToList())
            {
            if (draw is DrawingTools.LabeledHorizontalLine)
            {
            DrawingTools.LabeledHorizontalLine myLine = draw as DrawingTools.LabeledHorizontalLine;
            Print(myLine.DisplayText);
            }
            }
            Please note that this will only print out the text the user typed, and not the price being rendered in text as this isn't exposed. ​

            Comment


              #7
              Thank you so much. I did it.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by mlarocco, Today, 11:12 AM
              1 response
              28 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by futurenow, 12-06-2021, 05:49 PM
              19 responses
              1,010 views
              0 likes
              Last Post Redders
              by Redders
               
              Started by mathfrick2023, 05-08-2025, 12:51 PM
              8 responses
              124 views
              0 likes
              Last Post Yogaman
              by Yogaman
               
              Started by several, 04-22-2025, 05:21 AM
              1 response
              285 views
              0 likes
              Last Post Lukasxgtx  
              Started by NTEducationTeam, 06-12-2025, 02:30 PM
              0 responses
              45 views
              0 likes
              Last Post NTEducationTeam  
              Working...
              X