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

Re: Indicator works in TS4 but not in TS2000



PureBytes Links

Trading Reference Links

Hello all,

after having problems with division by Zero, I changed the "pnt2line"
function a little:

**********************************************
{ Function: pnt2line
   returns the distance from (x,y) to the line formed by (x1,y1) (x2, y2) }
   corrected for Division by Zero problem by Herfried Rossmeissl,
11/16/2000}

input: x1(numericsimple), y1(numericsimple),
          x2(numericsimple), y2(numericsimple),
          x(numericsimple),   y(numericsimple);

var: qq(0), m1(0), m2(0);

value1 = 0;

if x-x2 <> 0
 and x1-x2 <> 0
 then begin
 m1 = (y1-y2) / (x1-x2);
 m2 = (y-y2) / (x-x2);
 if 1 + m1*m2 <> 0 then begin
  qq = SquareRoot(Square(y-y2)+Square(x-x2));
  value1 = qq * sine( arctangent( (m2-m1) / (1 + m1*m2)));
 end;
end;

pnt2line = value1;

******************************************************

> {Function: pnt2line}
>
> input: x1(numericsimple), y1(numericsimple),
>           x2(numericsimple), y2(numericsimple),
>           x(numericsimple),   y(numericsimple);
>
> { returns the distance from (x,y) to the line formed by (x1,y1) (x2, y2) }
>
> var: qq(0), m1(0), m2(0);
>
> if x-x2 <> 0 then begin
> m1 = (y1-y2) / (x1-x2);
> m2 = (y-y2) / (x-x2);
> qq = SquareRoot(Square(y-y2)+Square(x-x2));
> value1 = qq * sine( arctangent( (m2-m1) / (1 + m1*m2)));
> end else
> value1 = 0;
>
> pnt2line = value1;
>