Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw.Text with a space after text is not being drawn.

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

    Draw.Text with a space after text is not being drawn.

    Hi,

    I don't want my text being so close to the square border, so I want to use a space after my string to create a space,
    but Ninja ignores the space. I've even tried all the following Unicode characters to get around it, but Ninja ignores them too.

    I don't know how to get around this.

    Thanks.
    • U+0020: " "
    • U+00A0: " "
    • U+2000: " "
    • U+2001: " "
    • U+2002: " "
    • U+2003: " "
    • U+2004: " "
    • U+2005: " "
    • U+2006: " "
    • U+2007: " "
    • U+2008: " "
    • U+2009: " "
    • U+200A: " "
    • U+202F: " "
    • U+205F: " "
    • U+3000: " "

    #2
    Hello davydhnz,

    Thank you for your post.

    Do you receive any errors on the Log tab of the Control Center? If so, what do the errors report?

    I was able to draw text and draw fixed test with a space at the end of the string as follows:
    Code:
            protected override void OnBarUpdate()
            {
                if (CurrentBar < 1)
                    return;
                Draw.Text(this, "myText", "this is my text. ", 0, Low[0] - 5 * TickSize);
                Draw.TextFixed(this, "myTextFixed", "this is my text. ", TextPosition.TopRight, false, "");
            }
    ​
    If you are not receiving any errors and still don't see the text being drawn, please provide a screenshot demonstrating where you expect the text to be drawn on the chart as well as a snippet of your script so I may look into this further with you.
    • To send a screenshot with Windows 10 or newer I would recommend using the Windows Snipping Tool.
    • Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screenshot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save it as a jpeg file and send the file as an attachment.
    ​I look forward to assisting you further.

    Comment


      #3
      NinjaTrader_Emily Does your example display the trailing space? That is what davydhnz is wanting I suspect. My own efforts to have trailing spaces displayed also does not produce them in the displayed text.

      Thanks.
      Multi-Dimensional Managed Trading
      jeronymite
      NinjaTrader Ecosystem Vendor - Mizpah Software

      Comment


        #4
        NinjaTrader_Emily,

        Here's a screenshot.

        Click image for larger version

Name:	Screenshot 2023-03-10 015609.png
Views:	150
Size:	2.1 KB
ID:	1239038

        Here is the code:


        Code:
        protected override void OnBarUpdate()
        {
        Draw.TextFixed(this, "My test",
        "   " + "My String" + "   ",
        TextPosition.TopRight, Brushes.PeachPuff, NotificationFont, Brushes.Green, Brushes.Black, 83, DashStyleHelper.Solid, 3, false, "");
        }
        Now my real indicator doesn't just have "My String," it's a proper string that changes all the time, but I'm trying to keep it simple for conservation.

        I put three spaces on either side to make a point, you'll observe that the right side doesn't get acknowledged like the left side does.

        Thank you for your help.

        David

        Comment


          #5
          Hello David,

          Thank you for your note.

          I suspect what is happening is there is a method somewhere in the inner workings of NinjaTrader that trims whitespace off of the end of the string in Draw() methods. I have been testing to try and find a blank character that is not considered whitespace. I see you have already tested many other blank characters to no avail. I appreciate your diligence in trying to figure out a solution; upon looking through online resources and other threads, I found the following thread discussing the same topic:


          It seems that adding \b to the end of your string will result in the spaces being printed at the end as desired.

          Please let me know if I may be of further assistance.

          Comment


            #6
            NinjaTrader_Emily, thank you.

            I tried /b. It didn't work. I tried /t, and that worked, but that's quite a lot of space! Then I tried space followed by /b and that worked. So we finally got there!
            Thanks for your help!

            David

            Comment


              #7
              Hello David,

              Thanks for your note.

              I am glad to hear you got it to work! I should have clarified that in my statement "adding \b to the end of your string" I meant adding it to the end of your string with the desired spaces included in the string. Sorry for any confusion, though it sounds like you figured it out either way.

              Thank you for your time and have a great day.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              599 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              344 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              103 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              558 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              557 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X