banner

 

Oscillators



GOOG Stochastics Down Chart GOOG W%R Up Chart


Definition:

Oscillators are a family of chart indicators that have the primary characteristic of swinging from one extreme of their scales to the opposite in exaggerated response to movement in price.

As the stock price moves up and down the oscillator line will also move, but in a magnified manner causing it to oscillate from one extreme to another.

There are several oscillators that one can use when applying technical analysis. Here are 5 that I want to use as an example:


The MACD Oscillator

MACD, which stands for Moving Average Convergence / Divergence, is a technical analysis indicator that shows the difference between a fast and slow exponential moving average (EMA) of closing prices. Fast means a short-period average, and slow means a long period one.

Exponential Moving Average (EMA) refers to an average, sometimes also called an exponentially weighted moving average (EWMA), that applies weighting factors which decrease exponentially. The weighting for each day decreases exponentially, giving much more importance to recent observations while still not discarding older observations entirely.

The standard periods are 12 and 26 days:

MACD = EMA[12]\,of\,price - EMA[26]\,of\,price

A signal line (or trigger line) is then formed by smoothing this with a further EMA. The standard period for this is 9 days,

signal = EMA[9]\,of\,MACD

The difference between the MACD and the signal line is often calculated and shown not as a line, but a solid block histogram style. This construction was made by Thomas Aspray in 1986. The calculation is simply

histogram = MACDsignal

The graph below shows an example of MACD as it can be set up with Big Charts.com

MACD

MACD is a trend following indicator, and is designed to identify trend changes. It's generally not recommended for use in ranging market conditions. Three types of trading signals are generated,

  • MACD line crossing the signal line.
  • MACD line crossing zero
  • Divergence between price and MACD levels

The signal line crossing is the usual trading rule. This is to buy when the MACD crosses up through the signal line, or sell when it crosses down through the signal line. These crossings may occur too frequently, and other tests may be needed to be applied.

The purpose of the histogram is to help show when a crossing occurs, since when it crosses through zero the MACD crosses the signal line. The histogram can also help visualizing when the two lines are coming together. Both may still be rising, but coming together, so a falling histogram suggests a crossover may be approaching.

A crossing of the MACD line up through zero is interpreted as bullish, or down through zero as bearish. These crossings are of course simply the original EMA(12) line crossing up or down through the slower EMA(26) line.

Positive divergence between MACD and price arises when price makes a new selloff low, but the MACD doesn't make a new low, ie. it remains above where it fell to on that previous price low. This is interpreted as bullish, suggesting the downtrend may be nearly over. Negative divergence is the same thing when rising, ie. price makes a new rally high, but MACD doesn't rise as high as it did before; this is interpreted as bearish.

Divergence may be similarly interpreted on the price versus the histogram, ie. new price levels not confirmed by new histogram levels. Longer and sharper divergences (distinct peaks or troughs) are regarded as more significant than small shallow patterns in this case.

It is recommended to look at a MACD on a weekly scale before looking at a daily scale, so as to avoid making short term trades against the direction of the intermediate trend.




The Relative Strength Indicator (RSI)

The Relative Strength Index (RSI) is an oscillator showing price strength by comparing upward and downward close-to-close movements.The RSI is popular because it is relatively easy to interpret.

Note that the term relative strength also refers to the strength of a security in relation to the overall market or to its sector. For instance XYZ might rise 2% when the rest of the market rises 1%. This is sometimes called relative strength comparative to avoid confusion. It's unrelated to the Relative Strength Index described here.

For each day an upward change U or downward change D amount is calculated. On an up day, ie. today's close higher than yesterday's,

U = closetodaycloseyesterday
D = 0

Or conversely on a down day (notice D is a positive number),

U = 0
D = closeyesterdayclosetoday

If today's close is the same as yesterday's, both U and D are zero. An average U is calculated with an exponential moving average using a given N-days smoothing factor, and likewise for D. The ratio of those averages is the Relative Strength,

RS = { EMA[N] \; of \; U \over EMA[N] \; of \; D }

This is converted to a Relative Strength Index between 0 and 100,

RSI = 100 - 100 \times { 1 \over 1 + RS }

This can be rewritten as follows to emphasise the way RSI expresses the up as a proportion of the total up and down (averages in each case),

RSI = 100 \times { EMA[N]\;of\;U \over (EMA[N]\;of\;U) + (EMA[N]\;of\;D) }

The EMA in theory uses an infinite amount of past data. It's necessary either to go back far enough, or alternately at the start of data begin with a simple average of N days instead,

AvgU_{initial} = { U_1 + U_2 + \cdots + U_N \over N }

and then continue from there with the usual EMA formula,

AvgU_{today} = \alpha \times U_{today} + (1-\alpha) \times AvgU_{yesterday}

(Similarly with D.)


A smoothing period of N=14 is recommended when using the RSI. This is by his reckoning of EMA smoothing, ie. α=1/14.

A security is considered to be overbought if it reached the 70 level, meaning that the trader should consider selling. Or conversely oversold at the 30 level. The principle is that when there's a high proportion of daily movement in one direction it suggests an extreme, and prices are likely to reverse. Levels 80 and 20 are also used, or may be varied according to market conditions (eg. a bull market may have an upward bias).

Large surges and drops in securities will affect RSI, but it could just be a false buy or sell. The RSI is best used as a complement with other technical analysis indicators.

