ADX stuff: part II a continuation of Part I
|
Here's what we'll do:
- We consider a sequence of positive numbers, P(0), P(1), P(2), ..., P(N)
... which may be stock prices for the last N days (weeks? months?) with P(N) being the most recent
- We consider the successive changes in these numbers: d(1) = P(1)-P(0), d(2) = P(2)-P(1), ... d(N) = P(N)-P(N-1),
... which would be the daily changes in stock price
- We consider an Exponential Moving Average (EMA) of the d-sequence which we write like so:
[1] EMA = aN-1d(1) + aN-2d(2) + ... + d(N)
... where "a" is some positive number, less than "1" so that more recent d-values have greater weight
>Huh?
The d-value N days ago - that's d(1) - is multiplied by aN-1 and if, for example, N = 30 days and a = 0.8 then aN-1 = 0.005 so that
ancient price difference doesn't hold much weight in the EMA.
Continuing:
- To mimic the DMI / ADX ritual we ignore the above EMA and consider, instead, the EMA for the POSITIVE d-values and NEGATIVE d-values.
DMI calls them DI+ and DI- ... or maybe DMI+ and DMI-
- To do this we define a bunch of U-vales and L-values (for Upper and for Lower):
[2a] U(1) = max[d(1),0], U(2) = max[d(2),0], ... U(N) = max[d(N),0]
[2b] L(1) = -min[d(1),0], L(2) = -min[d(2),0], ... L(N) = -min[d(N),0]
The U-values identify when the stock price increases and
the L-values when they decrease. A typical sequence is shown in Figure 1
- Now we consider two EMAs, namely:
[3a] EMA(U) = aN-1U(1) + aN-2U(2) + ... + U(N)
[3b] EMA(L) = aN-1L(1) + aN-2L(2) + ... + L(N)
| Figure 1
|
- Now (finally) we define our modified ADX, namely:
[4] gADX = EMA(U) - EMA(L) = aN-1(U(1)-L(1)) + aN-2(U(2)-L(2)) + ... + (U(1)-L(1))
which is just the EMA of the sequence: U(1)-L(1), U(2)-L(2), ... U(N)-L(N)
>Wait! Why "gADX"?
No good reason. Anyway, continuing ...
>Wait! Isn't that L sequence a bunch of negative numbers? I mean, you said they were the lower ...
That's why we stuck a negative sign in equation [2b].
If, for example, the fifth price difference is d(5) = -0.75 (meaning the price dropped 75 cents), then
from [2a], U(5) is the maximum of -0.75 and 0 which is 0, and
from [2b], L(5) is -[the minimum of -0.75 and 0] which is -[-0.75] which is 0.75 so that ...
>So the U and L numbers, they're the magnitudes of the changes, both positive and negative changes.
You got it. U and L themselves are never negative. Anyway, continuing from equation [4]:
- At a time when a price difference is positive, say d(k) > 0, then
U(k) = max[d(k),0] = d(k)
L(k) = -min[d(k),0] = 0
so U(k) - L(k) = d(k) > 0
... and U(k) + L(k) = d(k) > 0
- At a time when a price difference is negative, say d(k) < 0, then
U(k) = max[d(k),0] = 0
L(k) = -min[d(k),0] = -d(k)
so U(k) - L(k) = d(k) < 0
... and U(k) + L(k) = -d(k) > 0
- That turns equation [4] into equation [1]:
[4a] gADX = aN-1d(1) + aN-2d(2) + ... + d(N)
>Huh? So why that elaborate ritual with the Us and the Ls and max and min and...
Because that wouldn't have happened if we looked at daily highs and daily lows so the U and L numbers would be difference
between highs and lows respectively and ...
>And now you're assuming just a single sequence of prices, eh? Why?
No good reason. Anyway, continuing, we now see that when we use just a single daily price (instead of highs and lows) our
ADX becomes just the exponential Moving Average of the daily price changes.
Okay, we now incorporate into our gADX a normalizing feature.
Instead of taking the EMA of the sequence U(k) - L(k), which is the same as EMA[U(k)] - EMA[L(k)] ,
we take { EMA[U(k)] - EMA[L(k)] } /
{ EMA[U(k)] + EMA[L(k)] }, for k = 1, 2, 3 etc..
>Why?
Those EMAs are a kind of average and since daily price differences may be dollars or maybe cents
we don't want our ADX to be huge just because the price difference is huge. That price difference may, in fact, be a small
percentage of the current price. It's like saying the DOW just jumped 100 points whereas, twenty years ago, the largest jump was maybe
just 20 points ... and you get all excited, but that 20 point jump was a 4% jump whereas ...
>Whereas a 100 point jump today is only 1%, right?
Right.
Now, continuing, we note that EMA[U(k)] - EMA[L(k)] = EMA[d(k)] = EMA[P(k) - P(k-1)]
That gives:
gDX = X(1) + X(2) + ... + X(N)
where X(k) = { EMA[P(k) - P(k-1)] } /
{ EMA[U(k)] + EMA[L(k)] }
and U(k)= max[P(k)-P(k-1),0] and L(k)= -min[P(k)-P(k-1),0]
and P(k) are daily prices (or weekly or monthly or whatever)
and a is some positive constant less than "1" ... so 0 < a < 1
|
>Why "gDX"?
No good reason.
>And that gDX stuff is good ... uh, for what?
Who knows? But I'm working on a spreadsheet which'll look like this:
>gDX says Sell!! You kidding? Are you suggesting that somebuddy who owns GE stock should sell?
Me? Suggest? No, I just write tutorials, generate spreadsheets and ...
>And you actually use this stuff?
No, of course not! However, for those who play with these spreadsheets, you can set the Buy & Sell levels (-30% or +30%) and,
after downloading a year's worth of prices, you see what'd happen to a $1K portfolio that followed these signals over the past two months and ...
>I think you should get back to your painting.
Thanks.
P.S. If anybuddy would like to try out the spreadsheet, RIGHT-click here
and Save Target ... to download a .ZIPd file.
|