LuxAlgo

Machine Learning Regression Trend [LuxAlgo]

The Machine Learning Regression Trend tool uses random sample consensus (RANSAC) to fit and extrapolate a linear model by discarding potential outliers, resulting in a more robust fit.

🔶 USAGE


The proposed tool can be used like a regular linear regression, providing support/resistance as well as forecasting an estimated underlying trend.

Using RANSAC allows filtering out outliers from the input data of our final fit, by outliers we are referring to values deviating from the underlying trend whose influence on a fitted model is undesired. For financial prices and under the assumptions of segmented linear trends, these outliers can be caused by volatile moves and/or periodic variations within an underlying trend.

Adjusting the "Allowed Error" numerical setting will determine how sensitive the model is to outliers, with higher values returning a more sensitive model. The blue margin displayed shows the allowed error area.


The number of outliers in the calculation window (represented by red dots) can also be indicative of the amount of noise added to an underlying linear trend in the price, with more outliers suggesting more noise.


Compared to a regular linear regression which does not discriminate against any point in the calculation window, we see that the model using RANSAC is more conservative, giving more importance to detecting a higher number of inliners.

🔶 DETAILS

RANSAC is a general approach to fitting more robust models in the presence of outliers in a dataset and as such does not limit itself to a linear regression model.

This iterative approach can be summarized as follow for the case of our script:

  • Step 1: Obtain a subset of our dataset by randomly selecting 2 unique samples
  • Step 2: Fit a linear regression to our subset
  • Step 3: Get the error between the value within our dataset and the fitted model at time t, if the absolute error is lower than our tolerance threshold then that value is an inlier
  • Step 4: If the amount of detected inliers is greater than a user-set amount save the model
  • Repeat steps 1 to 4 until the set number of iterations is reached and use the model that maximizes the number of inliers

🔶 SETTINGS

  • Length: Calculation window of the linear regression.
  • Width: Linear regression channel width.
  • Source: Input data for the linear regression calculation.

🔹RANSAC

  • Minimum Inliers: Minimum number of inliers required to return an appropriate model.
  • Allowed Error: Determine the tolerance threshold used to detect potential inliers. "Auto" will automatically determine the tolerance threshold and will allow the user to multiply it through the numerical input setting at the side. "Fixed" will use the user-set value as the tolerance threshold.
  • Maximum Iterations Steps: Maximum number of allowed iterations.

Get access to our exclusive tools: luxalgo.com

Join our 150k+ community: discord.gg/lux

All content provided by LuxAlgo is for informational & educational purposes only. Past performance does not guarantee future results.
오픈 소스 스크립트

이 스크립트의 오써는 참된 트레이딩뷰의 스피릿으로 이 스크립트를 오픈소스로 퍼블리쉬하여 트레이더들로 하여금 이해 및 검증할 수 있도록 하였습니다. 오써를 응원합니다! 스크립트를 무료로 쓸 수 있지만, 다른 퍼블리케이션에서 이 코드를 재사용하는 것은 하우스룰을 따릅니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

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