Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Formatting Digits

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

    Formatting Digits

    I have a Range predictor for Range Bars that calculates the projected high and low prices correctly, but I don't know how to get it to print a decimal place when the price is a whole number , 731.0 as opposed to 731.

    if(showValues)
    {
    DrawText("HighValue", true, " . " + (Low[0]+(1*TickSize)+ Bars.Period.Value*TickSize), 0, Low[0]+(10*TickSize)+ (Bars.Period.Value*TickSize) , 2, Color.White, new Font("Arial", 9), StringAlignment.Near, Color.White, Color.Black, 10);
    }
    Attached Files

    #2
    Originally posted by ThatManFromTexas View Post
    I have a Range predictor for Range Bars that calculates the projected high and low prices correctly, but I don't know how to get it to print a decimal place when the price is a whole number , 731.0 as opposed to 731.

    if(showValues)
    {
    DrawText("HighValue", true, " . " + (Low[0]+(1*TickSize)+ Bars.Period.Value*TickSize), 0, Low[0]+(10*TickSize)+ (Bars.Period.Value*TickSize) , 2, Color.White, new Font("Arial", 9), StringAlignment.Near, Color.White, Color.Black, 10);
    }
    Perhaps you can use the " .ToString("0.00") " format, as in the following example:

    Code:
    [FONT=Consolas][SIZE=2][COLOR=#f3f3f3][FONT=Consolas][SIZE=2][COLOR=#f3f3f3][FONT=Consolas][SIZE=2][COLOR=#f3f3f3][COLOR=black]Print[B]([/B]Time[B][[/B]0[B]][/B].ToString[B]() [/B]+[/COLOR][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][COLOR=black][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]"Closing price with a lot of decimals: "[/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]+Close[B][[/B]0[B]][/B].ToString[B]([/B][/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][/COLOR][COLOR=black][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]"0.00000000"[/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][B][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]));[/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][/B][/COLOR][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]
    [/SIZE][/FONT][/SIZE][/FONT]
    which results in:
    Code:
    17-12-2008 12:45:00Closing price with a lot of decimals: 2434,70000000
    ( so it's .7000000 instead of .7 ). Off course, such a number of zero's is absurd, so ToString("0.00") woud be more than sufficient.

    Regards,

    Comment


      #3
      Thanks!

      Originally posted by J_o_s View Post
      Perhaps you can use the " .ToString("0.00") " format, as in the following example:

      Code:
      [FONT=Consolas][SIZE=2][COLOR=#f3f3f3][FONT=Consolas][SIZE=2][COLOR=#f3f3f3][FONT=Consolas][SIZE=2][COLOR=#f3f3f3][COLOR=black]Print[B]([/B]Time[B][[/B]0[B]][/B].ToString[B]() [/B]+[/COLOR][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][COLOR=black][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]"Closing price with a lot of decimals: "[/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]+Close[B][[/B]0[B]][/B].ToString[B]([/B][/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][/COLOR][COLOR=black][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]"0.00000000"[/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][B][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]));[/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][/B][/COLOR][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]
      [/SIZE][/FONT][/SIZE][/FONT]
      which results in:
      Code:
      17-12-2008 12:45:00Closing price with a lot of decimals: 2434,70000000
      ( so it's .7000000 instead of .7 ). Off course, such a number of zero's is absurd, so ToString("0.00") woud be more than sufficient.

      Regards,
      Thanks, That worked!

      Code:
      DrawText("HighValue", true, "     " +  (Low[0]+(1*TickSize)+ Bars.Period.Value*TickSize)[B].ToString("0.0")[/B], 0, Low[0]+(Ticks*TickSize)+ (Bars.Period.Value*TickSize) , 2, Color.White, new Font("Arial", 9), StringAlignment.Center, Color.White, Color.Black, 10);

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      571 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      331 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
      549 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      549 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X