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

RE: Warning about accuracy of Array functions in TS2000i



PureBytes Links

Trading Reference Links

At 10:51 AM -0500 3/17/00, M. Simms wrote:
>
>I "HEAR" everyone, but can someone "SHOW ME" how significant the difference
>is ?


Take a look at the series version of the simple moving average function.

The code says:

   Sum = Sum[1] + Price - Price[Length];

Do this for 20000 bars with a price equal to the DJIA at about 10000 and see what kind of errors you get.

There are a lot of functions such as this that save calculations by dropping off the old value and adding the new value for the new bar. Errors can easily accumulate to be very significant, especially if square of price is involved..

This can be helped a lot by very simple tricks. For example, in the Average function where they said:

  if CurrentBar = 1 then begin

if they instead said:

  if Mod(CurrentBar, 100) = 1 then begin

they would force the function to re-initialize the value every 100 bars, which would eliminate most errors with a negligible increase in processing time.

I have posted lots of examples in the past but cannot find one right now.

Believe me, the 16 bit accuracy is very marginal and it requires effort to avoid problems. I happened to be working on a problem for the past two days that I just discovered was caused by numerical calculation errors.

Bob Fulks