hi,
Could someone please tell me how i get round numbers. I only want 2 numbers after the komma
code i have now =
a= mashort
if mashort<mashort[1] then
DRAWTEXT(" BEAR ■",barindex+0.5,+0.7,SansSerif,Bold,12)coloured(255,0,0)
Drawtext("#a#",barindex-Xoffset-1.35,+0.7,SansSerif,Bold,12)coloured(0,0,0)
the #a# gives the numbers, but 2 would be enough like 15.06
Thanks in advance
rgds
John
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
Noobywan,
Thank you very much !! so simple haha
Thumbs up to you !
rgds
John
TimeFrame(1 day)
MyPivotD1 = (High[1] + Low[1] + Close[1]) / 3
MyPivotD1Rounded = Round(MyPivotD1, 2)
Tout simplement
Yes, it's easy now, but back then the second parameter to ROUND () didn't exist.