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

[amibroker] H&S targets



PureBytes Links

Trading Reference Links




^OSX gives a good example of both H&S and inverted H&S 
pattern.
Here is the full code for indicator builder
 
x = Cum(<FONT 
size=2>1<FONT 
face="Times New Roman">);<FONT 
face="Times New Roman">
per = 5<FONT face=Verdana 
size=2><FONT 
face="Times New Roman">;<FONT 
face="Times New Roman">
back=100<FONT face=Verdana 
size=2><FONT 
face="Times New Roman">;<FONT 
face="Times New Roman">
inter=200<FONT face=Verdana 
size=2><FONT 
face="Times New Roman">;<FONT 
face="Times New Roman">
s11=H;s12=L;R=0;RR=<FONT 
size=2>0<FONT 
face="Times New Roman">;
 
/* H & S */
 <FONT 
face="Times New Roman">
pR = PeakBars( s11, per, 
1 ) == 0<FONT 
face=Verdana size=2><FONT 
face="Times New Roman">;<FONT 
face="Times New Roman">
endt1= LastValue<FONT 
size=2>(ValueWhen( pR, x, R+<FONT 
size=2>1<FONT 
face="Times New Roman"> ));<FONT 
face="Times New Roman">
medt1=LastValue(<FONT 
size=2>ValueWhen( pR, x, R+2<FONT 
face=Verdana size=2><FONT 
face="Times New Roman">));<FONT 
face="Times New Roman">
startt1=LastValue<FONT 
size=2>(ValueWhen( pR, x, R+<FONT 
size=2>3<FONT 
face="Times New Roman"> ));
<FONT 
face="Times New Roman">dt1=endt1-startt1;
C1=x==endt1 OR x==medt1 OR 
x==startt1;
endR = LastValue<FONT 
size=2>(ValueWhen( pR, s11, 
R+1<FONT 
face="Times New Roman"> ) );<FONT 
face="Times New Roman">
medR=LastValue(<FONT 
size=2>ValueWhen( pR, s11, R+<FONT 
size=2>2<FONT 
face="Times New Roman"> ) );<FONT 
face="Times New Roman">
startR = LastValue( 
ValueWhen( pR, s11, R+<FONT 
size=2>3<FONT 
face="Times New Roman"> ));<FONT 
face="Times New Roman">
Filter1=medR>endR AND medR>startR AND <FONT 
size=2>abs(startR-endR)<<FONT 
size=2>0.02<FONT 
face="Times New Roman">*(startR+endR) <FONT 
face="Times New Roman">AND
 
dt1<inter AND endt1>LastValue<FONT 
face=Verdana size=2><FONT 
face="Times New Roman">(x)-back;
 
MaxGraph=12<FONT 
size=2>;Graph1=C;Graph1Style=64<FONT 
size=2>;GraphXSpace=5<FONT face=Verdana 
size=2><FONT 
face="Times New Roman">;
 
/*H&S Neck 
Line*/
 
<FONT 
face="Times New Roman">Aper=medt1-startt1;bper=endt1-medt1;<FONT 
face="Times New Roman">
La= LastValue(<FONT 
size=2>ValueWhen(x==medt1,<FONT 
size=2>LLV<FONT 
face="Times New Roman">(L,Aper)));<FONT 
face="Times New Roman">
Lb=LastValue(<FONT 
size=2>ValueWhen(x==-1<FONT 
size=2>+endt1,LLV<FONT face=Verdana 
size=2><FONT 
face="Times New Roman">(L,bper)));
Fa=L==La AND x>startt1 AND 
x<medt1;
Fb=L==Lb AND x>medt1 AND 
x<endt1;
endt= LastValue(<FONT 
size=2>ValueWhen<FONT 
face="Times New Roman">( Fb, x ));<FONT 
face="Times New Roman">
startt=LastValue<FONT 
size=2>(ValueWhen<FONT face=Verdana 
size=2>( Fa, x 
));
dtS =endt-startt;endS = Lb;startS = 
La;
aS = (endS-startS)/dtS;bS = 
endS;
trendlineS = aS * ( x -endt ) + bS; 

 
Graph3 = IIf(Filter1 AND 
x>startt-5,trendlineS,-<FONT 
size=2>1e10);Graph3BarColor=<FONT 
size=2>7<FONT 
face="Times New Roman">;
 
/*Inverted H & 
S*/
 <FONT 
face="Times New Roman">
tpR = TroughBars( s12, per, 
1 ) == 0<FONT 
face=Verdana size=2><FONT 
face="Times New Roman">;<FONT 
face="Times New Roman">
tendt1=LastValue<FONT 
size=2>(ValueWhen(tpr,x,RR+<FONT 
size=2>1<FONT 
face="Times New Roman">));<FONT 
face="Times New Roman">
tmedt1=LastValue<FONT 
size=2>(ValueWhen(tpr,x,RR+<FONT 
size=2>2<FONT 
face="Times New Roman">));<FONT 
face="Times New Roman">
tstartt1=LastValue<FONT 
size=2>(ValueWhen(tpr,x,RR+<FONT 
size=2>3<FONT 
face="Times New Roman">));
<FONT 
face="Times New Roman">tdt1=tendt1-tstartt1;
C2=x==tendt1 OR x==tmedt1 OR 
x==tstartt1;
tendR = LastValue<FONT 
size=2>(ValueWhen( tpR, s12, 
RR+1<FONT 
face="Times New Roman"> ) );<FONT 
face="Times New Roman">
tmedR=LastValue(<FONT 
size=2>ValueWhen( tpR, s12, RR+<FONT 
size=2>2<FONT 
face="Times New Roman"> ) );<FONT 
face="Times New Roman">
tstartR = LastValue( 
ValueWhen( tpR, s12, RR+<FONT 
size=2>3<FONT 
face="Times New Roman"> ));
Filter2=tmedR<tendR AND 
tmedR<tstartR AND
 <FONT 
