User login

  

Stochastic

Introduction

Developed by George C. Lane in the late 1950s, the Stochastic Oscillator is a momentum indicator that shows the location of the close relative to the high-low range over a set number of periods. According to an interview with Lane, the Stochastic Oscillator "doesn't follow price, it doesn't follow volume or anything like that. It follows the speed or the momentum of price. As a rule, the momentum changes direction before price." As such, bullish and bearish divergences in the Stochastic Oscillator can be used to foreshadow reversals. This was the first, and most important, signal that Lane identified. Lane also used this oscillator to identify bull and bear set-ups to anticipate a future reversal. Because the Stochastic Oscillator is range bound, is also useful for identifying overbought and oversold levels.

Interpretation

The Stochastic Oscillator measures the level of the close relative to the high-low range over a given period of time. Assume that the highest high equals 110, the lowest low equals 100 and the close equals 108. The high-low range is 10, which is the denominator in the %K formula. The close less the lowest low equals 8, which is the numerator. 8 divided by 10 equals .80 or 80%. Multiply this number by 100 to find %K %K would equal 30 if the close was at 103 (.30 x 100). The Stochastic Oscillator is above 50 when the close is in the upper half of the range and below 50 when the close is in the lower half. Low readings (below 20) indicate that price is near its low for the given time period. High readings (above 80) indicate that price is near its high for the given time period. The IBM example above shows three 14-day ranges (yellow areas) with the closing price at the end of the period (red dotted) line. The Stochastic Oscillator equals 91 when the close was at the top of the range. The Stochastic Oscillator equals 15 when the close was near the bottom of the range. The close equals 57 when the close was in the middle of the range.

Overbought Oversold

As a bound oscillator, the Stochastic Oscillator makes it easy to identify overbought and oversold levels. The oscillator ranges from zero to one hundred. No matter how fast a security advances or declines, the Stochastic Oscillator will always fluctuate within this range. Traditional settings use 80 as the overbought threshold and 20 as the oversold threshold. These levels can be adjusted to suit analytical needs and security characteristics. Readings above 80 for the 20-day Stochastic Oscillator would indicate that the underlying security was trading near the top of its 20-day high-low range. Readings below 20 occur when a security is trading at the low end of its high-low range.

Bull Bear Divergences

Divergences form when a new high or low in price is not confirmed by the Stochastic Oscillator. A bullish divergence forms when price records a lower low, but the Stochastic Oscillator forms a higher low. This shows less downside momentum that could foreshadow a bullish reversal. A bearish divergence forms when price records a higher high, but the Stochastic Oscillator forms a lower high. This shows less upside momentum that could foreshadow a bearish reversal. Once a divergence takes hold, chartists should look for a confirmation to signal an actual reversal. A bearish divergence can be confirmed with a support break on the price chart or a Stochastic Oscillator break below 50, which is the centerline. A bullish divergence can be confirmed with a resistance break on the price chart or a Stochastic Oscillator break above 50.

50 is an important level to watch. The Stochastic Oscillator moves between zero and one hundred, which makes 50 the centerline. Think of it as the 50 yard line in football. The offense has a higher chance of scoring when it crosses the 50 yard line. The defense has an edge as long as it prevents the offense from crossing the 50 yard line. A Stochastic Oscillator cross above 50 signals that prices are trading in the upper half of their high-low range for the given look-back period. This suggests that the cup is half full. Conversely, a cross below 50 means prices are trading in the bottom half of the given look-back period. This suggests that the cup is half empty.

Bull Bear Set-ups

George Lane identified another form of divergence to predict bottoms or tops. A bull set-up is basically the inverse of a bullish divergence. The underlying security forms a lower high, but the Stochastic Oscillator forms a higher high. Even though the stock could not exceed its prior high, the higher high in the Stochastic Oscillator shows strengthening upside momentum. The next decline is then expected to result in a tradable bottom. Chart 8 shows Network Appliance (NTAP) with a bull set-up in June 2009. The stock formed a lower high as the Stochastic Oscillator forged a higher high. This higher high shows strength in upside momentum. Remember that this is a set-up, not a signal. The set-up foreshadows a tradable low in the near future. NTAP declined below its June low and the Stochastic Oscillator moved below 20 to become oversold. Traders could have acted when the Stochastic Oscillator moved above its signal line, above 20 or above 50. Alternatively, NTAP subsequently broke resistance with a strong move.

