Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

print "Tag" of DrawText

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

    print "Tag" of DrawText

    Hello,

    Could anyone help me with the syntax to print the tag of a DrawText object within the DrawText itself?

    For example,

    DrawText ("mytag", "Hello World", 0, Close[0], Color.Black),

    how do I get it the append "mytag" after "Hello World"?

    THanks!

    #2
    nicbizz,

    I am happy to assist you.

    You will want to use iText objects for this. Please see the following link.



    Also, you can combine two strings into one as follows :

    String1 + String2

    Please let me know if I can assist further.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Hi Adam,

      Thanks for the quick response!

      If I understand you correctly, for each text box I'd like to draw, I'll have to use the following syntax:

      IText text = DrawText("myTag", "Text to draw" + text.Tag, 10, 1000, Color.Black);

      Can I just use the same 'text' reference for all my DrawText objects (and changing only the tag), or do I need a unique reference for each object?

      Comment


        #4
        Hello nicbizz,

        One way to provide a unique tag per bar is to add + CurrentBar to the tag.

        IText text = DrawText("myTag" + CurrentBar, "Text to draw", 10, 1000, Color.Black);

        You only need 1 named object if it does all that you're looking for. This one object can draw multiple times. (Provided the tag is unique).

        You can also create multiple objects. You would do this if you can't accomplish all you want with only one.

        If you wanted to access its properties, would use something like:

        Print(text.Tag);
        Last edited by NinjaTrader_RyanM1; 10-10-2011, 11:26 AM.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Hi Ryan,

          Assuming I create a DrawText object using IText above (with "MyTag" as the Tag), how can I change, say the Color parameter, of that object?

          Thanks!

          -Nick

          Comment


            #6
            Hmm, would this be the most efficient solution:

            IText myText = (IText) DrawObjects["MyTag"];
            myText.TextColor = Color.Chocolate;

            Comment


              #7
              In the example we're working from the draw object is named text. You can specify the color directly in the overload -- the last parameter.

              To assign the color later on, could use:
              text.Pen.Color = Color.Red;
              Ryan M.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              637 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              366 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              107 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              569 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              571 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X