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 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.
    Gaby V.NinjaTrader Customer Service

    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.
        Gaby V.NinjaTrader Customer Service

        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. ​
            Gaby V.NinjaTrader Customer Service

            Comment


              #7
              Thank you so much. I did it.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by mbafelfel, 05-05-2017, 06:12 AM
              5 responses
              1,367 views
              0 likes
              Last Post Rancher
              by Rancher
               
              Started by Blaze212, 07-07-2024, 08:58 PM
              3 responses
              23 views
              0 likes
              Last Post Blaze212  
              Started by yertle, Today, 12:24 PM
              0 responses
              4 views
              0 likes
              Last Post yertle
              by yertle
               
              Started by reekotubbs, Yesterday, 01:09 PM
              3 responses
              28 views
              0 likes
              Last Post reekotubbs  
              Started by medicmiked, Today, 11:56 AM
              0 responses
              9 views
              0 likes
              Last Post medicmiked  
              Working...
              X