A bear set-up occurs when the security forms a higher low, but the Stochastic Oscillator forms a lower low. Even though the stock held above its prior low, the lower low in the Stochastic Oscillator shows increasing downside momentum. The next advance is expected to result in an important peak. Chart 9 shows Motorola (MOT) with a bear set-up in November 2009. The stock formed a higher low in late-November and early December, but the Stochastic Oscillator formed a lower low with a move below 20. This showed strong downside momentum. The subsequent bounce did not last long as the stock quickly peaked. Notice that the Stochastic Oscillator did not make it back above 80 and turned down below its signal line in mid December.

Conclusions

While momentum oscillators are best suited for trading ranges, they can also be used with securities that trend, provided the trend takes on a zigzag format. Pullbacks are part of uptrends that zigzag higher. Bounces are part of downtrends that zigzag lower. In this regard, the Stochastic Oscillator can be used to identify opportunities in harmony with the bigger trend.

The indicator can also be used to identify turns near support or resistance. Should a security trade near support with an oversold Stochastic Oscillator, look for a break above 20 to signal an upturn and successful support test. Conversely, should a security trade near resistance with an overbought Stochastic Oscillator, look for a break below 80 to signal a downturn and resistance failure.

The settings on the Stochastic Oscillator depend on personal preferences, trading style and timeframe. A shorter look-back period will produce a choppy oscillator with many overbought and oversold readings. A longer look-back period will provide a smoother oscillator with fewer overbought and oversold readings.

Like all technical indicators, it is important to use the Stochastic Oscillator in conjunction with other technical analysis tools. Volume, support/resistance and breakouts can be used to confirm or refute signals produced by the Stochastic Oscillator.

 

Display/hide source code
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using PTLRuntime.NETScript;
using System.Drawing;
 
namespace ind
{
        //---------------------------------------------------
        // Project: Stoch
        // Type: Indicator
        // Author: PFSoft LLC
        // Company: PFSoft LLC /www.pfsoft.com/
        // Copyright: (C) PFSoft LLC Dnepopetrovsk. Ukraine
        // Created: Nov, 28,2006
        //---------------------------------------------------
    public class STOCHASTIC : NETIndicator
    {
  
        public STOCHASTIC()
            : base()
        {
                ProjectName = "Stochastic";
                Comments = "Shows the location of the current close relative to the high/low range over a set number of periods";
            SetIndicatorLine("line1", Color.Green, 1, LineStyle.ShapedDotChart);
            SetIndicatorLine("line2", Color.LightSkyBlue, 1, LineStyle.ShapedChart);
            SetIndicatorLine("line3", Color.Red, 1, LineStyle.SimpleChart);
            SetIndicatorLine("line4", Color.Yellow, 1, LineStyle.ShapedChart);
            SeparateWindow = true;
        }
 
         [InputParameter("Period of indicator:", 0)]
        public int IndPeriod = 10;
                [InputParameter("Smoothing:",1)]
        public int Smooth = 3;
        [InputParameter("Double smoothing:", 2)]
        public int DoubleSmooth = 3;
        
        [InputParameter("Up line level: ", 3, 0.0, 100.0, 1, 0.1)]
        public double UpLevel = 80.0;
        
        [InputParameter("Bottom line level: ", 4, 0.0, 100.0, 1, 0.1)]
        public double BottomLevel = 20.0;
        
        public const int MAIN_BUFFER = 0;
        
        public override void OnQuote()
        {
                        platform.SetValue(2, 0, UpLevel);
                    platform.SetValue(3, 0, BottomLevel);
                    int i = 0; 
                    int period = 0;
                    int count = platform.BarsCount(platform.Symbol, platform.Period);
                    double high = -1.0;
                    double low = 10000000;
                    while((i<count) && (period<IndPeriod))
                    {
                        if(!ptl.IsEmpty(i))
                        {
                            double price = ptl.High[i];
                            if(price>high)
                                high = price;
                            price = ptl.Low[i];
                            if(price<low)
                                low = price;    
                            period++;    
                        }
                        i++;        
                    }
                    
                    high -= low;
                    if(high>0.0)
                    {
                        double k;
                        k = 100.0*( (ptl.Close-low)/high );
                        platform.SetValue(0, 0, k);
                    };
                    
                    // Calculation of smoothed curve
                    i = 0;
                    double summa = 0.0;
                    while( (i<count) && (i<Smooth) )
                    {   
                        summa += platform.GetValue(0, i);
                        i++;
                    }
                    
                    platform.SetValue(1, 0, summa/Smooth);
        }
    }    
}
12345

Comments