Subject: Fwd: Doc Draft
From: [email-masked]
To: [email-masked]
Date: Sun, 13 Jan 2002 18:13:45 -0800 (PST)

Subject: Doc Draft
From: Vince Kaminski <[email-masked]>
To: [email-masked]
Date: 13 Jan 2002 19:55:16 -0600

The application takes as input the name of a file containing a stocks
trading history. The first line of the file has the stocks symbol, the
second a human-readable description of each quotes fields (This comes
from the format used by Yahoo! Finance and is simply skipped by the
application), and the remaining lines are quotes, starting with the most
recent, in the form:

<day>-<month>-<year>,<open>,<high>,<low>,<close>,<volume>

Where,

<day> == Day of the month (1-31)
<month> == Three-letter abbreviation of the months name
<year> == Two-digit representation of the year
(The rest are self-explainatory)

Example:
AAPL
Date,Open,High,Low,Close,Volume
31-Dec-01,22.51,22.66,21.83,21.90,2460400
28-Dec-01,21.97,23,21.96,22.43,5341500
27-Dec-01,21.58,22.25,21.58,22.07,3419800
26-Dec-01,21.35,22.30,21.14,21.49,2614300
24-Dec-01,20.90,21.45,20.90,21.36,904100
21-Dec-01,21.01,21.54,20.80,21,4577400
20-Dec-01,21.40,21.47,20.62,20.67,3944000
--------8<---------
10-Jan-91,22.875,23.625,22.875,23.5625,3886800
9-Jan-91,22.125,23,21.875,22.625,4172000
8-Jan-91,21.875,21.9375,21.25,21.625,1952600
7-Jan-91,21.50,22.625,21.50,21.625,2775000
4-Jan-91,21.50,22.125,21.50,21.625,1263600
3-Jan-91,21.75,22.125,21.50,21.50,1340900
2-Jan-91,21.375,22,21,21.75,1383800

Adapting the application to use different formats is trivial.

In its current form the analysis is quite simple. A stochasitic (fast or
slow, with abritrary periods) is computed from the stocks data (see
below for a more detailed description). Next, the stock data searched
for Japanese Candlestick patterns (see below).

The actual analysis consists of simulating several years of trading
(here ten years). Each is stochastic and candlestick data is examined.
If the days candlestick is a hammer and the %k is above a pre-defined
value, a buy signal is triggered. Likewise, if the days candlestick is a
hanging man and the %k is below a second pre-defined value, a sell
signal is triggered.
When simulating a buy, a long position of a constant number of shares is
opened if long positions already exist or if no positions exist. If
there are open short positions, each of these is closed. Likewise, when
simulating a sell, a short position of the same constant number of
shares is opened if short positions already exist or if no positions
exist. If there are open long positions, each of these is closed.
When closing a position, the rate-of-return and annualize rate-of-return
are calculated. For both long and short positions:

                           sale cost - purchase cost
                     RoR = -------------------------
                                purchase cost
(a better method is needed for shorts)

and,
                                               365
                                      --------------------
                                      Duration of Position
          Annualized RoR = (RoR + 1.0)                     - 1.0

Stochastics:
            (Todays Close - Lowest Low for kN Periods)
%k = ---------------------------------------------------------
     Highest High for kN Periods - Lowest Low for kN Periods)
%p = Simple Moving Average of %k for pN Periods

     (Where the lowest low is chosen from amongst the lows
      field and the highest high is chosen from amongst the
      high field.)

This is a fast-stochastic. When computing a slow stochastic, %k is
replaced with its 3-day Simple Moving Average. %p is then calculated
from this value.

Japanese Candlesticks:
The application currently searches the data for the Hanging Man and
Hammer patterns. A Hanging Man is defined as very short top-shadow,
medium body, and long bottom-shadow. The ratios are adjustable. A Hammer
is a Hanging Man where the days close is higher than the open.

--
Vince Kaminski
[email-masked]