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

[amibroker] Parallel channels automatic selection



PureBytes Links

Trading Reference Links




Parallel channels as exposed at <A 
href="">http://www.amibroker.com/library/detail.php?id=105 may 
be defined by
*the basic Support line and the HighestBetween 
point
*the basic resistance line and the  LowestBetween 
point
Which one is better for the recent stock history 
?
The slope of the channel will be compared to the Linear 
regression slope and this criterion will define the primary
and the secondary channel. For easy reading, the primary 
channel is painted yellow and the secondary is Grey40.
The linear regression line has different slope 
according to the daysback parameter.
The trendlines have a startt/startt1 according to the zig 
period per.
A simple solution was to ask daysback=min(startt, 
startt1)
In some cases this decision gives excellent results : the 
linreg line is the middle line of the channel.
Of course this is the ideal case and we shall not meet it 
everyday.
Sometimes both channel slopes are in disagreement to the main 
linearreg slope. In this case [CPWR] it is better to wait
for the next pattern.
Here is the Indicator Builder code
 
// Automatic channel selectionper = 3;// sensitivity 
calibrationx = Cum(1);s1=L;s11=H; Plot(C,"Close",1,64);// 
SUPPORT DEFINED CHANNELpS = TroughBars( s1, per, 1 ) == 0;endt= 
LastValue(ValueWhen( pS, x, 1 ));startt=LastValue(ValueWhen( pS, x, 2 
));dtS =endt-startt;endS = LastValue(ValueWhen( pS, s1, 1 ) );startS 
= LastValue( ValueWhen( pS, s1, 2  ));aS = (endS-startS)/dtS;bS = 
endS;trendlineS = aS * ( x  -endt ) + bS; 
H1=LastValue(Highest((Cum(1)>startt AND 
Cum(1)<endt)*H));tH1=LastValue(ValueWhen(H==H1,Cum(1)));UpperParallel=aS*(x-tH1)+H1;
 
// RESISTANCE DEFINED CHANNELpR = PeakBars( s11, per, 1 ) 
== 0;endt1= LastValue(ValueWhen( pR, x, 1 
));startt1=LastValue(ValueWhen( pR, x, 2 ));dtR =endt1-startt1;endR 
= LastValue(ValueWhen( pR, s11, 1 ) );startR = LastValue( ValueWhen( pR, 
s11, 2  ));aR = (endR-startR)/dtR;bR = endR;trendlineR = aR * ( 
x  -endt1 ) + bR; L1=LastValue(Lowest(IIf(Cum(1)>startt1 AND 
Cum(1)<endt1,L,10^10)));tL1=LastValue(ValueWhen(L==L1,Cum(1)));LowerParallel=aR*(x-tL1)+L1;
 
// LINEAR REGRESSION LINElastx = LastValue( x ); 
Daysback = lastx-Min(startt,startt1);aa = LastValue( LinRegIntercept( 
Close, Daysback) );bb = LastValue( LinRegSlope( Close, Daysback ) );y = 
Aa + bb * ( x - (Lastx - DaysBack) ); Plot( IIf( x >= (lastx - 
Daysback-10), y, -1e10 ), "LinReg", colorRed,8 );
 
// 
SELECTIONColorS=IIf(bb*aS>0,colorYellow,colorGrey40);Plot(IIf(x>Min(startt,startt1)-10,trendlineS,-1e10),"Support",colorS,1);Plot(IIf(x>Min(startt,startt1)-10,UpperParallel,-1e10),"UpperLine",colorS,1);ColorR=IIf(bb*aR>0,colorYellow,colorGrey40);Plot(IIf(x>Min(startt,startt1)-10,trendlineR,-1e10),"Resistance",colorR,1);Plot(IIf(x>Min(startt,startt1)-10,LowerParallel,-1e10),"LowerLine",colorR,1);
 
Dimitris Tsokakis






Yahoo! Groups Sponsor


  ADVERTISEMENT<img
src="" width=300 height=250 border=0>  









Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



Attachment:
selection.gif

Attachment: Description: "Description: GIF image"