RSI

 

The Stochastics Oscillator

The stochastic oscillator is a technical analysis oscillator (or two oscillators) showing the latest closing price in relation to the trading range of the past N days. This concept is unrelated to a stochastic in mathematics or statistics.

stochastis

Two oscillator lines are calculated, called %K and %D, each ranging from 0 to 100. %K is the closing price within the past N-days trading range, ranging from 0 when the latest close is a new N-day low, up to 100 for a new N-day high,

\%K = { close_{today} - lowest\,low_{Ndays} \over highest\,high_{Ndays} - lowest\,low_{Ndays} } \times 100

%D is a 3-day simple moving average of %K,

\%D = SMA_3 \; of \; \%K

The usual "N" is 14 days, ie. a fortnight's worth of past data, but this can be varied. Levels near the extremes 100 and 0, for either %K or %D, indicate strength or weakness (respectively) with prices making or approaching new N-day highs or lows.

Levels above 80 and below 20 can be interpreted as overbought or oversold, but not on their own, only with other factors. Lane recommended waiting for a return back through those thresholds, ie. when the oscillator goes above 80, wait for it to fall below 80 before selling; or vice versa on going below 20 wait for a rise back above 20 before buying; which in effect means waiting for a bit of a reversal. Or alternately levels 80 and 20 might be traded when some other technical indicator suggests a non-trending market.

%D acts as a trigger or signal line for %K. A buy signal is given when %K crosses up through %D, or a sell signal when it crosses down through %D. Such crossovers can occur too often, and to avoid repeated whipsaws one can wait for crossovers occurring together with an overbought/oversold pullback, or only after a peak or trough in the %D line.

Some traders consider the basic %K and %D too volatile, giving too many signals and too many whipsaws. This is addressed by forming "slow" stochastics. %K values are first smoothed by a 3-day simple moving average, and then the %D formed by a further 3-day SMA on that. This "slowed" %K is the same as the "fast" %D, but it's easiest just to think of the slow form as first inserting an extra smoothing.

%K is the same as Williams % R though on a scale 0 to 100 instead of -100 to 0, but the terminology for the two are kept separate.


The TRIX Oscillator

Trix (or TRIX) is a technical analysis oscillator developed in the 1980's by Jack Hutson, editor of Technical Analysis of Stocks and Commodities magazine. It shows the slope of a triple-smoothed exponential moving average (EMA).

The name Trix is from "triple exponential".

Trix is calculated with a given N-day period as follows,

  • Smooth prices (often closing prices) using an N-day exponential moving average (EMA).
  • Smooth that series using another N-day EMA.
  • Smooth a third time, using a further N-day EMA.
  • Calculate the percentage difference between today's and yesterday's value in that final smoothed series.

Like any moving average, the triple EMA is just a smoothing of price data and therefore is trend-following. A rising or falling line is an uptrend or downtrend and Trix shows the slope of that line, so it's positive for a steady uptrend, negative for a downtrend, and a crossing through zero is a trend-change, ie. a peak or trough in the underlying average.

The triple-smoothed EMA is very different from a plain EMA. In a plain EMA the latest few days dominate and the EMA follows recent prices quite closely. But applying it three times ends up with weightings spread much more broadly, and the weights for the latest few days are in fact smaller than older days. The following graph shows the weightings for an N=10 triple EMA (most recent days at the left),

Triple exponential moving average weightings, N=10 (percentage versus days ago)
Triple exponential moving average weightings

The easiest way to calculate the triple EMA on successive values is just to apply the EMA three times, creating single, then double then triple smoothed series.



Williams % R Oscillator

Williams %R, or just W%R, is a technical analysis oscillator showing the current closing price in relation to the high and low of the past N days (for a given N). It was developed by trader and author Lary Williams and is normally used just in the stock market.

\%R = { close_{today} - high_{Ndays} \over high_{Ndays} - low_{Ndays} } \times 100

The W%R oscillator is an excellent barometer of overbought/oversold conditions. The full scale of oscillation is from 0 (zero) to -100. Zero representing a fully overbought condition and -100 being fully oversold. The -50 level is neutral.

W%R

An extreme overbought condition runs from -20 to zero and the area between -80 to -100 is identified as extreme oversold.

Such a scale is a little unusual and is sometimes found altered (by adding 100), but needn't cause any confusion. A value of -100 is the close today at the lowest low of the past N days, and 0 is a close today at the highest high of the past N days.

Williams used a 10 trading day period and considered values below -80 as oversold and above -20 as overbought. But they were not to be traded directly, instead his rule to buy an oversold was

  • %R reaches -100%.
  • Five trading days pass since -100% was last reached
  • %R rises above -95% or -85%.

or conversely to sell an overbought condition

  • %R reaches 0%.
  • Five trading days pass since 0% was last reached
  • %R falls below -5% or -15%.

The timeframe can be changed for either more sensitive or smoother results. Though the more sensitive you make it, the more false signals you will get. The "close-position within a range" in the %R indicator is the same as the %K stochastic oscillator, on a different scale.


Ricky Schmidt

January 11, 2007

 

For more information, please sign up here and receive my weekly newsletter. It's free of charge and you can unsubscribe at any time!  

Your Name:

Primary Email:

 

StockBreakthroughs.com > Oscillators