face="Times New Roman">
abs(tstartR-tendR)<<FONT 
size=2>0.02<FONT 
face="Times New Roman">*(tstartR+tendR) AND tdt1<inter 
AND
tendt1>LastValue<FONT face=Verdana 
size=2><FONT 
face="Times New Roman">(x)-back;
 
/*Inverted H&S Neck 
Line*/
 
<FONT 
face="Times New Roman">tAper=tmedt1-tstartt1;tbper=tendt1-tmedt1;<FONT 
face="Times New Roman">
Ha= LastValue(<FONT 
size=2>ValueWhen(x==tmedt1,<FONT 
size=2>HHV<FONT 
face="Times New Roman">(H,tAper)));<FONT 
face="Times New Roman">
Hb=LastValue(<FONT 
size=2>ValueWhen(x==-1<FONT 
size=2>+tendt1,HHV<FONT face=Verdana 
size=2><FONT 
face="Times New Roman">(H,tbper)));
tFa=H==Ha AND x>tstartt1 AND 
x<tmedt1;
tFb=H==Hb AND x>tmedt1 AND 
x<tendt1;
Rendt= LastValue<FONT 
size=2>(ValueWhen<FONT face=Verdana 
size=2>(tFb, x 
));
Rstartt=LastValue<FONT 
size=2>(ValueWhen<FONT face=Verdana 
size=2>( tFa, x 
));
Rdt =Rendt-Rstartt;endR = Hb;startR = 
Ha;
aR = (endR-startR)/Rdt;bR = 
endR;
trendlineR = aR * ( x -Rendt ) + bR; 

 
Graph4 = IIf(Filter2 AND 
x>Rstartt-5,trendlineR,-<FONT 
size=2>1e10);Graph4BarColor=<FONT 
size=2>10<FONT 
face="Times New Roman">;
Filter=Filter1 OR 
Filter2;
 
NumColumns=8<FONT face=Verdana 
size=2>;
Column0=Filter1;
 
<FONT 
face="Times New Roman">Column1=Filter2;<FONT 
face="Times New Roman">
Column0Format=Column1Format=1.0<FONT 
face=Verdana size=2><FONT 
face="Times New Roman">;
 
Column0Name="H&S"<FONT face=Verdana 
size=2><FONT 
face="Times New Roman">;<FONT 
face="Times New Roman">
Column1Name="inv H&S"<FONT 
face=Verdana size=2><FONT 
face="Times New Roman">;
g3=Graph3;
g4=Graph4;<FONT 
face="Times New Roman">
upcr=filter2 AND Cross<FONT face=Verdana 
size=2>(C,trendlineR) AND 
x>tendt1;
dncr=filter1 AND Cross<FONT face=Verdana 
size=2>(trendlineS,C) AND 
x>endt1;
 
/*H&S 
target*/
 <FONT 
face="Times New Roman">
diff1=ValueWhen<FONT face=Verdana 
size=2><FONT 
face="Times New Roman">(x==medt1,C-trendlineS);
<FONT 
face="Times New Roman">target1=trendlineS-diff1;<FONT 
face="Times New Roman">
target1cross=Cross<FONT face=Verdana 
size=2>(target1,C) AND 
Filter1;
 
Graph5=IIf(filter1 AND 
x>endt1,target1,-1e10<FONT face=Verdana 
size=2><FONT 
face="Times New Roman">);<FONT 
face="Times New Roman">
Graph5Style=8<FONT 
size=2>;Graph5BarColor=7<FONT face=Verdana 
size=2><FONT 
face="Times New Roman">;
 
/*Inverted H&S 
target*/
 <FONT 
face="Times New Roman">
diff2=ValueWhen<FONT face=Verdana 
size=2><FONT 
face="Times New Roman">(x==tmedt1,trendlineR-C);
<FONT 
face="Times New Roman">target2=trendlineR+diff2;<FONT 
face="Times New Roman">
target2cross=Cross<FONT face=Verdana 
size=2>(C,target2) AND 
Filter2;
 
Graph6=IIf(Filter2 AND 
x>tendt1,target2,-1e10<FONT 
size=2>);Graph6Style=8<FONT 
size=2>;Graph6BarColor=10<FONT face=Verdana 
size=2><FONT 
face="Times New Roman">;<FONT 
face="Times New Roman">
Graph1BarColor=IIf(C1 AND 
Filter1,7,<FONT 
size=2>IIf(C2 AND Filter2,10<FONT 
size=2>,IIf(upcr OR 
target2cross,5,<FONT 
size=2>IIf(dncr OR target1cross,<FONT 
size=2>4,1<FONT 
face=Verdana size=2><FONT 
face="Times New Roman">))));
 
The recent situation 
helped the inv. H&S to confirm its properties, break the neckline and reach 
the H&S target.
Enjoy 
!!
Dimitris 
Tsokakis
 






Yahoo! Groups Sponsor


  ADVERTISEMENT









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:
h&s.gif

Attachment: Description: "Description: GIF image"