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 set2win, 08-04-2021, 09:23 AM
              39 responses
              1,000 views
              0 likes
              Last Post WaleeTheRobot  
              Started by md4866, Today, 08:15 PM
              0 responses
              6 views
              0 likes
              Last Post md4866
              by md4866
               
              Started by mjbatts91, Yesterday, 04:48 PM
              2 responses
              23 views
              0 likes
              Last Post mjbatts91  
              Started by pibrew, Today, 06:10 PM
              1 response
              19 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by actualfacts.2021, 07-25-2021, 03:11 PM
              8 responses
              1,187 views
              0 likes
              Last Post linkcou
              by linkcou
               
              Working...
              X