Rounding before the zero  [SOLVED]

Questions about MultiCharts and user contributed studies.
waldem
Posts: 115
Joined: 18 Nov 2013
Has thanked: 3 times
Been thanked: 4 times

Rounding before the zero

Postby waldem » 13 Apr 2017

Hi all there are some way to round the numbers before the zero?
for example, i have the function: TrdQty = IntPortion (Capital / close);
this results should be for eg: 3663 but i would like to have 3660 - 3665 etc...
i know perfectly the function: JK_Math_RoundToNearest. but that works only for fraction after the zero, for eg: JK_Math_RoundToNearest(100.58, 0.25) -> 100.50.

could you help me?
thanks
walter

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Rounding before the zero

Postby TJ » 13 Apr 2017

Hi all there are some way to round the numbers before the zero?
for example, i have the function: TrdQty = IntPortion (Capital / close);
this results should be for eg: 3663 but i would like to have 3660 - 3665 etc...
i know perfectly the function: JK_Math_RoundToNearest. but that works only for fraction after the zero, for eg: JK_Math_RoundToNearest(100.58, 0.25) -> 100.50.

could you help me?
thanks
walter

Please give specific and comprehensive examples of what you would like to do.


e.g.

xxxx should be converted to XXX
yyy should be converted to YYYY
zzzzz should be converted to ZZZZ

waldem
Posts: 115
Joined: 18 Nov 2013
Has thanked: 3 times
Been thanked: 4 times

Re: Rounding before the zero

Postby waldem » 13 Apr 2017

Hi TJ, 3663 should be 3660 or 3665 step of 5.
walter

escamillo
Posts: 203
Joined: 25 Mar 2011
Has thanked: 23 times
Been thanked: 56 times

Re: Rounding before the zero  [SOLVED]

Postby escamillo » 13 Apr 2017

Code: Select all

Value1 = Round(Value1 * 0.1, 0) * 10 ; //to round to 10
or
Value1 = Round(Value1 * 0.2, 0) * 5 ;//to round to 5
Value1 = Round(Value1 * 0.2, 0) * 5 ; will round to 0, 5, 10, 15, etc.


Return to “MultiCharts”