Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Convert Double int for chart text display.

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

    Convert Double int for chart text display.

    I'm sure there's a library item on this, so confession I'm cheating for time bringing this to the forum.

    I played around with it & got nowhere (dunce cap)

    I have a bar calculation which requires the use of doubles. All good to go there. I want this value displayed on the chart, and of course directly applying doubles to this is a crap shoot of 0 to 12 decimal points also displayed.. messy...

    Objective is to convert the resultant double value into an integer so that it displays without the decimals; hence for example derived value of 54.1836574632 displays on chart as a simple 54.

    Thanx
    JM

    #2
    Hello johnMoss,

    If what you are doing is drawing a string on the chart from your double you can use the C# ToString method to format the number. You can see some examples in the following public link: https://learn.microsoft.com/en-us/do...ramework-4.8.1

    Code:
    string myString = myDouble.ToString();
    If you want to actually convert the number to an int and not just trim the remainder you can cast it to an int:

    Code:
    int myInt = (int)myDoubleVariable;

    Comment


      #3
      This is what I have right now:

      Draw.Text(this, CurrentBar.ToString(), true, percent.ToString(), 0, Low[0] - (4 * TickSize), 0 , _textColorDefinedbyUser, myFont, TextAlignment.Justify, null, null, 1);

      I gather I need to do something with the one of the nulls or do I need to venture upstairs with

      public string ToString (string format, IFormatProvider provider);

      JM

      Comment


        #4
        Hello johnMoss,

        if the variable percent is what you want to format you almost have what you need, it would be:

        Code:
        percent.ToString("N0")

        Comment


          #5
          Thank you sir... Like a champ

          JM

          Comment

          Latest Posts

          Collapse

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