round down/up

Tagged: , ,

Viewing 9 posts - 1 through 9 (of 9 total)
  • #41400
    tav

    How do you round down or up in prorealtime?

    #41415

    ROUND() rounds numbers to the nearest whole number, the documentation is a bit poor, since it shows only the rounding of 9.60.

    I tested this fake strategy (one buy instrution is necessary to be executed) with returns wit no addiotion, adding 0.9 and 0.4, both with positive and negative values, in case you want ALWAYS round to the greatest or to the smallest whole number:

     

     

     

    2 users thanked author for this post.
    #41420

    So, it appears that to ALWAYS round a number to the nearest greatest whole number you have to add 0.4 (both for positive and negative numbers).

    1 user thanked author for this post.
    #41425
    tav

    perfect thank you!

    #41430

    By following the link, you can find a nice little code snippet made by Pepsmile that floor and ceil a number to the nearest one.

    #118575

    Hello,
    I know this topic is old but it could be helps users like me who was affected by that issue.
    I would like to get only the integer without decimal, and without a round to superior integer when my value is above 0.5

    So I’ve created this code to get only the integer.

     

    Have fun 🙂

    1 user thanked author for this post.
    #118576

    Thank you @dupont_a , however there are now 2 new instructions in Prorealtime v11: floor and ceil

    In a future update, the ROUND instruction will also have the capability to handle digits, such as ROUND(close,2). I’m testing it and it works fine.

     

     

    #118579

    Thx Nicolas, I’m still on v10.3.
    I’m glad to learn that PRT has solved that for new version 🙂

    PS : Sorry for haven’t use  “insert PRT code” button

    #118596

    PS : Sorry for haven’t use  “insert PRT code” button

    I tidied it up ! )

Viewing 9 posts - 1 through 9 (of 9 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login