Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Rounding question

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

    Rounding question

    Hello,

    my script is:

    risk_long = GetCurrentBid() - Swing(5).SwingLow[0];
    psize_long1 = accbalNew * (riskf/100)/risk_long;
    psize_long2 = (psize_long1/1000);

    PTLongTA1 = psize_long2 *0.3;
    PTLongTA1 = Math.Round(PTLongTA1);

    PTLongTA2 = psize_long2 *0.3;
    PTLongTA2 = Math.Round(PTLongTA2);

    PTLongTA3 = psize_long2 *0.4;
    PTLongTA3 = Math.Round(PTLongTA3);

    I need integers, rounded up and rounded down.
    How can I implement it?

    #2
    Hello Blackburn,

    Thank you for your post.

    What values need to ints? What values are currently doubles?

    Comment


      #3
      actually all values are doubles.

      PTLongTA1 , PTLongTA2 and PTLongTA3 need to ints

      Comment


        #4
        Hello BlackBurn,

        Thank you for your response.

        You can use Math.Round(value, 0) and then Convert.ToInt32().

        Please visit the following links for more information:

        Comment


          #5
          Can I use "round.math" also für rounded down?

          Comment


            #6
            Originally posted by Blackburn View Post
            Can I use "round.math" also für rounded down?
            Use Math.Round() for mathematical rounding.
            Use Math.Ceiling() to force rounding up.
            Use Math.Floor() to force rounding down.

            Comment

            Latest Posts

            Collapse

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