Announcement

Collapse
No announcement yet.

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 kiffgj, Today, 04:23 AM
                              0 responses
                              10 views
                              0 likes
                              Last Post kiffgj
                              by kiffgj
                               
                              Started by Lando Calrissian, Today, 07:30 AM
                              1 response
                              4 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Started by lismartin, Yesterday, 04:47 PM
                              1 response
                              15 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by facuevasm, Today, 07:28 AM
                              3 responses
                              13 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by ballston, Today, 06:32 AM
                              0 responses
                              8 views
                              0 likes
                              Last Post ballston  
                              Working...
                              X