Hi Sanjiv,

I also just recently had problems trying to use prec(), floor(), and round().  
I sidestepped all of them with jury rigging int().

This is what I ended up with :

buyPriceMin = int( ( symbolsLow * ( 1 - pctMax ) ) * 100) / 100;

You'll have to modify it to meet your needs...,
Michael

--- In [email protected], "sanjiv" <sumanga...@...> wrote:
>
> Hello Friends,
> 
> I need to ROUND UP or DOWN some values based on TickSize. Sometimes I need to 
> round UP and sometimes round Down. Based upon some postings of the Group, I 
> wrote following functions for the purpose. MOST of the time the results are 
> on expected line. However on some RARE occasions RoundUp_TickSize is 
> returning lower value. Sometimes RoundUp_TickSize as well as RoundDn_TickSize 
> are modifying already round values. Further prec(ARRAY, precision )  function 
> is giving errors if my functions are called inside a loop.
> 
> It will be nice if you can please guide me my errors.
> 
> With Regards
> 
> Sanjiv Bansal
> 
> ===================
> 
> TickSize = 0.05;
> 
> function Round2TickSize( aValue )
> {
> TickInv = 1 / TickSize;
> return ( round( aValue * TickInv ) / TickInv );
> }
> 
> function RoundUp_TickSize( aValue )
> {
> TickInv = 1 / TickSize;
> return( (ceil( Prec(aValue,2) * TickInv )) / TickInv);
> }
> 
> function RoundDn_TickSize( aValue )
> {
> TickInv = 1 / TickSize;
> return( (floor( Prec(aValue,2) * TickInv )) / TickInv);
> }
>


Reply via email to