# Slope

This is an old revision of the document!

# Slope

## Introduction

The slope indicator measures the rise-over-run of a linear regression, which is the line of best fit for a price series. Fluctuating above and below zero, the Slope indicator best resembles a momentum oscillator without boundaries. It is not well suited for overbought/oversold levels, but can measure the direction and strength of a trend. It can also be used with other indicators to identify potential entry points within an ongoing trend.

## Calculation

Slope is based on a linear regression (line of best fit). Even though the formula for a linear regression is beyond the scope of this article, a linear regression can be shown using the Raff Regression Channel in SharpCharts. This indicator features a linear regression in the middle with equidistant outer trend lines. Slope equals the rise-over-run for the linear regression. Rise refers to the price change. Run refers to the timeframe. A 20-day Slope would be the rise-over-run of a 20-day linear regression. If the rise is 4 points and the run is two days, then the slope would be 2 (4/2 = 2). If the rise is -6 points and the run is 2, then the slope would be -3 (6/2 = 3). In general, an advancing period has a positive slope and a declining period has a negative slope. The steepness depends on the sharpness of the advance or decline.

Chart 1 shows SPY with three different 20-day periods (orange, yellow, blue). A 20-day Raff Regression Channel is shown for each 20-day period. The linear regression, in the middle, represents the “line of best fit” for the 20 data points. The dotted lines mark the end of the 20-day period and the value of the slope at that price point. The first period is relatively flat and the slope is barely positive. The second period is up and the slope is clearly positive. The third period is down and the slope is negative. Keep in mind that the Slope changes as old data points are dropped off and new data points are added.

## Trend Identification

Slope can be used to quantify the trend. A positive slope is by definition an uptrend. Similarly, a negative slope defines a downtrend. Chart 2 shows the Dow Industrials with a 52-week Slope (one year). The red dotted lines show the Slope turning negative, while the green dotted lines show the slope turning positive. The 52-week Slope was positive for around two years (2006-2007) and then turned negative in February 2008. Even though the Dow bottomed in March 2009 and moved sharply higher, the 52-week Slope did not cross back into positive territory until September 2009. Notice that the slope does not predict the trend. Instead, it follows the trend or the price points. This means there will be some lag.

## Trend Strength

Directional movement can also be important when analyzing the slope. A negative and rising slope shows improvement within a downtrend. A positive and falling slope shows deterioration within an uptrend. Chart 3 shows the Nasdaq 100 ETF (QQQQ) with the 100-day Slope. A 20-day simple moving average was added to identify upturns and downturns. A Slope is rising when above its 20-day SMA and falling when below. Four key crossovers are identified on this chart (green/red arrows). Notice that the crossovers occurred before the Slope turned negative or positive. This is like a leading indication for the Slope. Also, notice the bounce after the negative cross in July 2008 and the retest after the positive cross in January 2009. These early slope reversals foreshadowed a move into positive territory or a trend change, but you should not expect an extended move after every moving average crossover. The 100-day Slope moved below its 20-day SMA in August 2009, yet QQQQ kept moving higher. A declining and positive Slope reflects less steepness in the advance. Notice how the 100-day Slope remained positive as QQQQ continued higher from September 2009 to January 2010.

Slope alone cannot be used to participate in an ongoing trend, but it can be used with other indicators to identify potential entry points. In particular, Slope can be used for trend identification to establish a trading bias. A positive slope dictates a bullish bias, while a negative Slope dictates a bearish bias. Once a trading bias is established, a momentum oscillator can be used to identify potential entry points. The choice of momentum oscillator is really a personal preference. The example with Apple uses the 100-day Slope with 10-day Williams %R. The look-back period for the Slope should be significantly longer than the look-back period for the momentum oscillator. The Slope defines the bigger trend, while the momentum oscillator represents a subset of that trend. Chart 4 shows the 100-day Slope moving above zero in July to establish a bullish bias. Only bullish signals are considered for the momentum oscillator. These include oversold readings, centerline crossovers, or signal line crossovers. Williams %R does not have a signal line, but MACD and PPO do. The blue dotted lines show when 10-day Williams %R moves below -80% to become oversold. Notice that these readings correspond with short pullbacks in the stock. Except for the last oversold reading in early December, Apple resumed its uptrend soon after these oversold readings.

## Relative Strength

The Slope of two (or more) securities can be compared to identify relative strength and relative weakness. The chart below shows Amazon (AMZN) with the S&P 500. Both securities are shown with the 20-day Slope (black). The blue vertical line marks a point in early November when Amazon had a positive Slope and the S&P 500 had a negative Slope. Amazon was clearly outperforming the S&P 500 at this time. In fact, when the S&P 500 bottomed in early November, Amazon led the way higher with a move from 117 to 143. Notice that Amazon moved higher even as the Slope moved lower. The Amazon Slope turned negative in mid-December and the S&P 500 Slope was still positive. This situation repeated the second week of January. Based on the Slope comparison, Amazon went from relative strength in November to relative weakness in December and January. During these two months, the 20-day linear regression for Amazon was sloping down while the 20-day linear regression for the S&P 500 was sloping up.

## Conclusion

Slope measures the rise-over-run of a linear regression. In general, an uptrend is present when Slope is positive and a downtrend exists when the slope is negative. The timeframe depends on the number of days. 10 days covers a short-term trend, 100 days a medium-term trend, and 250 days a long-term trend. As with typical trend-following indicators, Slope lags price and reverses after an actual top or bottom. This does not, however, detract from its usefulness. Trend identification and trend strength are important tools, even for traders. As with moving averages, Slope can be used with momentum indicators to participate in an ongoing trend. Click here for a live chart with the Slope indicator.

## Using with SharpCharts

Slope can be found near the bottom of the indicator list on SharpCharts. The default parameters (20) can be changed to suit the desired timeframe. Like all indicators, Slope can be positioned above the price plot, behind the price plot or below the price plot. In addition, users can click the green arrow next to advanced options to apply a moving average or another indicator to Slope.

## Suggested Scans

### Oversold in an Uptrend

This scan reveals stocks that are oversold (short-term Williams %R below -80) in a medium-term uptrend (positive 100-day Slope).

```[type = stock] AND [country = US]
AND [Daily SMA(20,Daily Volume) > 40000]
AND [Daily SMA(60,Daily Close) > 5]

AND [Daily Slope(100,Daily Close) > 0]
AND [Daily Williams %R(10) < -80]```

### Overbought in a Downtrend

This scan reveals stocks that are overbought (short-term Williams %R above -20) in a medium-term downtrend (negative 100-day Slope).

```[type = stock] AND [country = US]
AND [Daily SMA(20,Daily Volume) > 40000]
AND [Daily SMA(60,Daily Close) > 5]

AND [Daily Slope(100,Daily Close) < 0]
AND [Daily Williams %R(10) > -20]```

For more details on the syntax to use for Slope scans, please see our Scanning Indicator Reference in the Support Center.

## Further Study

Perry Kaufman's Trading Systems and Methods covers a wide variety of topics, including a section focused on regression analysis using linear regressions.

 Trading Systems and Methods Perry Kaufman   