Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DrawText

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

    DrawText

    Hello, I would like to add a text field to print the current value of a custom indicator just below the name. I have added some moving averages and all the price labels on the Y axis overlap, so I would rather print these in the top left corner.

    Does anyone have a sample as to how to do this? I would like to print it just below the name of the indicator or to the right of it, which ever is easier.

    Thanks!

    #2
    tradinginzen,

    Please try DrawTextFixed(). http://www.ninjatrader-support.com/H...TextFixed.html

    DrawTextFixed("tag1", "Text to draw", TextPosition.TopLeft);
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thanks that worked perfectly.

      Comment


        #4
        Hello,
        How would I add to the DrawTextFixed code below to change the color of the text...right now the text color is black. Lets say I would like the text to be red or blue?

        Thanks

        Comment


          #5
          DrawTextFixed(string tag, string text, TextPosition textPosition, Color textColor, Font font, Color outlineColor, Color backColor, int opacity)
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Thanks Josh,
            This wont work.
            DrawTextFixed("CCi","RisingCCI",TextPosition.BottomRight,Color.Green);
            Do I need to add all the other things too? the...Font font, Color outlineColor, Color backColor, int opacity).

            Thanks

            Comment


              #7
              You need all.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Is there a snippet of code somewhere showing an actual syntax for
                ,Font font, entry

                Comment


                  #9
                  DrawTextFixed("tag", "text", TextPosition.Center, Color.Black, new Font("Arial", 10), Color.Black, Color.Black, 5);
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    How can you place more than one drawtext in the top left corner without overlap?

                    Comment


                      #11
                      Hello brucelevy,

                      Thanks for your post.

                      The DrawTextFixed would draw to the location specified, subsequent calls would draw to the same location, starting at the same point and so would overlay.

                      If you need multiple lines, you can use the "\n" new line command in the text.
                      Here is an example of 4 lines drawn one at a time:

                      if (CurrentBar == 0)
                      {
                      string v1 = "Line 1";
                      string v2 = "\nLine 2";
                      string v3 = "\n\nLine 3";
                      string v4 = "\n\n\nLine 4";

                      DrawTextFixed("line1",v1,TextPosition.TopLeft);
                      DrawTextFixed("line2",v2,TextPosition.TopLeft);
                      DrawTextFixed("line3",v3,TextPosition.TopLeft);
                      DrawTextFixed("line4",v4,TextPosition.TopLeft);
                      }

                      The output on the chart would be in the upper left corner:
                      Line 1
                      Line 2
                      Line 3
                      Line 4

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      579 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      334 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      101 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      554 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      551 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X