UTILS\PATTERN.DOC ·
DOC ·
11.4 KB ·
1991-06-01 ·
from PCPlus_Issue-57_Jun-1991_FluxEngine-360Kb
PATTERN:
Pattern detection tests for share price series
==============================================
Computer program written by Arthur Fasler 1990
THIS PROGRAM REQUIRES A CGA ADAPTOR, OR CGA2 LOADED WITH A HERCULES CARD
1 INVESTMENT NOTES
------------------
Shares have been shown to be amongst the best investments in the long
run (5 years or more) for most investors.
1.1 Strategies of dealing in shares
Many methods have been put forward which promise to make the most out
of share investments. I put them into one of two classes:
1 Long-term gains are predicted if you buy many shares ("a diversified
portfolio") and keep them. This I call the hold method.
2 All other methods maintain that higher gains can be achieved by
following rules which tell you when and what to buy and when and what
to sell. These I call the buy and sell methods.
Over the last 70 years, the hold method has provided a yield (gain)
from share price rises and dividend income of about 7 % a year above
inflation. The buy and sell methods must make higher gains to keep up
with this. The reason is that dealing costs for a cycle of buying and
selling are about 5 % of the sum of money involved. Thus if you buy
and sell only twice in a year, the yield of the buy and sell method
must be 17 % above inflation just to keep up with the hold method.
Buy and sell can be better if share price movements are predictable
because you can then buy shares at their lowest prices and sell at
their highest. Provided the difference is larger than the dealing
costs, you will make a gain. If share price movements are too small,
or if they are not predictable, then the hold method is best.
1.2 Predictable patterns
If you look at past share prices, predictability will show up by
regularities and patterns in their movements. If an investor is
skilful enough to predict such a pattern of rises or falls, he can get
higher returns by buying or selling than if he just held his shares.
If, however, share price movements are not predictable, then buying
and selling will provide a poor return because dealing is expensive.
Each time you buy and sell a share you lose about 5% of the capital
used.
This program provides tests to detect the presence of patterns in any
series of prices you want to check.
As you will see, no such patterns are detectable. The conclusion is
therefore that the hold method is the best way to invest in shares.
2 DATA SERIES
-------------
The progam on the disk is called PATTERN.EXE and works with five files
called SERIES-1.DAT etc . Two of them contain series of index values
(FTSE), two contain series of share prices (British Petroleum), and
one will contain your own data series. There is also a simulated share
price series called Siml which shows what a random series looks like
in the tests, and there are two check series called Sine and Down-Up
to show what patterns looke like in the tests.
You can use these series via the Choice of data list (menu) in the
program. The Series 5 option only works when you have written your
own file for it. You may also replace the data provided in the files
SERIES-1.DAT to SERIES-4.DAT by your own data by overwriting the
series provided.
Siml creates lists of random numbers in such a way that they resemble
(simulate) lists of share prices with an initial value of 100. The
program will prompt you to make two entries: first, the length of the
series you want (I suggest you try values between 50 and 90, but
values from 30 to 160 are acceptable), and second, a measure of the
variation you want the series to have (only values from 1 to 5 are
acceptable)
You will find that the simulated share price series behaves in very
much the same way as any series of actual share prices you may use.
This is another indication that share price movements have no patterns
but behave as if they occurred at random.
The check series are included so that you can see what the tests do
with data series which have a pattern. The Sine series is a wave-like
movement, in Down-Up the values first decrease, then increase in a
regular way.
I suggest that you test Siml and the check series before you test your
share price series, to get a feel for what the tests do.
3 TEST METHODS
--------------
The tests display either a graphical illustration of the result or
numbers.
To make comparisons between different data series easier, the results
are standardised . A rise of 50 in a share priced at 1000 provides a
different gain from a rise of 50 in a share priced at 500. Therefore
all results are given in %, ie a change from 1000 to 1050 is given as
5%, from 500 to 550 as 10%.
3.1 Scatter diagram
A scatter diagram tests the relationships of consecutive changes of
share prices by plotting pairs of consecutive changes as dots into a
coordinate system. Thus, the changes 3,2,1,5 are converted to pairs of
coordinates (3,2) (2,1) and (1,5) and plotted as (x=3, y=2), (x=2,
y=1) and (x=1, y=5).If share price changes have a pattern, the scatter
diagram will show a linear (longish) pattern of dots.
The program also plots two crossed lines at the average values of the
changes.If the dots are fairly equally distributed in the four parts
of the diagram , and more are near the crossing of the lines than away
from it, then there is no pattern in the share price movements.
The numbers at the edges of the diagram are maximum rise and fall
figures in % for the series plotted.
3.2 Serial correlation
This is a numerical test of the visual impression given by the scatter
diagram. It detects relationships between consecutive price changes.If
there is a relationship, the calculated correlation coefficient r will
be at or near 1 or -1,if there is no relationship, r will be at or
near 0. The program will test this and provide a conclusion about the
absence or presence of a pattern. The program uses a statistical
significance level of 95% which means that the conclusion may be wrong
once in 20 executions of the test.
3.3 Runs of rises and falls
If share price changes are non-random, there will be runs of rises
and of falls which are different from those obtained by numbers drawn
at random. If there is a tendency for changes to persist, runs of
rises or falls will be longer than if changes occur at random, and
there will be fewer runs. The test given here counts the number of
runs of rises and of falls in the series under test and compares them
with runs expected in a random series of the same length.
If the numbers of runs in the series under test are about the same as
those calculated for a random series, it can be assumed that it is a
random series. If the numbers are very different, the series under
test is likely to be a non-random series ie to show some pattern.
For short series (20 rises and 20 falls or less), this has to be
assessed by intuition, but for longer series, a test is applied which
results in a conclusion: random , or non-random.
3.4 Chart of changes
This is a pictorial representation of the changes of share prices. If
there are spikes about evenly distributed above and below the
horizontal zero line, there is no pattern in the changes.
3.5 Other choices from the method choice list:
3.6 View share prices
This lists the share prices, 60 entries at a time. Only integer values
are displayed but if your entries have decimals, the accurate values
are used for all calculations.
3.7 Choice of another data series
In this program you can examine only one series at a time. This option
takes you back to the Choice of data series screen from which you can
select another series.
4 COMPUTING NOTES
You need a PC compatible computer with MS-DOS and CGA.
These instructions are in PATTERN.DOC, which you can print, or view
with PBS-VIEW.
To use the program, boot your computer, then type the name of the
program file ie PATTERN. Now follow the instructions displayed on
screen.
During use, you will be prompted to type in certain numbers. If you
type in something unacceptable (a number which is too high or too low,
or a non-number), the program will show a message about it on the
screen and ask you to try again.
4.1 Data
The disks provides four series of index and share price values. For
the Series 5 file you have to enter your own values. The file must be
a pure ASCII text file to be readable by the program and must consist
of the following five parts: 1 short name, up to 4 characters, eg BP91
or GEC; 2 a remark, up to 12 characters long eg (Series 1); 3 details,
up to 39 characters long eg Daily values 22.1.-8.3.90; 4 list of share
prices separated either by a comma or a space; 5 the last entry must
be -1 (minus one) as an end-of-file marker.
To write your own data file under DOS, use the procedure described in
your computer or DOS manual under 'Creating batch files'.
The program will not work with fewer than 30 entries, and is written
for up to 160 entries. In general, the more entries you use, the
clearer the results.
The Chart of changes displays up to 90 changes on one screen. If there
are more changes, they will be shown on a further screen.
5 STATISTICAL NOTES
-------------------
Statistics, properly applied, can sort out what is real from what is
imaginary. Do share price changes run in patterns which can be used to
predict them? Charts of share prices often appear to show patterns to
such an extent that many names have been created for them such as head
and shoulders, trends, flags etc.
If share price movements show regular patterns, a skilled investor
should be able to use them to improve his gains. If no such patterns
exist, skill will produce no better results than chance. The
statistical tests given here allow you to find out if there are usable
patterns in any series of share prices.
6 RESULTS
---------
To see what the test results mean, I suggest you first test check
series which you know have a pattern, then a number of random changes.
When you then test share prices you will find it easier to decide to
which of the two types of series they belong.
My checks, using the above and other tests, as well as the checks made
by many others using similar tests and share price series worldwide
and over many decades, have very rarely shown patterns of the type
that could be used to predict future share price changes.
The conclusion must therefore be that none of the buy and sell methods
are good ways of investing in shares; the hold method is definitely
the best way. These programs give you a chance to do your own tests
with your own share price series.
To be safe, your share holding should be as wide-spread as possible. I
favour index funds for this.
7 RECOMMENDED BOOKS
-------------------
An introduction to risk and return by Richard Brealey (Blackwell
1985)
Stock market efficiency by Simon Keane (Allen 1983)
A basic course on statistics by GM Clarke and D Cooke (Arnold 1983)
Basic statistical computing by D Cooke, AH Craven and GM Clarke
(Arnold 1982)
8 NOTE
------
These tests were developed and used specially for the detection of
patterns in series of share prices and share price index numbers but
they can just as well be used for other data such as prices of any
assets - gilts, stamps etc -, body temperature during a day, roulette
wheel results and so on.