PureBytes Links
Trading Reference Links
|
At 6:24 PM -0400 7/21/01, Kent Rollins wrote:
>As much as I hate to perpetuate this discussion, I thought I would
>contribute this: when combining 2 floats, you have to consider relative
>magnitude.
This is true but probably not a factor in this case. Since the
calculation is:
Sum = Sum[1] + Price - Price[Length];
"Sum" will be about equal to Length * Price. If Price = 10000 (as in
the DJIA) and Length = 1000 (very long for such an average) then Sum
will be about 10^7 which limits the precision to about 1.0, which
would neglect the fractions in the price.
But since the calculation does not take the difference between such
large numbers, the final accuracy for one iteration is still about
one part in 10^7 after dividing the Sum by Length. The error builds
up with each new bar but can be fixed by the trick I posted earlier.
I guess it would be slightly better to use:
Sum = Sum[1] + (Price - Price[Length]);
to force the subtraction of near equal size numbers before adding the
difference to the much larger Sum and avoid subtracting a small number
from a big one.
Our complaint with Omega is not with the use of floating point
arithmetic or even single-precision floats. Our complaint is that if
the developers of TradeStation decided, for whatever reason, to use
single-precision floats for the arithmetic, they have the OBLIGATION
to create a function library using programming techniques that give
accurate results using single-precision floats. The present library
gives inaccurate results with single-precision floats. It certainly
seems as if the developers of the TradeStation function libraries did
not understand the effects of calculation precision on their
results... or didn't care...
We as customers, shouldn't even have to think about it...
A quick web search turned up a discussion of how another supplier of
a function library made sure it was accurate with the precision of
the floating point arithmetic:
<http://www.netlib.org/lapack/lug/node72.html>
There is a good tutorial on floating point arithmetic at:
<http://www.cs.utah.edu/~zachary/isp/applets/FP/FP.html>
and an interesting discussion of "The Perils of Floating Point" at:
<http://www.lahey.com/float.htm>
Bob Fulks
|