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

RE: Precision Errors



PureBytes Links

Trading Reference Links

Clever solution by Bob Fulks, but this one could produce  average jumps if
the mod function triggers after the TS Float (name it like you want)
precision is reached before.
This could be the case for example if you perform average calculation on
volume...

 This is an example of how a tiny bit of attention to detail by Omega Users
too
 could   greatly reduced the numerical errors.


A modification like this one should solve:


{ *******************************************************************

   Study       : AverageWC

   Last Edit   : Tonight
   Provided By : PO

     No © By Sirtrade Intl. www.sirtrade.com

********************************************************************}
inputs: Price(NumericSeries), Length(NumericSimple) ;
vars  : Sum(0), Counter(0) ;

if sum> = 9999999- 2*price
{ please check the acceptable precision limit according to your own TS
precision belief}
then begin
   Sum = 0;
   for counter = 0 to Length - 1
   begin
      Sum = Sum + Price[counter];
   end;
end
else
   Sum = Sum[1] + Price - Price[Length];
if Length > 0 then
   AverageWC = Sum / Length
else
   AverageWC = 0;


Sincerely,

Pierre Orphelin
www.sirtrade.com
TradeStation Technologies representative in France






> -----Message d'origine-----
> De : Bob Fulks [mailto:bfulks@xxxxxxxxxxxx]
> Envoyé : jeudi 19 juillet 2001 23:56
> À : Mark Jurik
> Cc : omega-list@xxxxxxxxxx
> Objet : RE: Precision Errors
>
>
> At 1:28 PM -0600 7/19/01, Mark Jurik wrote:
>
> >There are two ways to handle this, improve precision (not the
> Omega way) or write sophisticated algorithms (also not the Omega way).
>
> Actually there is an even simpler way that requires modifying only
> one line of the Omega code (see below).
>
> I replaced:
>
>     if currentbar = 1
>
> with:
>
>     if Mod(currentbar, 100) = 1
>
> to cause the routine to recalculate it accurately every 100 bars but
> still use the fast calculation on the other 99 bars. This eliminates
> the error buildup with less than a 1% decrease in speed.
>
> This is an example of how a tiny bit of attention to detail by Omega
> could have greatly reduced the numerical errors.
>
> Bob Fulks
>
>
> { *******************************************************************
>
>    Study       : AverageAC
>
>    Last Edit   : 10/7/98
>
>    Provided By : Bob Fulks
>
>       © 1998 Bob Fulks, All rights reserved.
>
> ********************************************************************}
> inputs: Price(NumericSeries), Length(NumericSimple) ;
> vars  : Sum(0), Counter(0) ;
>
> if Mod(currentbar, 100) = 1
> then begin
>    Sum = 0;
>    for counter = 0 to Length - 1
>    begin
>       Sum = Sum + Price[counter];
>    end;
> end
> else
>    Sum = Sum[1] + Price - Price[Length];
> if Length > 0 then
>    AverageAC = Sum / Length
> else
>    AverageAC = 0;
>