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

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 selu72, Today, 02:01 PM
              1 response
              7 views
              0 likes
              Last Post NinjaTrader_Zachary  
              Started by WHICKED, Today, 02:02 PM
              2 responses
              12 views
              0 likes
              Last Post WHICKED
              by WHICKED
               
              Started by f.saeidi, Today, 12:14 PM
              8 responses
              21 views
              0 likes
              Last Post f.saeidi  
              Started by Mikey_, 03-23-2024, 05:59 PM
              3 responses
              51 views
              0 likes
              Last Post Sam2515
              by Sam2515
               
              Started by Russ Moreland, Today, 12:54 PM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_Erick  
              Working...
              X