Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to make new line with DrawText in NT 8

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

    How to make new line with DrawText in NT 8

    A comment thread exists for this topic but applies to NT7. \n or \nMore no longer works or does it belong outside of the string?

    Bottom line looking for syntax on this for NT8 Text.

    Thanx
    JM

    #2
    Hello JM,

    \r\n still works to make new lines in 8.1.1.5.

    Attached is a screenshot.

    Click image for larger version

Name:	2023-05-03_11-10-17.png
Views:	408
Size:	108.1 KB
ID:	1249789
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you, it appears the nomenclature has changed slightly with the \r...

      BUT,

      I tried this and its still not working; probably because of what I'm using. I'm using TextFixed and on occasion two separate conditional incident text lines may need fire at the same time. Solution here is to have one of them print one line lower by default. So checking to see if TextFixed will allow this & if so what the nomenclature is...

      In using your example on one of the two they are still printing on top of each other.

      Thanx
      JM

      Comment


        #4
        Hello JM,

        The \r\n is the same for NinjaTrader 7 as well.

        Below is a link to a forum post in the NinjaTrader 7 section of the forums that discusses.


        Draw.TextFixed() or Draw.Text() will work the same.

        However, you do have to have text on the new line for the new line to show.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          I would recommend that as a matter of principle you consider using System.Environment.NewLine not hardcoding "\r\n".
          Bruce DeVault
          QuantKey Trading Vendor Services
          NinjaTrader Ecosystem Vendor - QuantKey

          Comment


            #6
            Not working... What's happening is the code ' \r\n ' is showing up as text; added to the front character space in front of the desired text.

            Comment


              #7
              Thanks Bruce, not seen that one. Where is the code you suggest added? Here is the current code. Objective is have this line print one below the top line, with nothing in the top line.

              Draw.TextFixed(this, @"Exam", @"\r\n Example", GetTextPosition(Location), InfoBrush, Font, Brushes.Transparent, Brushes.Transparent, 0);

              Comment


                #8
                Draw.TextFixed definitely supports multiple lines with System.Environment.NewLine. Did you try the code that NinjaTrader_ChelseaB posted above in the screenshot? That works as well.
                Bruce DeVault
                QuantKey Trading Vendor Services
                NinjaTrader Ecosystem Vendor - QuantKey

                Comment


                  #9
                  Hello johnMoss,

                  Remove the @ symbol from the front of the string.

                  You will need some text on each line (there can't be a new line without text on it). The top line cannot be blank. Nor would that make sense, as that would be the same as no new line. Try ".\r\nExample" instead.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Get rid of the @ - that is your problem.
                    Bruce DeVault
                    QuantKey Trading Vendor Services
                    NinjaTrader Ecosystem Vendor - QuantKey

                    Comment


                      #11
                      Correct, thank you... Curious as to why its part of the standard code, but removing it worked ...

                      Comment


                        #12
                        Hello johnMoss,

                        The @ symbol means verbatim text.

                        Below is a link to the microsoft documentation.
                        Verbatim text using the `@` enables C# keywords to be used as identifiers, or indicates that a string literal should be interpreted verbatim, or to distinguish attribute names
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          I don't know about "the standard code" but I never use @ and mine all work. @ means repeat what you have typed verbatim without interpreting it. And, in this case, you want it interpreted to mean a new line, yet you have instructed it not to do that.
                          Bruce DeVault
                          QuantKey Trading Vendor Services
                          NinjaTrader Ecosystem Vendor - QuantKey

                          Comment


                            #14
                            It's how it's demonstrated from the source I got it from so assumed it was a necessary inclusion. Thank ya'll for the heads up, now I know ...

                            JM

                            Comment


                              #15
                              I'd be willing to bet it's only in the source because it doesn't have any non-literal characters in there.
                              Bruce DeVault
                              QuantKey Trading Vendor Services
                              NinjaTrader Ecosystem Vendor - QuantKey

                              Comment

                              Latest Posts

                              Collapse

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