home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1993 #2
/
Image.iso
/
finance
/
tas515dm.zip
/
EXAMPLES.ZIP
/
BASE-NH.TAS
< prev
next >
Wrap
Text File
|
1992-11-30
|
18KB
|
461 lines
{BASE-NH.TAS *Written 11/28/92 by Tom Rategan -Prodigy PMGV10A
*Originally written 3/18/92. Script saw numerous
revisions and improvements, which were documented
prior to this version. Changes eventually made much
of the original monolog obsolete, so the following
monolog reflects only the script as it is now. The
evolution of the script is no longer documented
here. Oh well <g>....
This script is geared toward investors who like to buy stocks which are
showing unusual strength, with an emphasis on stocks emerging from
price consolidation or "basing" patterns. There are four situations which
the script will find:
1) Stocks closing at new 52 week highs, or closing at a 52 week
high which has been tested before.
2) Stocks closing within 5% of their 52 week high, which have also
been in a basing pattern for a minimum of 6 weeks (30 days).
3) Stocks which close more than 5% off their 52 week high, but
which have broken out of some sort of basing pattern.
4) Stocks which are below their yearly high, but which close
higher than any close in the prior 50 days.
Any base which the script finds will be defined with red lines on
the stock's graph, and the dimensions of the base are given on top of
the graph. Any stock which is making a 10+ week high but is below its
yearly high, will be graphed with a grey resistance line extending from
today to the last time the price was at today's level. The line will
be at the level of the next highest close during the period, making it
easier to see what resistance was broken with today's close. In cases
where the script is unable to find a base, the top of the graph will
report how long the stock has traded within a 15% range.
In searching for a basing pattern, the script looks for the longest,
tightest (narrowest trading range) possible bases first, then it
gradually loosens the search to consider shorter, looser bases. Any base
initially found is tested for validity. To pass the test, the HIGH price
of the stock must come to within 4% of the upper resistance line, at
some point during the first 1/3 of the base period. So if the script
finds a stock with a possible 15% base for 12 weeks, it checks if the
stock's HIGH price nearly tested (4% forgiveness) the upper resistance
line of the base, at some time in the first 4 weeks (ending 8 weeks ago).
If the first possible base found does not pass the test, the script will
continue to search and test other possibilities until its list of
acceptable pre-defined base parameters is exhausted.
The volume graph tells today's volume, the value of the 50VMA, and
how today's volume compares with the 50VMA. It then tells how each of
the 4 prior weeks (actually 5 day periods) compares to the 50VMA. Each
"week" is compared to the value of the 50VMA on the day before the
week began. So "W1" averages the prior 5 days (5 days ago through
yesterday) and compares that average to the value of the 50VMA 6 days
ago- the day before the "week" began. "W2" averages the volume from
10 days ago through 6 days ago, and compares that to the 50VMA 11 days
ago. "W3" and "W4" are similarly figured.
The last graph is a volume UP/DOWN graph. U/D ratio is the ratio
of the sum of all volume on days when the price was up, to the sum of
all volume on days when the price was down. Attempts to show whether
a stock is seeing accumulation or distribution. A ratio of 1.0 means
that there is an even balance of buying pressure and selling pressure.
A value above 1.0 indicates buying pressure, a value below 1.0
indicates selling pressure.
The U/D is computed a unique way in this script. It attempts to show
accumulation and distribution effectively, while filtering out the
exagerations and distortions which U/D ratios can be subject to due
to periods of extreme volume.
40 days are used in computing the ratio. The "average price
weighted toward the close" ( (H+L+C)/3 ) is used to determine whether
the price was up or down from day to day. If more than 200% of the 40 day
MA is traded, then only 200% of the average volume is added to the
up side or the down side. In other words, there is a ceiling of 200%
of normal volume which can be used in the U/D calculation. If a stock
trades 300%, 700%, 1000% or more of its 40 day average volume, then
only 200% of the 40MA on the day the volume took place is added.
The legend on top of the U/D graph shows the current U/D, the change
from yesterday, the percent of time in the past 40 days the ratio was
greater than 1, and how many days ago the last cross of the 1 line
took place. The percent above 1 figure is helpful if the ratio has been
very close to the 1 line for awhile and it's difficult to tell which
side it has been on more of the time. The 40U/D graph also gives the
value of the the standard 50U/D. That is, 50 days used, close alone
determines whether price was up or down, and no filtering of extreme
volume. It can be interesting to see how the value compares to the
modified 40 U/D value.
Most data is printed to the screen during scanning, and is saved
in the output file "BASE-NH.LST". Stocks found which are breaking out
of a base and are also making a 10+ week high which is more significant
than the base period indicates, are listed with an asterisk (*) next
to the base period figure. Also, if a stock closes at a new high,
as opposed to a price which it has closed at before, the screen will
report NH. If the close is a yearly high but not a new high, it is
reported as 0% off high.
There are three "switches" which allow you to customize the script
to your preferences.
The GRAPH_SWITCH allows you to turn off the graph feature, for
unattended running of the script. Stocks found will only be listed to
the screen and saved in the output file, and the script will not stop
until it is finished with the ticker list.
The HIBASE_ONLY_SWITCH can be set to find only stocks at or near
new highs, or else it will also find base breakouts and 10+ week
highs reguardless of where the stock is relative to it's yearly high.
The UD_GRAPH_SWITCH can be set to turn off the 40U/D graph, and only
show the price and volume graphs. This may be attractive because the
U/D graph takes alot of time to compute, so turning it off will reduce
scanning time. If it is turned off, the standard 50U/D value (which is
very quick to compute) will appear in the volume graph, as well as on
the screen during scanning.
}
GRAPH_SWITCH = 1; { <<<<<< '1' SHOWS GRAPHS, '0' TURNS OFF GRAPHS}
HIBASE_ONLY_SWITCH = 0; { <<<<<< '1' FINDS ONLY HI BASES, 0 FINDS LO BASE}
{BREAKOUTS ALSO}
UD_GRAPH_SWITCH = 1; {<<<<< '0' TURNS OFF 40U/D GRAPH AND INDICATES 50U/D}
{VALUE ONLY, '1' TURNS ON 40U/D GRAPH}
#max_quotes 255
#output_file 'BASE-NH.LST'
if first_ticker then begin
if hibase_only_switch = 1 then goto hi_header;
writeln(
' **** New highs, high bases, 10+ week highs, & low base breakouts ****
');
goto next_ln;
:hi_header
writeln(
' ******* New highs and possible near base breakouts *******
');
:next_ln
if ud_graph_switch = 1 then goto write_with_40;
writeln(
' 52 Week |--Base-| 50')
;goto next_line;
:write_with_40
writeln(
' 52 Week |--Base-| 40')
;
:next_line
writeln(
' Name Close Change %OH High %Rng Wks Vol %V U/D'
);
writeln(
' ---- ----- ------ --- ---- ---- ---- --- -- ---'
);
end;
if quote_count < 65 then return;
hiqc : array;
qc = (quote_count-2);
hiqc = hhv(c,qc);
if hibase_only_switch = 0 then goto lb_also;
if c < (hiqc*.95) then return;
:lb_also
hi30 : array;
hi30 = hhv(c,31-1);
if c[0] < (hiqc * .95) and c[0] <= hi30[-1] then return;
hi50_switch = 0;
hi40 : array;
hi40 = hhv(c,41-1);
hi50 : array;
hi50 = hhv(c,51-1);
hi60 : array;
hi60 = hhv(c,61-1);
if c[0] > hi50[-1] and c[0] < hiqc then hi50_switch = 1;
if hi30[0] > hi30[-1] then hv30 = hi30[-1] else hv30 = hi30[0];
if hi40[0] > hi40[-1] then hv40 = hi40[-1] else hv40 = hi40[0];
if hi60[0] > hi60[-1] then hv60 = hi60[-1] else hv60 = hi60[0];
lo30 : array;
lo30 = llv(c,30);
lo40 : array;
lo40 = llv(c,40);
lo60 : array;
lo60 = llv(c,60);
newhigh_switch = 0;
r30 = (1-(lo30/hv30))*100;
r40 = (1-(lo40/hv40))*100;
r60 = (1-(lo60/hv60))*100;
if hi50_switch =0 then goto find_base;
c50 = -50;
:count50
if c[c50] >= c[0] then goto x50;
c50 = c50 - 1; goto count50;
:x50
c50 = -(c50+1);
next50: array;
next50 = hhv(c,c50-1);
:find_base
nobase = 0;
btest = 0;
if r40 <= 2 then gosub b40;
if btest = 1 then goto stats2;
if r30 <= 2 then gosub b30;
if btest = 1 then goto stats2;
if r60 <= 4 then gosub b60;
if btest = 1 then goto stats2;
if r40 <= 4 then gosub b40;
if btest = 1 then goto stats2;
if r30 <= 4 then gosub b30;
if btest = 1 then goto stats2;
if r60 <= 6 then gosub b60;
if btest = 1 then goto stats2;
if r40 <= 6 then gosub b40;
if btest = 1 then goto stats2;
if r30 <= 6 then gosub b30;
if btest = 1 then goto stats2;
if r60 <= 8 then gosub b60;
if btest = 1 then goto stats2;
if r40 <= 8 then gosub b40;
if btest = 1 then goto stats2;
if r30 <= 8 then gosub b30;
if btest = 1 then goto stats2;
if r60 <= 10 then gosub b60;
if btest = 1 then goto stats2;
if r40 <= 10 then gosub b40;
if btest = 1 then goto stats2;
if r30 <= 10 then gosub b30;
if btest = 1 then goto stats2;
if r60 <= 12 then gosub b60;
if btest = 1 then goto stats2;
if r40 <= 12 then gosub b40;
if btest = 1 then goto stats2;
if r30 <= 12 then gosub b30;
if btest = 1 then goto stats2;
if r60 <= 14 then gosub b60;
if btest = 1 then goto stats2;
if r40 <= 14 then gosub b40;
if btest = 1 then goto stats2;
if r30 <= 14 then gosub b30;
if btest = 1 then goto stats2;
if r60 <= 16 then gosub b60;
if btest = 1 then goto stats2;
if r40 <= 16 then gosub b40;
if btest = 1 then goto stats2;
if r30 <= 15 then gosub b30;
if btest = 1 then goto stats2;
if r60 <= 18 then gosub b60;
if btest = 1 then goto stats2;
if r40 <= 18 then gosub b40;
if btest = 1 then goto stats2;
if r60 <= 20 then gosub b60;
if btest = 1 then goto stats2;
if r40 <= 20 then gosub b40;
if btest = 1 then goto stats2;
if r60 <= 25 then gosub b60;
if btest = 1 then goto stats2;
if r30 <= 16 then gosub b30;
if btest = 1 then goto stats2;
Nobase = 1;
if hi50_switch = 1 then goto newhigh;
if c[0] = hiqc then goto newhigh else return;
:b30
t = -30;
rng = r30;
lorg = lo30;
hirg = hv30;
goto count_days;
:b40
t = -40;
rng = r40;
lorg = lo40;
hirg = hv40;
goto count_days;
:b60
t = -60;
rng = r60;
lorg = lo60;
hirg = hv60;
goto count_days;
:newhigh
if c[0] = hiqc then newhigh_switch = 1;
t = 0;
lorg = c[0] * .85;
hirg = c[0];
:count_days
gosub count;
if t = -(qc) then goto stats;
if c[t] < lorg or c[t] > hirg then goto stats else goto count_days;
:count
t = t-1;
return;
:stats
t= -(t+1);
if t= -0 then t =0;
if nobase = 1 then goto stats2;
hi_rng : array;
lo_rng : array;
hi_rng = hhv(c,(t-1));
lo_rng = llv(c,t);
if hi_rng[0] <= hi_rng[-1] and c[0] < (hiqc*.95) then return;
if hi_rng[0] > hi_rng[-1] then rng = (1-(lo_rng/hi_rng[-1]))*100
else rng = (1-(lo_rng/hi_rng))*100;
basetest = -t; midbase = -t*.66; hbline = hi_rng[-1] *.96;
:basecheck
if basetest > midbase then return;
if h[basetest] >= hbline then btest = 1;
if btest = 1 then return;
basetest = basetest +1;
goto basecheck;
:stats2
if newhigh_switch = 1 then rng = 15;
if hi50_switch = 1 and nobase = 1 then rng = 15;
v50 : array;
v50 = mov(v,50,'s');
vv50 = ((v[0]/v50[-1])*100);
v1 = (v[-1]+v[-2]+v[-3]+v[-4]+v[-5])/5;
v1v50 = ((v1/v50[-6])*100);
v2 = (v[-6]+v[-7]+v[-8]+v[-9]+v[-10])/5;
v2v50 = ((v2/v50[-11])*100);
v3 = (v[-11]+v[-12]+v[-13]+v[-14]+v[-15])/5;
v3v50 = ((v3/v50[-16])*100);
v4 = (v[-16]+v[-17]+v[-18]+v[-19]+v[-20])/5;
v4v50 = ((v4/v50[-21])*100);
oh = 100-((c/hiqc)*100);
chg = c[0]-c[-1];
if ud_graph_switch = 0 then goto ud40_not;
v40 : array;
v40 = mov(v,40,'s');
ud2:array;
up2:array;
dn2:array;
maup2:array;
madn2:array;
vo : array;
vo = v;
up2[1]:=0; dn2[1]:=0;
for j := 2; j<= quote_count; j:=j+1;
begin
if j < 40 then v40[j] = v40[1];
if vo[j] >= (v40[j]*2) then vo[j] = (v40[j]*2);
py = (h[j-1]+l[j-1]+c[j-1])/3;
pt = (h[j]+l[j]+c[j])/3;
if pt > py then up2[j]:=vo[j] else
up2[j]:=0;
if pt < py then dn2[j]:=vo[j] else
dn2[j]:=0
end;
maup2:=Mov(up2,40,'s');
madn2:=Mov(dn2,40,'s');
ud2:=div(maup2,madn2);
ud_chg= ud2[0] - ud2[-1];
da= -40;
np = 0;
:check_perc_one
da = da + 1;
if da = 1 then goto perc_one;
if ud2[da]>=1 then np = np + 1;
goto check_perc_one;
:perc_one
p_one = (np/40)*100;
x_ago = 1;
:check_cross
x_ago = x_ago - 1;
if x_ago = -(quote_count-41) then goto graphit;
if ud2[x_ago] >1 and ud2[x_ago-1] <1 then goto graphit;
if ud2[x_ago]<1 and ud2[x_ago-1] >1 then goto graphit else goto check_cross;
:graphit
if x_ago <> 0 then x_ago = -(x_ago);
:ud40_not
av = 0;
dv = 0;
d = -51;
:loop
gosub countit;
if d = 0 then goto figure;
if c[d] < c[d+1] then av = av + v[d+1];
if c[d] > c[d+1] then dv = dv + v[d+1];
goto loop;
:countit
d = d + 1;
return;
:figure
ud = av/dv;
if graph_switch <> 1 then goto no_graph;
if ud_graph_switch = 1 then goto ud_yes;
opengraph(2);
sizegraph(5,2);
goto start_graph;
:ud_yes
opengraph(3);
sizegraph(6,2,2);
:start_graph
if hi50_switch = 1 and c50 <> t then goto hi50_graph;
graph(1,' '+format(c[0],'$%5.2f')+' is '+format(oh,'%2.1f%')
+' off '+format(hiqc[0],'$%5.2f')+' high. Change= '+format(chg,'$%2.2f')
+' Base '+
format(rng,'%2.1f%')+' for '+format((t/5),'%2.1f')+' weeks.');
goto lines;
:hi50_graph
graph(1,' '+format(c[0],'$%5.2f')+' is '+format(oh,'%2.1f%')
+' off '+format(hiqc[0],'$%5.2f')+' high. Change= '+format(chg,'$%2.2f')
+' Base '+
format(rng,'%2.1f%')+' for '+format((t/5),'%2.1f')+' weeks. '+format
((c50/5),'%2.1f')+' week high.');
:lines
if newhigh_switch = 1 then goto graphvol;
if hi50_switch = 0 then goto draw_base;
drawline(7,0,next50[-1],0,next50[-1],-c50,-1);
if nobase=1 then goto graphvol;
:draw_base
drawline(12,0,lorg,0,lorg,-t,-1);
drawline(12,0,hirg,0,hirg,-t,-1);
:graphvol
if ud_graph_switch = 1 then goto udg_yes;
graph(v,'Today='+format(v[0],'%5.f')+' 50MA='+format(v50[-1],'%5.f')
+' %Today='+format(vv50,'%4.f%')+' 50U/D='+format(ud,'%1.2f')
+' W1='+format(v1v50,'%3.f%')+' W2='+format(v2v50,'%3.f%')
+' W3='+format(v3v50,'%3.f%')+' of',v50,' 50MA.');
closegraph();
goto no_graph;
:udg_yes
graph(v,'Today='+format(v[0],'%5.f')+' 50MA='+format(v50[-1],'%5.f')
+' %Today='+format(vv50,'%4.f%')+' W1='+format(v1v50,'%3.f%')
+' W2='+format(v2v50,'%3.f%')+' W3='+format(v3v50,'%3.f%')
+' W4='+format(v4v50,'%3.f%')+' of',v50,' 50MA.');
graph(ud2,'40 U/D= '+format(ud2[0],'%1.2f')+' Change= '
+format(ud_chg,'%0.2f')+' Above ONE (40 Days)= '+format(p_one,'%2.f%')
+' Last Cross '+format(x_ago,'%1.f')+' Days Ago. 50U/D= '
+format(ud,'%1.2f'));
drawline(7,0,1,0,1);closegraph();
:no_graph
if ud_graph_switch = 1 then ud3 = ud2[0];
if ud_graph_switch = 0 then ud3 = ud;
if c[0] = hiqc[-1] and nobase = 0 then goto write_no_bo;
if c[0] >= hiqc[-1] then goto write_nobase;
if hi50_switch = 1 and nobase = 1 then goto hi50_only;
if hi50_switch = 1 and nobase = 0 and t = c50 then goto write_no_bo;
if hi50_switch = 1 and nobase = 0 then goto base_and_hi50;
:write_no_bo
writeln(fullname,' ',format(c[0],'%7.2f'),' ',format(chg,'%6.2f'),' ',
format(oh,'%2.f%'),' ',format(hiqc[0],'%7.2f'),' ',format(rng,'%3.f%')
,' ',
format(t/5,'%3.f'),' ',format(v[0],'%7.f'),'',format(vv50,'%5.f%'),' ',
format(ud3,'%3.1f'));
return;
:hi50_only
writeln(fullname,' ',format(c[0],'%7.2f'),' ',format(chg,'%6.2f'),' ',
format(oh,'%2.f%'),' ',format(hiqc[0],'%7.2f'),' Hi ',
format(c50/5,'%3.f'),' ',format(v[0],'%7.f'),'',format(vv50,'%5.f%'),' ',
format(ud3,'%3.1f'));
return;
:base_and_hi50
writeln(fullname,' ',format(c[0],'%7.2f'),' ',format(chg,'%6.2f'),' ',
format(oh,'%2.f%'),' ',format(hiqc[0],'%7.2f'),' ',format(rng,'%3.f%')
,' ',
format(t/5,'%3.f'),'*',format(v[0],'%7.f'),'',format(vv50,'%5.f%'),' ',
format(ud3,'%3.1f'));
return;
:write_nobase
if c[0] = hiqc[-1] and nobase = 1 then goto old_high;
if c[0] > hiqc[-1] and nobase = 1 then goto nh_nobase;
writeln(fullname,' ',format(c[0],'%7.2f'),' ',format(chg,'%6.2f')
,' NH ',format(hiqc[0],'%7.2f'),' ',format(rng,'%3.f%')
,' ',
format(t/5,'%3.f'),' ',format(v[0],'%7.f'),'',format(vv50,'%5.f%'),' ',
format(ud3,'%3.1f'));
return;
:nh_nobase
writeln(fullname,' ',format(c[0],'%7.2f'),' ',format(chg,'%6.2f')
,' NH ',
format(hiqc[0],'%7.2f'),' No Base ',
format(v[0],'%7.f'),'',format(vv50,'%5.f%'),' ',
format(ud3,'%3.1f'));
return;
:old_high
writeln(fullname,' ',format(c[0],'%7.2f'),' ',format(chg,'%6.2f'),' ',
format(oh,'%2.f%'),' ',format(hiqc[0],'%7.2f'),' No Base ',
format(v[0],'%7.f'),'',format(vv50,'%5.f%'),' ',
format(ud3,'%3.1f'));
return;