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 charlesugo_1, 05-26-2026, 05:03 PM
            0 responses
            65 views
            0 likes
            Last Post charlesugo_1  
            Started by DannyP96, 05-18-2026, 02:38 PM
            1 response
            149 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 05-11-2026, 05:56 AM
            0 responses
            162 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 05-10-2026, 08:12 PM
            0 responses
            99 views
            0 likes
            Last Post CarlTrading  
            Started by Hwop38, 05-04-2026, 07:02 PM
            0 responses
            286 views
            0 likes
            Last Post Hwop38
            by Hwop38
             
            Working...
            X