Return the R-Squared indicator value over the last N periods (error rate of the linear regression on price).
Syntax:
1 |
R2[N](price) |
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
i1 = R2[20](close) LR1 = linearregression[20](close) LR2 = linearregression[20](close[1]) if(i1>0.4 AND LR1<LR2) THEN bullish = 0 bearish = -1 ELSIF i1>0.4 AND LR1>LR2 THEN bullish = 1 bearish = 0 ELSE bullish = 0 bearish = 0 ENDIF RETURN bullish, bearish |