This indicator calculates the position of the current price in relation to the highest high and the lowest low of the last *n* bars. The idea being that when the market is trending up, price is closer to the highs of the bars and when the market is trending down price tends to be closer to the lows of the bars.

The Stochastic uses a scale from 0 to 100 and has an Overbought line at 80 and an Oversold line at 20.

There are two speeds of Stochastics that are available – Fast and Slow – one being a derivative of the other.

**CALCULATION**

For the Fast Stochastic we want to take the highest high and the lowest low of the past *n* bars like so:

*%K = (CurrentPrice – Lowest(Low, n)) / (Highest(High, n) – Lowest(Low, n)) * 100;*

%K represents the Stochastic. The *n* is period lookback used and is usually set to 14 by default.

There is another plot called the %D which Lane contended was good to find divergence in the market. The %D is calculated simply by averaging the %K as follows:

*%D = Average(%K, n);*

The *n* in this case is typically set to 3 by default.

Given the focus on the Fast %D for divergence, the Slow Stochastic was created to emphasize its importance. To do this version, you continue with the formula above by doing:

*Slow%K = %D;
*

As you can see, to make the Slow Stochastic, we simply get the %D from the fast stochastic and use it as the Slow%K and then we smooth the Slow%K to make the Slow%D. Like the Fast Stochastic, the typical period (*n*) used for the Slow%D is 3 by default. This effectively smooths out a lot of the noise of the faster version.

In summary:

Fast %K = %K basic calculation

Fast %D = 3 period average of Fast %K

Slow %K = Fast % D

Slow %D = 3 period average of Slow %K

**USES**

Like I say for all oscillators, do not expect the market to reverse when the oscillator tells you it is Overbought or Oversold – they could stay that way for a LONG time if there is a lot of buying or selling pressure. However, the Stochastic is real good at showing a decline of momentum.

Stochastic is very good at showing a divergence in the market – for instance in an uptrend the market is making higher highs but the Stochastic is making lower highs – THAT is a divergence and usually means the market is getting tired and about to reverse. The same goes for lower lows in the market and higher lows in the Stochastic – a signal that the market could be ready for a reversal to the upside.

Sometimes traders like to treat the %D as a trigger line – for instance, when the %K crosses over the %D and the 20 line, there is a Long condition. Likewise, when the %K crossed under the %D and the 80 line, there is a Short condition. However be cautioned in that this doesn’t happen all the time. When there is a strong trend, a cross of the %D can be a fake out.

]]>The Relative Strength Index (RSI) is an oscillator that measures the momentum of price change. It uses a scale between zero and 100 and is considered “overbought” when over 70 and “oversold” when below 30. Like many technical analysis indicators, the RSI has a lookback period where it compares price changes for a specific period of time – this is typically set to 14.

**CALCULATION**

To calculate the RSI, you take the average gains from the last *n* days and divide that by the average losses from the same *n* days. For instance:

*RS = Average(Gains, nPeriod) / Average(Losses, nPeriod);*

The result is then normalized to a 0 to 100 scale by doing:

*RSI = 100 – (100 / (1+RS)); *

The original calculation uses a Simple Moving Average for the gains and losses, but some version will use the Exponential Moving Average. I have even seen the Hull Moving Average used for an extra smooth and responsive RSI movement.

**USES**

The purpose of most oscillators is to show when a security is over extended to the upside or the downside. When the RSI is above 70 it is considered Overbought and when it is below 30 it is Oversold. And also like most oscillators, you cannot trust that when a security is Overbought or Oversold that it will change its trend any time soon – sometimes trends can last for weeks before price returns to the mean.

So what I use the RSI for? The RSI can tell you the strength of directional movement. Given the typical 14 day period, when the RSI pegs 100, it means there has not been a losing day in the last 14 days. Likewise, if the RSI hits 0 (zero) then there have been no gains in the last 14 days. Obviously those conditions cannot last forever, but given that the Overbought and Oversold zones are 30 points each, it is possible they can last a long while. But know that the steeper the directional move is in the RSI, the stronger the trend is in the market.

This is to say, use the RSI for directional momentum rather than a signal that the market is about to turn.

]]>The MACD indicator is usually made up using three plots – the MACD, the SignalLine, and the MACDHisto (sometimes called Divergence).

Here is how the MACD is created:

**MACD**= the difference between two exponential moving averages – typically using the 12 and 26 periods.**SignalLine**= the 9 period exponential moving average of the MACD**MACDHisto**= the difference between the MACD and SignalLine

The MACD and MACDAvg are plotted using simple lines whereas the MACDHisto uses and histogram as shown below:

