PureBytes Links
Trading Reference Links
|
I have been using the following code that I downloaded a while ago
for breakouts. First I would like to thank the author of the code
as I have found it be invaluable. What I have noticed is that a lot
of the stocks I have been watching have channeled between the upper
and lower support and resistance lines. I would like a way to know
when a stock hits either of these lines so that I can decide if I
want to go long or short the stock. I am at a loss as to how to go
about coding this. Any help would be much appreciated.
ron
/*HISTORICAL TRENDLINES and BREAKOUTS*/
x = Cum(1);
per = 3;// CALIBRATE THE ZIG() SENSITIVITY
s1=L;s11=H;
pS = TroughBars( s1, per, 1 ) == 0;
endt=SelectedValue(ValueWhen( pS, x ,1));
startt=SelectedValue(ValueWhen( pS, x ,2));
dtS =endt-startt;
endS = SelectedValue((ValueWhen( pS, s1,1) ));
startS = SelectedValue(( ValueWhen( pS, s1 ,2)));
aS = (endS-startS)/dtS;bS = endS;
trendlineS = aS * ( x -endt ) + bS;//SUPPORT LINE
pR = PeakBars( s11, per, 1 ) == 0;
endt1= SelectedValue(ValueWhen( pR, x, 1));
startt1=SelectedValue(ValueWhen( pR, x, 2 ));
dtR =endt1-startt1;
endR = SelectedValue(ValueWhen( pR, s11, 1 ) );
startR = SelectedValue( ValueWhen( pR, s11, 2 ));
aR = (endR-startR)/dtR;bR = endR;
trendlineR = aR * ( x -endt1 ) + bR;//RESISTANCE LINE
first=Min(startt,startt1);Last=Max(endt,endt1);
d=10;// INCREASE d TO EXTEND THE LINES
bullishbreakout=x>endt1 AND x<last+d AND Cross(C,trendlineR);
bearishbreakout=x>endt AND x<last+d AND Cross(trendlineS,C);
Plot(C,"Close",IIf(bullishbreakout,colorBrightGreen,IIf
(bearishbreakout,colorRed,colorBlack)),64);
Plot(IIf(x>=first -d AND x<=Last+d,trendlineS,-
1e10),"Support",colorBrightGreen,1);
Plot(IIf(x>=first-d AND x<=Last+d,trendlineR,-
1e10),"Resistance",colorRed,1);
//Just move your cursor to the left, it will help to Study the recent
// behavior.
//The same procedure may be used for indicators [some slight per
//changes are
//necessary]
------------------------ 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/
|