home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
t
/
tas412.zip
/
H&S.TAS
< prev
next >
Wrap
Text File
|
1991-11-14
|
3KB
|
90 lines
{ H&S.TAS
Head and Shoulders recognition script.
Note : This script requires TAS 4.08 or later to run
This script will locate a "head and shoulders" pattern
in the closing prices. It will also draw a graph of the
closing price array along with a line drawn across the
neckline of the h&s formation.
The script presently does not locate the h&s with a volume
filter. That will be added at some point.
Author : Martin Moore
Date : Oct 1991
Revision 1.0 - Original script
Revision 1.1 - Modified to take account of the angle of the
neckline. Command line parameter @NeckAngle=n
will set the angle under which the H&S is
considered selected.
Modified to eliminate those cases where the
left shoulder is beyond the first day of data.
Modified to find first trough between right
shoulder and head.
Invocation:
TAS H&S tickername @NG=g; NeckAngle=n, CutOff=f
where 'g' is 1 if no graphs are to be produced
'n' is the angle under which the neckline must
be drawn
'f' is the ZigZag percentage movement to draw on
the closing prices
}
#max_quotes 200
#output_file h&s.lst
ziga is an array;
neckline is an array;
if cutoff = 0 then
cutoff = 5;
if NeckAngle = 0 then
NeckAngle = 3;
ziga = zig(c,cutoff,'%');
pkr = peak(ziga,1);
pkh = peak(ziga,2);
pkl = peak(ziga,3);
nopeak = -(quote_count)+1;
{ Make sure that all peaks are found..if no peak found, then
peak returns a positive number, otherwise it returns the
days in the past that the peak occurred at. Also, check to
be sure that we have all three peaks.}
if (pkr = nopeak) or (pkh = nopeak) or (pkl = nopeak) then
return;
cr = c[pkr]; { close price on right shoulder}
ch = c[pkh]; { close price on head }
cl = c[pkl]; { close price on left shoulder}
if (cl < ch) and (ch > cr) then {we have a H & S}
begin
trough_number = 0;
trr = 0;
while (pkr < trr)
begin
trough_number = trough_number+1;
trr = trough(ziga,trough_number);
end;
trl = trough(ziga,trough_number+1);
ctrr = c[trr]; { close on right shoulder trough}
ctrl = c[trl]; { close on left shoulder trough}
dydx = (ctrl-ctrr)/(trl-trr);
{ Create a line parallel to the neckline so we can use the
angle function}
for i = 1; i <= quote_count; i = i+1;
neckline[i] = dydx * i;
angleOfneckline = angle(neckline);
{ Skip those with too steep a neckline angle}
if (angleOfneckline > NeckAngle) or (angleOfneckline < -NeckAngle)
then return;
{writeln(ticker,dydx,angle(neckline));}
if NG = 1 return;
opengraph(3);
sizegraph(5,1,1)
graph(1,ziga);
{drawline(15,trl,ctrl,trr,ctrr);}
drawline(15,trl,ctrl,trr,ctrr,trl-10,0); { FOR TAS 5.0 only}
graph(v,'volume',tsf(v,5),'Volume TSF');
graph(obv(),'On Balance Volume');
closegraph();
end;