In the chart above, you will see that the MACD line crosses above or below the zero line whenever the 12 EMA crosses above or below the 26 EMA. Likewise, the MACDHisto crosses above or below the zero line when the MACD crosses above or below the SignalLine. Using these signals along with the direction the MACD is pointing can imply when the market is about to reverse directions.

The MACDHisto is also thought of as Divergence. Note the chart below that when price makes a new high or low and the MACDHisto fades instead, this is a signal of a change in direction.

Have you tried the MACD in your trading strategies successfully? Do you like to use the traditional 12, 26, 9 periods or do you have your own? As always, I welcome your comments.

Bruce

]]>- All moving averages for trading use a series of values. Even though these values can be from any numeric series, the Close from a series of price bars is most commonly used and will be assumed going forward in this article.
- All moving averages define the number of prices or bars to include in the calculation. This is many times called the Length, or Period or Lookback.
- All moving averages are lagging indicators.

The idea of using a lagging indicator may sound inferior, however that is not an accurate assessment. The lagging attribute of a moving average can help a trader stay in a trade longer by smoothing out the price action noise that can cause knee jerk reactions. THAT is a good thing.

I will try to enumerate and discuss all of the Moving Averages I come across, but first, let’s start at the beginning. The simplest, ,most basic moving average of all – the **Simple Moving Average**.

We all know the **Simple Moving Average** (SMA). It takes the Close from a define range of bars (the Length), adds them together, and then divides the result by the Length. For example, with *x* representing the Length:

*SMA(x) = (close[x] + close[x-1] + close[x-2] + . . . + close[x-x]) / x*

It’s that simple! And make note that all the Closes are equally weighted. In other words, each price point impacts the result equally.

The chart above shows examples of the 8, 50, and 200 Simple Moving Averages which are perhaps the most widely used periods. It is said when the 50 SMA crosses above the 200 SMA it is called the Golden Cross – whereas when the 50 SMA crosses below the 200 SMA it is called the Death Cross.

Remember that the Simple Moving Average had equal weighting for each of its Closes? Well that is what makes the **Weighted Moving Average** (WMA) different – each Close is weighted with the most recent bar having the most weight. The weighting mechanism first multiplies each Close by the number of bars away from the oldest bar in the period (1 to 10) and adds them together for a WeightedSum. For instance, with a WMA length of 10, the 10th bar in the series would be multiplied by Length (10) times 1 and the current bar would be multiplied by Length (10) times 10. So the current bar has the most weight.

Now to average out the weighting, we add together the digit position of the number of bars in the series from 1 to 10 (1 +2+3+4+5+6+7+8+9+10) and uses it to divide into the WeightedSum for the WMA result. Here is example code for the WMA:

*for Value1 = 0 to Length – 1*

* begin
WeightedSum = WeightedSum + ( Length – Value1 ) * Close[Value1] ;*

*CumulativeWeights = ( Length + 1 ) * Length * .5 ;*

* WMA = WeightedSum / CumulativeWeights ;*

This calculation divides the weighting across the bars on a consistent incline towards the most recent bar which has the most weight. Below is a chart comparing the WMA with the SMA.

Notice the WMA seems to react a little faster than the SMA. This doesn’t make it better, it is simply a different way to analyze the chart.

It has been said that the **Exponential Moving Average** (EMA) is one of the most reliable moving averages to use for day trading. Like the Weight Moving Average, the EMA is also weighted – but calculates the weighting in a different way.

The EMA calculation first creates a “Weighting Factor” based on the Length:

*WeightingFactor = 2 / (Length + 1);*

The first EMA calculation simply begins with the Close of the starting bar. To continue the EMA for subsequent bars, we take the difference between the current Close price and the previous EMA and multiply that by the WeightingFactor. We then add to that the previous EMA for the final result.

*EMA[current] = EMA[previous] + WeightingFactor * (Close – EMA[previous]);*

In the chart below, we show a comparative study.

The chart compares the EMA with the previous moving averages we discussed (SMA and WMA). You will notice that the EMA has a slightly different action – a bit faster reaction than the SMA and not as tight to price as the WMA. Many times it plots in between the two.

As mentioned in the previous sections, the **WMA** and **EMA** are weighted averages. However, the **SMA** is not weighted at all – and each of the bars within its define Length or Period are given equal weight in coming up with the resulting average as shown below.

The chart shows a 10 period SMA and the impact each of the bars within the period have on the result – with 1 being the current bar. Each bar is given equal representation – 10% each of 10 bars.

However, what about the **WMA** and the **EMA**?

The **WMA** re-evaluates each period for every bar giving the most recent bar the highest weight. The weighting algorithm that the WMA uses declines the weighting consistently to the end of the period each and every bar as shown below.

