home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1993 #2
/
Image.iso
/
finance
/
tas515dm.zip
/
EXAMPLES.ZIP
/
AAMOSC.TAS
< prev
next >
Wrap
Text File
|
1992-08-13
|
4KB
|
84 lines
{ ******** MOSC.TAS 7/31/92 BY DENNIS MEYERS ******************}
{this script computes the McClennan oscillator and then does a
profit test against the s&p500. The pgm then draws the buy and
sell points as vertical lines in the ticker graph }
{ BUY criteria..buy when mosc > +zone
SELL criteria.. sell when mosc < -zone
position the same in -zone to + zone }
{********************* IMPORTANT POINTS ***********************}
{ a. This pgm could have been (and was) written & tested in MSP3.0
in 1/10th the time. The main purpose of my pgm is to serve as
model and skeleton for future more complicated profit testing
pgms that can't be done using MSP3.0}
{ 1. This pgm uses the McClellen Osc as a driver to make buy and
sell decisions on the S&P500. Any Security could be substituted
as a ticker to buy and sell.}
{ 2. The indicator, in this case the NYSE adv and decl have to
loaded separately through the LOAD statement. CARE MUST BE
TAKEN to make sure the load data and the ticker data start
from the same date. This can be done through a scan_date statement
as below where YOU KNOW each file has those dates or through
a #MAX_QUOTES statement where YOU KNOW each file has those SAME
number of quotes. }
{ 3. I get my data from Dial Data. they put the ADV,DEC,UNC,AV,DV
in the OHLCV fields of the ticker symbol *NADV. Other vendors
breakup that data into 5 different ticker symbols. So in order
for you to get this program to work you must use Dial Data's
*NADV or redefine the tickers in the LOAD statments below}
{ 4. This pgm runs a profit test for both short and long positions
using all cash, no commisions, and buying and selling on the close.
***NOTE all array declarations MUST COME BEFORE PLOT BEGIN
statement.}
{ 5. This pgm MUST HAVE sub B_S_LINE.TAS in the same directory.
#include B_S_line.TAS at the bottom appends sub to this pgm.
B_S_LINE.TAS is the sub that draws (almost)vertical lines
at the buy and sell points of profit test.}
{ 6. The Mosc does not seem to give very timely signals and has a lot
of whipsaws... using buy and sell on zone crossings...}
#profit_test both 10000
#profit_comm nocomm allcash 0 - todays close
#profit_output detail
#MAX_QUOTES 2000
#scan_date 911001 0 {need this because *nadv and *spx (ticker input)}
{ are different sizes *nadv=797 data *spx=1411}
{TAS lines up arrays from start date of ticker}
{and pads 0's on the end of load data if load }
{data is not a long as tickers data.. TAS will not}
{line up dates..that is left to programmer}
#output_file mosc.lst
adv : array;
dec : array;
addiff: array;
mosc : array;
pos : array;
plot begin {********** PLOT BEGIN **************************}
qe=quote_count;
adv=load('*NADV','O');
dec=load('*NADV','H');
addiff=sub(adv,dec);
mosc=sub(mov(addiff,19,'e'),mov(addiff,39,'e'));
zone=15;
for i=2; i<=qe; i=i+1; begin
pos[i]=pos[i-1]; {pos remains the same when in dead zone}
if mosc[i]>zone pos[i]=1;
if mosc[i]<-zone pos[i]=-1;
writeln(int(i),dates[i],c[i],mosc[i],int(pos[i]));
end; {buy sell for loop}
end; {******** PLOT END *************}
BUY WHEN pos=1 and pos[-1]<=0;
SELL WHEN pos=-1 and pos[-1]>=0;
if end_phase and last_ticker then begin
graph_it=1;
if graph_it=0 return;
lsw=1;
OPENGRAPH(3);
sizegraph(3,2,1);
GRAPH(c,'s&p500');
gosub b_s_line; {***call the buy sell vertical line generator}
GRAPH(mosc,'McClellan Oscillator');
graph(pos,'Position buy=1 sell=-1');
CLOSEGRAPH();
end; {end_phase=1 if}
return;
#include B_S_LINE.TAS