Round the numbers

Viewing 5 posts - 1 through 5 (of 5 total)
  • #32741

    hi,

    Could someone please tell me how i get round numbers. I only want 2 numbers after the komma

    code i have now =

     

    the #a# gives the numbers, but 2 would be enough like 15.06

    Thanks in advance

    rgds

    John

     

    #32756

    Hi,

    To the best of my knowledge, there’s no direct way to specify how many digits after comma, but there’s a way to do it with small extra calculation. The only function available would be round(x) to make a round number (no digits beyond comma)  out of a real number x. So my trick is to multiply x by 10^N, round this, and then divide the rounded value by 10^N, N being the number of digits wanted after comma.

    For example, in your case you would be interested to have N=2 and do: a=round(mashort*100)/100

    1 user thanked author for this post.
    #32769

    Noobywan,

    Thank you very much !! so simple haha

    Thumbs up to you !

     

    rgds

    John

    #179072

    TimeFrame(1 day)
    MyPivotD1 = (High[1] + Low[1] + Close[1]) / 3
    MyPivotD1Rounded = Round(MyPivotD1, 2)

     

    Tout simplement

    #179081

    Yes, it's easy now, but back then the second parameter to ROUND () didn't exist.

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

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