Noting that 1 is the current bar, you will notice the weighting has a consistent and straight decline to the last bar in the series. Even though each bar has different weighting, all the percentages of weight added together still add up to 100% showing that the resulting WMA is based solely on the 10 bars of the define period.

However, the **EMA** is a different beast. In the previous section, you may have noticed from the calculation that the Length is only used to calculate the WeightingFactor AND the resulting value uses the previous EMA calculation to create the new EMA. This means that even thought a Length has been defined, it does not mean that the result is totally based on just the last 10 bars like the SMA or WMA. Rather, the EMA uses the residual results of past EMA values vs the current price – previous EMA values going back since the beginning of the chart, albeit in only minute amounts for the older bars. Because of this, the resulting EMA value is based only partially on the bars from the defined period by about 86.8%. One would have to go out over 2 times the period before we start approaching close to 100% and older bars would have little to no effect. Here’s a chart showing the weighting for a 10 period EMA.

The weight distribution is similar to the WMA except the columns have a descending exponential curve from the current bar (1) and continues until it simply doesn’t exist anymore. For a 10 period EMA, the weight of the current bar is 18.18% and it goes down from there. In fact, the weight of each bar (for a 10 period EMA) is 18.18% less than the next one.

After going thought this study of the three most used moving averages, it might not surprise you if I say that one of them is not better than the others. They are simply different, but each has their pros and cons.

The SMA is an equal weighted moving average that is quick to calculate and is used perhaps more than any other moving average. It’s the original! The SMA tends to lag more than most other moving averages, but that can actually help you stay in a trade longer by avoiding the noise and whipsaws of the market.

The WMA is much quicker to react to market changes than the SMA. Being quicker can help make quicker decisions, but quicker also reveals more noise. The WMA is probably used less than either the SMA or EMA.

And the EMA seems to be in the middle – the Goldilocks of the group – faster than the SMA and a bit more lagging than the WMA.

The best thing to do is try all three on the charts you like to use and see which one feels right – and then stick to it so you will be able to learn how it moves with the market.

So which Period or Length should be used with these moving averages? It has been said that there is a moving average for every marker – you can curve fit any average to work. However, there are typical moving averages that are used in the market place.

For the SMA, the 50 and 200 period averages are fairly global in use. In fact, when the 50 SMA crosses above the 200 SMA, that is referred to as the Golden Cross showing a bullish trend is ahead. However, when the 50 crosses below the 200, that is called the Death Cross denoting a bearish trend is happening. The SMA is also used inside many indicators including the Bollinger Bands, Keltner Channel, RSI etc.

For some reason, I have noticed that most of the EMA periods I have seen used are based on Fibonacci numbers (3, 5, 8, 13, 21, 34, 55, etc). Many believe the 34 EMA is a strong moving average. The EMA is also the moving average of choice for the MACD indicator and sometimes the Stochastic.

It should also be noted that SMAs can have equivalents across different timeframes. For instance, if you have a 5 SMA on a 60 minute chart – you can use a 20 SMA on a 15 minute chart to see equivalent MA/price crosses – almost like having a closeup version. Simply multiply the period used in the 60 minute chart by 4 since there are four 15 minute segments in 60 minutes. You can do this with any timeframe equivalents – but it will not work as accurately when using WMAs and EMAs.

There are a few techniques for using moving averages.

**Price Cross** – some like to enter or exit a trade when price closes above or below an particular moving average. Since price can change so frequently, some let the price close twice above or below as a confirmation before making a trade commitment. Popular moving averages to use for this method are typically the 5 or 8 SMA and EMA. Depending on how long you want to stay in a trade, the 13 or even 21 have been used to determine a trade decision.

**MA Cross** – Given the lagging quality of moving averages, some like to enter a trade when a moving average with a small period (Fast) crosses above or below a moving average with a larger period (Slow). Since these moving averages smooth out the noise, it is believed that trend changes are fairly reliable for the MA Cross. Popular pairs for MA Crosses are:

- 8 and 20 SMAs
- 10 and 30 SMAs
- 8 and 13 EMAs
- 50 and 200 SMAs (Used for overall trend direction)

**MA Alignment** – When you have multiple moving averages on your chart, you can determine the overall direction of the market by ensuring that all of the moving averages are “stacked” in the proper order. For instance, if you have three moving averages and they are stacked with the fastest on top and the slowest at the bottom (8, 20, 50), then the market will be bullish. If the stack is reversed (50, 20, 8) then the market is bearish. If the moving averages are out of alignment from each other, then the market could either be in an accumulation/distribution mode (flat and choppy) or going through a reversal.

There is actually no conclusion as there are so many other types of moving averages out there to discuss. But those will be save for other articles.

– Bruce

]]>