Parabolas ... and technical analysis stuff
|
suggested by Jim T.
Once upon a time J. Welles Wilder and
(maybe) others were fitting parabolas to stock price charts and ...
>Huh?
Stare at Figure 1. It's the S&P500 index over a 1020 day period (ending October, 2004).
Don't you see a parabola there?
>No!
Look closely. That light grey curve is a parabola.
Our objective is to pick a parabola which best fits the points on the S&P price curve.
>Best? What's "best"?
Aah, yes. That's the question. Once we get our parabola we'd like to use it to identify the market bottom or ...
>Or market top!
| Figure 1
|
Sure. So we'll do this:
- We identify N prices at times t = 0, 1, 2, ... N and we'll call them p(1), p(2), p(3), ... p(N).
>Are we gonna do math here?
Yes ... a bit. Take a nap and I'll wake you when ...
>zzzZZZ
- We identify N prices at times t = 0, 1, 2, ... N and we'll call them p(1), p(2), p(3), ... p(N).
- We'll invent a parabola whose equation is p = A t2 + B t + C
... with constants A, B and C as yet unknown.
It'll look like the grey curve in Figure 1.
- We evaluate this parabola at the integers t = n (for n = 0, 1, 2, ... N), namely:
p = A n2 + B n + C
The integers count the number of days from the start of our price chart.
- We consider the difference between the parabola at these times and the price, namely:
A n2 + B n + C - p(n)
- We want to choose our A, B and C so these "errors" are minimized,
so we consider the sum of squares of these differences (or "errors"), namely:
E(A, B, C) =
[A 02 + B 0 + C - p(0)]2 +
[A 12 + B 1 + C - p(1)]2 +
[A 22 + B 2 + C - p(2)]2 + ... +
[A N2 + B N + C - p(N)]2
= Σ
[A n2 + B n + C - p(n)]2
... summing from n = 0 to N
- We set the derivatives (with respect to A, B and C) of this "Error function" E(A, B, C)
to 0,
giving three equation to solve for the "best" values for A, B and C, namely:
[1] A Σn4
+ B Σn3
+ C Σn2
= Σn2 p(n)
[2] A Σn3
+ B Σn2
+ C Σn
= Σn p(n)
[3] A Σn2
+ B Σn
+ C Σ1
= Σp(n)
>I haven't the faintest idea what you're ...
Look carefully at Figure 2. It shows a few of the prices p(1), p(2), etc. and a parabola
and a typical "error" term at n = 3 and we're squaring all these errors (so it don't matter whether they're positive of negative) and then adding these
squares and seeing if we can choose A, B and C so this sum of the squared errors is a minimum.
>And you solve equations [1], [2], [3] to find the "best" values for A, B and C?
You got it.
>And you expect anybuddy to actually do this?
No, an Excel spreadsheet will do it.
| Figure 2
|
Anyway, equations [1], [2], [3] can be written in matrix form, like so
... so the solutions can be written like so (involving the inverse of the f-matrix)
Here f4, f3, f2, f1 and f0 are the sum of the powers of the integers. For example: f3 = Σn3
Note that f0 is easy: f0 = Σ1 = 1 +1 +...+ 1 = N
Also, s2, s1 and s0 are the three right-sides of our three equations. For example: s2 = Σn2 p(n)
There are known, magic formulas for the sum of powers of the integers. For example: f3 = Σn3 = n2(n+1)2/4
On the other hand, the three right-sides depend upon the stock prices over the past umpteen days.
>Yeah, so ... is this stuff any good?
I don't know ... yet!
However, let's look at that S&P500 chart (as in Figure 1). ... but just the first 300 days.
Let's pretend we don't yet know the next bunch of prices (from day 301 to day 1020).
Figure 3 gives the "best" parabola ... matching those first 300 days (according to the solution of the equations given above).
The equation of the parabola is: p = (0.0012) n2 + (-1.469) n + (1424)
Note that A = 0.0012, B = -1.469 and C = 1424.
| Figure 3
|
>And the next bunch of days?
That's shown in Figure 4 (along with the prices).
There we show those first 300 days (ending at the red dot) and the continuation of the parabola
to its minimum (ending at the magenta dot).
>So the minimum of the parabola is at the minimum of the prices, right?
Pretty close!
Note: one-of-these-days I'll have a spreadsheet to do all this stuff
... then we'll see if it's just an accident, eh?
| Figure 4
|
Here are some "best" parabolas ... for various stocks over various time periods:
Figure 5
>Are you predicting in them charts?
Uh ... no. I'm just showing what a "best" parabola might look like. It might be shaped like a bowl or a dome of just like a straight line.
>Yeah, but I want to know what will happen ... not what has happened?
Patience!
However, suppose we look at the first chart above. That's GE stock starting in April, 1999.
Suppose we look at the period from April to, say, June, 2000.
>So you're pretending it's June, 2000 and ...
And I whip out my spreadsheet, download the latest GE prices and ask the spreadsheet to find that "best" parabola.
It gives me Figure 6.
>Then you see where the parabola is heading, right?
Exactly. In this case the parabola has equation: p = (-0.0001)n2 + (0.091)n + (29.069)
and that parabola has a maximum at n = 431. So 431 days from our April starting date ...
>We get the maximum GE price, eh?
No, it's a prediction ... and it gives a date when GE will start to fall.
It happens to be January 10, 2001.
| Figure 6
|
>And, did it fall on January 10, 2001?
It looked like this (along with our "best" parabola, calculated from the April, 1999 - June, 2000 prices):
Figure 7
Note the first GE chart in Figure 5. That shows a "best" parabola determined by ALL the data from April, 1999 to March, 2001.
The chart in Figure 7 shows the parabola based upon JUST the prices to June, 2000
... and its extension beyond June.
>Can't you do better than that?
Certainly ... try this
To play this Parabola Game**, you can download a spreadsheet by RIGHT-clicking
here
... then Save Target file. (It's about 400 Kbytes @!^%$*?)
The spreadsheet looks like this ... but it keeps changing
** This spreadsheet is intended to play with the "best" parabola idea,
looking at past prices and seeing how well (or poorly) the parabolas predict future highs and lows
It's fun. You could get things like this:
Although these charts cover three years (about 750 days), the parabolas were calculated using the prices over 250 days
... that's about the first year or so.
>And what about the future?
Okay, it's now October, 2004.
We look at the last 3 years (754 days) and use all those prices to calculate our "best" parabola and get this:
>So we should buy T, right?
I'll let you know in a few months ...
for Part II
|