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

String Formatting

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

    String Formatting

    I am trying to use "\t" in a string so I will have columns. Doesn't seem to be working. My code snippet is

    String pricerank = "Column 1\tColumn 2\tColumn 3";

    which produces
    Column 1Column 2Column 3

    when I expected it to produce
    Column 1 Column 2 Column 3

    What am I doing wrong?

    Mike

    #2
    Maybe try this and see what the results are:

    String pricerank = "Column 1 \tColumn 2 \tColumn 3";
    eDanny
    NinjaTrader Ecosystem Vendor - Integrity Traders

    Comment


      #3
      it's puts a space between them and not a tab...

      Comment


        #4
        Hi Mike Winfrey,

        You can either add multiple spaces, or add more \t

        Try...

        String pricerank = "Column 1\t\tColumn 2\t\tColumn 3";
        Last edited by NinjaTrader_Tim; 03-15-2010, 02:01 PM.
        TimNinjaTrader Customer Service

        Comment


          #5
          Thanks...according to http://msdn.microsoft.com/en-us/libr...8VS.71%29.aspx

          string c = "hello \t world"; // hello world

          which tells me \t should do more than what i'm getting. Using \t in my indicator doesn't produce any spacing at all.

          just tried the following

          String x = "Column 1/t/t/tColumn 2/t/t/tColumn 3/t/t/t" and it produced

          Column 1Column 2Column 3

          when according to the reference I provided, it should've done something other than what it did.

          Because these fonts are apparently truetype, using spaces is unacceptable as well. Spaces don't produce a well formatted string.

          Comment


            #6
            Hi Mike Winfrey,

            I have been unable to reproduce your results. The \t creates a space on my end.

            How exactly are you using the string? Are you printing to text on a chart? To the output window?
            TimNinjaTrader Customer Service

            Comment


              #7
              The funny thing is that according to the reference I sent you it shouldn't produce a space but a tab. Anyway, I am using it to send the string to the chart in the upper right corner of the price panel using the code snippet I provided in the first post.

              More fully, I am using

              String pricerank =
              "GBPAUD\t" + GBPAUD.ToString("0.0") +
              "\nGBPCAD\t" + GBPCAD.ToString("0.0") +
              "\nGBPCHF\t" + GBPCHF.ToString("0.0") +
              "\nGBPJPY\t" + GBPJPY.ToString("0.0") +
              "\nGBPNZD\t" + GBPNZD.ToString("0.0") +
              "\nGBPJPY\t" + GBPJPY.ToString("0.0") +
              "\nEURGBP\t" + EURGBP.ToString("0.0");

              DrawTextFixed("PriceRank",pricerank,TextPosition.T opRight,Color.Black,textFont,Color.Empty,Color.Emp ty,10);

              Am attaching the strategy with proprietary stuff removed. You can see what I'm trying to do is very basic with this string formatting.

              Thanks,
              Mike
              Attached Files

              Comment


                #8
                Please lower case your S for string and see if that helps.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  nope...same result.
                  now i am using

                  string pricerank = ...

                  Comment


                    #10
                    Mike,

                    Here is the deal. When you use it in a DrawText() as a draw object, you will not see such formatting. You can only see the formatting when you use it and print to say the Output Window.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      That's funny. Does that just apply to the \t? Just wondering because \n works in DrawText.

                      Thanks

                      Comment


                        #12
                        Hi Mike Winfrey,

                        \n appears to work as expected.
                        TimNinjaTrader Customer Service

                        Comment


                          #13
                          Yes I know which is why I asked my last question...why does \n work but \t doesn't?

                          Comment


                            #14
                            Mike,

                            Seems to be a bug. Thank you. We have added it to our list.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              Cool...thanks Josh

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by maybeimnotrader, Yesterday, 05:46 PM
                              1 response
                              18 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by Perr0Grande, Yesterday, 08:16 PM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by f.saeidi, Yesterday, 08:12 AM
                              3 responses
                              24 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by algospoke, Yesterday, 06:40 PM
                              1 response
                              14 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by quantismo, Yesterday, 05:13 PM
                              1 response
                              14 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Working...
                              X