We also compute the average price over the past N days ... and plot it. When they cross we BUY ... or maybe we SELL depending upon whether the crossing is from above or below It might look like so: So you play with the numbers M and N until you're happy. Of course, a simple 200-day Moving Average, like MA = (P1 + P2 + P3 + ... + P200)/200, gives equal weight to all Prices, even the one that occurred 200 days ago! So, if we want to give more weight to more recent Prices, we could use a Weighted Moving Average: WMA = (P1 + 2P2 + 3P3 + ... + 200P200)/K where K is a magic number (which we'll explain in a minute). Note that we are assuming that P1 is the price 200 days ago and P200 is the most recent Price ... and this most recent price is multiplied by 200 so it's 200 times more significant than the 200-day old Price, right?
Okay, what's K?
WMA = (P + 2P + 3P + ... + 200P)/K = P(1 + 2 + 3 + ... + 200)/K As you might imagine, there's a magic formula for this sum, namely: 1 + 2 + 3 + ... + 200 = 200*201/2 so that's the value for K.
In general, for an N-day moving average, we have Our Weighted Moving Average is now:
Of course, nobody sez that the relative weights 1, 2, 3, ... are etched in stone. We could choose any weights w1, w2, w3, ... wN, and get:
Note that the number K is chosen so that, in the case where all Prices are equal, the Moving Average is equal to that Price as well. It's time for a picture (where we use the weights 1, 2, 3, ...):
Note that the Weighted Moving Average (which emphasizes more recent Prices) follows the stock price more closely than the Simple 20-day average.
Then there's See also Moving Averages
Another thing ... In order to simplify the calculation of the Weighted Moving Average WMA (with relative weights 1, 2, 3, ... N) we do this: We have, at the current time period (which we'll call "Now"):
WMA(Now)= (P1 + 2P2 + 3P3 + ... + NPN)/K WMA(Next) = (P2 + 2P3 + 3P4 + ... + NPN+1)/K
and if we subtract, we get: WMA(Next) - WMA(Now) = (-P1 - P2 - P3 - ... - PN + N PN+1)/K and here we recognize P1 + P2 + P3 + ... + PN as N times the Simple Moving Average at time period "Now" ... which we'll call MA(Now), what else? That gives a prescription for computing our "Next" Weighted Moving Average: WMA(Next) = WMA(Now) + {- N MA(Now) + N PN+1}/K and it's time to stick in K = 2/{N(N+1)} and get:
So, assuming you're at time period 123 (that's "Now" and it could be 123 days or 123 weeks or ...) and you're workin' on 26-day moving averages (so N = 26) and you have the values of WMA(Now) and MA(Now) and the "Next" stock Price, P124, then you get the "Next" Weighted Average like so: WMA(Next) = WMA(Now) + 2/27 {P124 - MA(Now)}.
So now, having the "Next" stock Price you also compute the Simple Moving Average of the last 26 prices, namely MA(Next), then "Next" becomes "Now" and you start again, to compute a new "Next" ... now, ain't that right?
See the similarity? (Just replace MA by EMA)
where EMA(Next) appears as a weighted average of EMA(Now) and PN+1. In fact, let's write the "weight factor" as:
Okay, so why does this give an "Exponentially Weighted Average"?
Now, if we also write
See? It's the EMA equation we got before 'cept, now, we do
recognize it as an exponentially weighted average! One curious thing. For a 12-day EMA, one chooses α = 1 - 2/(N+1) with N = 12 and for a 26-day EMA, one chooses α = 1 - 2/(N+1) with N = 26, etc. even tho' the average is certainly not an average over just 12 or 26 days, but over all previous stock prices!
where EMA12-day means the 12-day (N = 12) Exponential Moving Average.
Here's MACD for a fast-moving exponential average (12-day) minus
a slow-moving exponential average (26-day): Of course, y'all don't hafta use the numbers 12 and 26 used by all them thar investment gurus ... When MACD goes positive (meaning the fast average moves above the slow), that's a BULLish signal. When it goes negative, that's BEARish.
If today's closing price is $16 and last month it closed at $12, then is today's price more significant ... because it's more recent (hence more relevant)? I don't think so, not if only ten shares traded at $16 whereas ten million traded last month at $12. (Okay, I exaggerate, but you get the idea, no?) That brings us to my favourite (which we'll call VMA), not necessarily because it gives better BUY/SELL signals, but because it makes some sense (to me, cuz VMAN-day is approximately the average price paid for each share of stock over the past N days).
It's simple.
Here's a stock and the volume of trades: The trading price in May was really important ... look at the volume! Anyway, we plot the weighted moving average over, say N = 100 days (why not?) and get:
I'm getting ahead of myself. You see the stock price and the 100-day VMA in a lovely blue and also the 5-day Moving Average. (I hate to look for places where the stock price crosses some moving average; the stock price is too finicky, too nervous, too apt to spike-then-fall, too volatile ... so we use a fast moving average, like 5-day, 'cause it follows the stock price pretty closely and it's smooother, right?)
So what're the BUY/SELL signals?
When VMA - (5-day) > A then we BUY.
For example, if we plot the difference VMA - (5-day) we get: OOPs! I've used the label VA for the Volume Weighted Average, rather than VMA; sorry 'bout that.
And what're optimal choices for A and B?
One other thing:
and the numbers VN are the volumes of stock traded each day and, as before, α = 1 - 2/(TimePeriod + 1) so, for a 12-day V-EMA, we'd have α = 1 - 2/13 = .846 You can, of course, take V-EMA12-day - V-EMA26day to get a Volume-weighted MACD which I call V-MACD (and my son calls VD).
Does it differ much from the garden-variety MACD? Yes, if the volume of stock
trades changes a bunch, like so: Here, the price dropped but the volume increased thereby increasing the significance of these lower prices; when the garden-variety MACD dropped ('cause the price dropped so the 12-day EMA dropped) the increased volume kept the V-EMA from dropping so dramatically. Note: If the volume doesn't change from day to day, then V-MACD and MACD are identical.
Except ... uh ... I should mention the
Signal Line. You see, some
technical gurus use yet another line (curve?) called the
Signal Line
and take as BUY/SELL signals the times when MACD crosses this
Signal Line.
where α = 1 - 2/(9+1) = .80 and it looks like so:
Just one last thingy: formulas which look like:
As you can see, it's sort of a personal thing; you draws 'em as you see 'em. The stock price keeps bouncing off the red line as though it's being supported by that line ... so it's called the line of support. Prices can't seem to break through the green line; it's called resistance. One (presumably) waits for some sign that the stock price has changed trends and bravely crosses either line, leaving the channel. (The channel between the red and the green lines is called the ... uh ... channel.) Here's a beauty; it's trending UP ... uh ... or is it trending DOWN?
It's called trendless I invented the above charts to illustrate trends, but here's a real live example:
Me? I find it difficult to identify any trend, just by eyeballing the chart ... especially the beginning of a trend. (After it's over, it's too late!)
Maybe there's a more analytical/technical/sophisticated method to identify trends, which
brings us to:
Each day we compute BULL points if today's high is greater than
yesterday's high.
Each day we compute BEAR points if today's low is smaller than yesterday's low.
* In order to be somewhat more meaningfull, we'll
divide these differences by "today's" closing price so they become percentages. Then, each day we see which points are bigger: the BULL points or the BEAR points (recognizing that, on some days, they may both be zero).
If the BULL points are bigger, they get awarded to the
bulls. Here's the BULL and BEAR points, for a sequence of days: Uh ... the horizontal axis includes weekends when there were no points ... like Sep 25/26 and Oct 2/3 Note that, on Sep 24, there were both BULL and BEAR points, but only the BEAR points were awarded - to the bears (cuz their points wuz bigger). Okay, here are the points that were actually awarded (to either the bulls or the bears) for the six month period covered by the stock price chart (above):
and, for reference, the stock chart itself: Okay, here's what we do ... actually, what Mr. Wilder does, 'cause DMI is his baby:
We take the sequence of awarded BULL points,
say B(1), B(2), B(3) ...
and compute the
14-day Exponential Moving Average of this sequence
(Remember the EMA? Use:
EMA(n+1) = α EMA(n)+
(1-α)B(n+1)
with α = 1 - 2/(14+1))
Then we take the sequence of awarded BEAR points and compute the
14-day Exponential Moving Average of this sequence (remember the EMA?).
Then we plot 'em both, like so: and, for reference, the stock chart itself: Notice something interesting? When the +DI gets bigger than the -DI, there's a UP trend (the bulls are winning) and when the -DI gets bigger than the +DI, there's a DOWN trend (the bears are winning) and these events usually happen near the beginning of the trend!! Of course, if we take the difference between +DI and -DI we'd get a chart that goes positive when the former exceeds the latter (the more the bulls are ahead, the bigger this difference would be) so we compute:
That'd give this guy: and, for reference, the stock chart itself:
Uh ... did I mention it was called ADX (Average Directional Indicator)?
It's in the nature of the sport that bulls get very excited when the
ADX is increasing
... especially when it exceeds 50.
I should mention that, if the spikes in ADX are bothersome, Check out DI+/- (sometimes called DMI+/-) and ADX on your stock at bigcharts.com. It'll look like so:
PS#1
PS#1.5
PS#2It's been said (not by me!) that one can't use DMI on single-value sequences of numbers, like Mutual Funds (that don't have daily Highs and Lows). Take a peek at these charts (where I just made the High & Low stock prices equal to the Close ... hence a single daily value):
PS#3Another thing: the use of the Exponential Moving Average is not the only choice one has (to incorporate the recent stock price history). We could also use (of course!) the Volume-weighted Moving Average. Here it is (for the CBR stock), where we're changing the names of +DI and -DI to VDI+ and VDI- and the ADX we'll call VDX:
Conclusion: with Volume-weighting, there's a certain amount of inertia associated with stock prices accompanied by high volume; the VDX tends to be more sluggish after high volume days. The effect hangs around for a while and the VDX is less temperamental, less likely to frivolously change direction with every spike in stock price - especially prices with low volume. That may - or may not - be a good thing. Another note: in the Volume chart, there are blanks along the horizontal time axis. Them's weekends! For more on VDI and Volume-weighted EMA, see EMA.
As you might imagine, we plot the values of %K (which lie between 0% and 100%) ... either with or without smoothing. (Smoothing involves taking a 2- or 3-day average of the %K values). No smoothing? It's a fast stochastic. In addition, we calculate the M day moving average of %K ... and call it %D. This might be a weighted average, such as described above. In any case, we watch to see when %K falls below or above some magic number (like below 20% or above 80%) ... or when it crosses %D. The chart below shows a few months of %K (with N=10 days) and a 2-day (smoothed) version and an M=5-day, simple moving average (that's %D) and some red and green arrows at the 20% and 80% values ... meaning SELL ... or maybe BUY ... or maybe ...
Note that %K + %R = 100% See also Williams
Once upon a time, an Italian mathematician called Leonardo Fibonacci (while studying the population growth in rabbits) considered the sequence of numbers: 1, 1, 2, 3, 5, 8, 13, ... where each number is the sum of the two previous numbers (so, for example, the next number would be 13 + 8 = 21). The numbers satisfy the equation Fn+2 = Fn+1 + Fn with F1 = F2 = 1. The ratio of successive numbers satisfies
Fn+2/Fn+1 = 1 + 1/{Fn+1/Fn} and if we let n become
infinite we get the limiting value of this ratio, namely x which satisfies:
x = 1 + 1/x or x2 - x - 1 = 0
which has as a solution
In any case, this number has been applied to so many things that it seemed inevitable that it'd be applied to the stock market. We'll talk about Fibonacci fans. To see a DOWN Fibonacci fan we do this:
Martin Zweig wrote a book, "Winning on Wall Street", where he describes (among other things) a 4% Rule.
I goes like so:
It will (among other things) search for the best percentage (as opposed to the 4%). To download Anthony's spreadsheet, RIGHT-click here and Save Target.
A WORD OF EXPLANATION: I'm learning 'bout this technical analysis bumpf as I go along.
Each time I discover something new (and interesting) I stick it here provided I can
understand it (hence adequately describe it) ... and sometimes, somebuddy suggests a topic.
(e.g. I learned about the existence of Bollinger & RSI & MACD from my son and I invented the
"volume-weighted" stuff myself (tho' it wasn't the first time it was invented :^) and DMI was brought to my
attention by Jean-Claude).
There are two (old!) spreadsheets to play with:
P.S. For other TA bumpf:
Check here.
|