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

Re: Extracting Value from an expression



PureBytes Links

Trading Reference Links

The only way I know is to do trail and error. Since
the number you are looking for is an integer it
becomes a little easier. You can use a FOR loop to go
from XBar=1 to 100 and find the closest value you will
get for the angle.
Something like:

nputs:TLAng(45);
Vars:XBar(3),LeftBar(1);
Vars: temp(0), result(0); 
LeftBar=HighestBar(Osc,10);

temp = AbsValue(ArcTangent( (Osc[1]-Osc[LeftBar]) /
(LeftBar - 1) ));
result = 1;
For XBar = 2 to 100 Begin
   if AbsValue(ArcTangent( (Osc[XBar]-Osc[LeftBar]) /
(LeftBar - XBar))) < temp then begin
      result = XBar;
      temp = AbsValue(ArcTangent(
(Osc[XBar]-Osc[LeftBar]) / (LeftBar - XBar)));
   end;
end;


Once the loop finishes, it will have in the variable
'Result' the number for XBar that makes the formula
the closest to your desired angle. Where XBar is
anything from 1 to 100. 
Note I did not have a chance to test this myself so
there might be some error, but it should send you in
the right direction. 

Good Luck,

H

--- L'Alchimista <l.alchimista@xxxxxx> wrote:
> I'm trying to calculate the value of a trend line
> which angle is TLAng .
> The problem : how can I extract the value XBar from
> the expression below ?
> 
> Inputs:TLAng(45);
> Vars:XBar(3),LeftBar(1);
> 
> LeftBar=HighestBar(Osc,10);
> 
> ArcTangent( (Osc[XBar]-Osc[LeftBar]) / (LeftBar -
> XBar) ) = TLAng ;
> 
> 
> 
> 
>