PureBytes Links
Trading Reference Links
|
This is not the fault of TradeStation but is caused by the way digital computers do arithmetic. There is always limited resolution so after a complex calculation, you are not likely to ever get exactly 2.000000000000.
Normally you never notice the "round-off errors" but if you use functions such as IntPortion you can get into trouble if you do not understand what is actually going on inside the calculation.
Do a Google search on "numerical analysis" to find lots of material on the topic.
Bob Fulks
At 10:31 PM 6/4/2004, Chris Cheatham wrote:
>I have been baffled as to why an indicator is behaving incorrectly at
>certain times, and have finally figured it out. There appears to be an
>incompatibility between the way numbers are stored in TS7 and intportion. I
>have a calculated value that is an even number on the first bar of the day.
>1, 2, 3, etc. What I have determined is that the calculated value that TS
>stores is not "2" but is 1.9999999999990905... OK, now apply intportion to
>this variable that is supposed to be 2 and you should get 2, but you don't,
>you get 1.
>
>My calc that arrives at the even #s is not difficult, I have stepped through
>it and found that the step that introduces the error is apparently adding an
>expression that equals 0 to a whole integer.
>
>OK, next I try rounding the value that is supposed to be 2 to eight decimal
>places....silly me...expect to get a whole number. The result of rounding is
>2.000004999999... At least it is over 2 now, so intportion works.
|