LinearRegressionSlope

Category: Indicators

The LinearRegressionSlope function in ProBuilder language calculates the slope of the linear regression line over a specified number of periods for a given price series. This indicator is primarily used to determine the direction and strength of a trend. A positive slope indicates an uptrend, while a negative slope suggests a downtrend. The magnitude of the slope gives an idea of the trend’s strength.

Syntax:

LinearRegressionSlope[N](price)

Where N is the number of periods over which the linear regression is calculated, and price refers to the price series used (e.g., close, open, high, low).

Example:

i1 = LinearRegressionSlope[10](close)
IF(i1 > 0 AND i1[1] < 0) THEN
    bullish = 1
    bearish = 0
ELSIF(i1 < 0 AND i1[1] > 0) THEN
    bullish = 0
    bearish = -1
ELSE
    bullish = 0
    bearish = 0
ENDIF
RETURN bullish, bearish

This example calculates the Linear Regression Slope of the closing prices over the last 10 periods. It then checks if the slope has changed from negative to positive (indicating a potential uptrend) or from positive to negative (indicating a potential downtrend), and assigns values to bullish and bearish accordingly.

Additional Information:

  • The Linear Regression Slope is a measure of the rate of change in price. It fits a straight line through the selected price data using the least squares method and calculates the slope of that line.
  • It is often used in conjunction with the R-squared indicator, which measures the strength of the trend. A higher R-squared value indicates a more reliable trend.
  • Understanding the direction and strength of the trend can help in making informed trading decisions, but it should not be used in isolation. Combining this indicator with others can provide a more comprehensive view of market conditions.

Related Instructions:

  • LinearRegression indicators
  • R2 indicators
  • Logo Logo
    Loading...