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

Re: [amibroker] Re: HighestSince function



PureBytes Links

Trading Reference Links

Hope DT hasn't already done this one, but his work in automated angled
sup/res lines got me to thinking drawing angled Fibonacci levels. The built
in fib tool is good, but only uses horizontal lines, so I thought I would do
one for any pair of drawn lines.

Just draw 2 lines on the price chart and name them F1 and F2 in the line
properties window. You can add or delete lines, change % and colours just
using the fibline statement per the last few lines of the code.

Plot(C,"",colorBlack,styleBar);

Upper=ValueWhen(NOT IsNull( Study("f1",GetChartID())
),Study("f1",GetChartID()));
Lower=ValueWhen(NOT IsNull(
Study("f2",GetChartID())),Study("f2",GetChartID()));

TLB = ValueWhen( Upper AND IsNull(Ref(Upper,-1)), BarIndex());
TLP = ValueWhen( Upper AND IsNull(Ref(Upper,-1)), Upper );
TRB = ValueWhen( Upper ==LastValue(Upper), BarIndex());
TRP = ValueWhen( Upper ==LastValue(Upper), Upper );

BLB = ValueWhen( Lower AND IsNull(Ref(Lower,-1)), BarIndex());
BLP = ValueWhen( Lower AND IsNull(Ref(Lower,-1)), Lower );
BRB = ValueWhen( Lower ==LastValue(Lower), BarIndex());
BRP = ValueWhen( Lower ==LastValue(Lower), Lower );

procedure FibLine(x,y)
{
LB = LastValue( BLB+(TLB-BLB)*x );
RB = LastValue( BRB+(TRB-BRB)*x );
LP = LastValue( BLP+(TLP-BLP)*x );
RP = LastValue( BRP+(TRP-BRP)*x );
Line = LineArray( LB, LP, RB, RP ,0 );
Plot( Line, "Line "+(x*100)+"%", y, styleLine);
}

FibLine(0.5,colorRed);
FibLine(0.618,colorBlue);
FibLine(0.382,colorGreen);
FibLine(1.618,colorRed);
FibLine(-0.618,colorRed);


Cheers,
Graham
http://e-wire.net.au/~eb_kavan/




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
     amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/