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

Re: Surely there is a better way



PureBytes Links

Trading Reference Links

They are identical:

Evaluate the absvalue(price1 - price2) < Ftol for both cases:

Case 1: Price1 > Price2

Price1 - Price2 < Ftol
Price1 - Ftol < Price2   {Add Price2 to both sides}

Case 2: Price1 < Price2

Price2 - Price1 < Ftol
Ftol > Price2 - Price1   {Reverse the inequality}
Ftol + Price1 > Price2   {Add Price1 to both sides}

To be true, both conditions must be true so:

IsItInProximity = Price1 - Ftol < Price2 and Ftol + Price1 > Price2

which is the other equation.

The AbsValue form is more transparent as to what you are doing and
easier to understand many months from now when you want to modify the
code. :-)

Bob Fulks


>Is there a better way of doing this and are the two
>caculations the same?  I seem to recall I had an issue with
>the second method.  I really hate to expose myself.
>
>{
>IsItInProximity()  return true/false if  Price1 is
>close enough to Price2 as defined by the input Tolerance value, using
>ATR to relativeize the distance.  This example is not tested.
>}
>
>input: Price1(numericseries), Price2(numericseries), tolerance(numeric);
>var:Ftol(0);
>Ftol = ATR*Tolerance;
>IsItInProximity =  Price1 - Ftol < Price2 and Price1 +  Ftol > Price2 ;
>IsItInProximity  = absvalue(price1 - price2) < Ftol;
>{eof}
>
>
>
>Regards,
>Ernie
>ebonugli@xxxxxxxx