ROUNDUP function in amibroker

Hi,

I am using ROUNDUP function in excel as seen below.
A1=1346.10
=ROUNDUP(A1*1.00618,1)

Result is 1354.5

How can i achieve the same anaswer in Amibroker?
I guess we have only ROUND function in amibroker.

Regards,

Gloria Filamino.

Try using `Prec()`

https://www.amibroker.com/guide/afl/prec.html

2 Likes
``````function RoundToTick( price, tick ) {
result = round( price / tick ) * tick;// or use ceil, or floor instead of round
return result;
}

value = 1346.10*1.00618;

printf( "Raw value: %g\n\n", value );
printf( "tick round: %g", RoundToTick( value, 0.5 ) );
``````

On the other hand if you want to insert decimal place as argument you could do like so

``````function PrecRound( value, decplaces ) {
// by Tomasz Janezcko
return Prec( value + 5*10^-(decplaces+1), decplaces );
}

value = 1346.10*1.00618;
printf( "\nprecround: %g", PrecRound( value, 1 ) );
``````

9 Likes

I changed RoundToTick to accept decimal places (You can also set negative value for "decplaces" argument. Then it rounds to the left of the decimal place):

``````function RoundUp ( value, decplaces ) {
powten = 10^decplaces;
result = ceil(value * powten) / powten;
return result;
}

value = 1346.10*1.00618;
decplaces = 1;
printf( "Raw value: %g\n", value );
printf( "RoundUp(dec_places: %g): %g", decplaces, RoundUp( value, decplaces ) );
``````