Return the Linear Regression Slope value of selected price over the last N periods.
Syntax:
1 |
LinearRegressionSlope[N](price) |
This indicator represents the direction of the trend.
If the indicator rises above the 0 level, then we are in an uptrend and when the indicator falls below the 0 level, then we are in a downtrend.
The higher the indicator is the more the trend is important
With this indicator, we suggest that you use the R squared to confirm the trend.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
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 |