[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EL for special rounding



PureBytes Links

Trading Reference Links

Barry Silberman wrote:
>  A)  If price is above the .5 level go to next .5 and add .1   Thus, if
>price is 920.75 new price should be 921.60.
>  B)  If price is below the .5 level go to next .5 and add .1    Thus, if
>price is 920.25 new price should be 920.60

The following may help (composed here online, not using the PowerEditor):

------------------------------------------------------------
{Function _Round
 Round the number x to the nearest p.
 p may be a fraction or an integer, so
 _Round(12.64, 0.5) would return 12.5}

Inputs: x(NumericSimple), p(NumericSimple);

_Round = p * IntPortion((x + 0.5*p) / p);
------------------------------------------------------------

Then the result you want should be simply _Round(price+0.5, 0.5) + .1


-- 
  ,|___    Alex Matulich -- alex@xxxxxxxxxxxxxx
 // +__>   Director of Research and Development
 //  \ 
 // __)    Unicorn Research Corporation -- http://unicorn.us.com