tbiktag

Moving Regression

Moving Regression is a generalization of moving average and polynomial regression.

The procedure approximates a specified number of prior data points with a polynomial function of a user-defined degree. Then, polynomial interpolation of the last data point is used to construct a Moving Regression time series.

Application:
Moving Regression allows one to smooth noise on the analyzed chart, assess momentum, confirm trends, and establish areas of support and resistance .
In addition, it can be used as a simple stand-alone forecasting method to identify trend direction and trend​ reversal points. When the local polynomial is predicted to move up in the next time step, the color of the Moving Regression curve will be green. Otherwise, the color of the curve is red. This function is (de)activated using the Predict Trend Direction flag.

Selecting the ​model parameters:
The effects of the moving window Length and the Local Polynomial Degree are confounded. This allows for​ finding the optimal trade-off between noise (variance) and lag (bias). Higher Length and lower Polynomial Degree (such as 1, i.e. linear), will result in "smoother" time series but at the cost of greater lag. Increasing the Polynomial​ Degree to, for example, 2 (squared) while maintaining the Length will diminish the lag and thus compromise the noise-lag tradeoff.

Relation to other methods:
When the degree of the local polynomial is set to 0 (i.e., fitting data to a constant level), the Moving Regression time series exactly matches the Simple Moving Average of the same length.
릴리즈 노트: minor corrections
오픈 소스 스크립트

진정한 TradingView의 정신에 따라, 이 스크립트의 작성자는 스크립트를 오픈소스로 게시했기에 거래자들이 이해하고 확인할 수 있습니다. 작가님께 건배! 스크립트를 무료로 사용할 수 있지만, 게시물에서 이 코드를 재사용하는 것은 하우스룰을 따릅니다. 당신은 스크립트를 차트에 사용하기 위해 그것을 즐겨찾기 할 수 있습니다.

차트에 이 스크립트를 사용하시겠습니까?

코멘트

500 코인
+1 응답
tbiktag PineCoders
@PineCoders, Many thanks!
응답
Outstanding work, thanks for sharing!
+1 응답
tbiktag allanster
@allanster, Thank you mate!
응답
This looks like the Least Squares Moving Average
+1 응답
tbiktag justinsandell
@justinsandell, In my experience, the name "Least Squares Moving Average" is commonly associated with local linear regression. The current script is built on polynomial regression and therefore can be viewed as a generalization. But of course you can achieve the local linear regression by setting Polynomial Degree to 1.
응답
This looks splendid. However I don't get the blue line to show up nor can I find how to activate it in settings. Help!
Thanks
응답
MMC11 MMC11
tbiktag- Perhaps you could send me the settings you use for a stock, because the one's I have do not produce two lines. No matter how I change them.
응답
tbiktag MMC11
@MMC11, the script produces only one line as output, i.e. the MR curve (plotted in green-red color). The blue line that you see in the preview is just the closing price.
응답
MMC11 tbiktag
@tbiktag, THAN!KS
응답