LuxAlgo

Machine Learning: Anchored Gaussian Process Regression [LuxAlgo]

Machine Learning: Anchored Gaussian Process Regression is an anchored version of Machine Learning: Gaussian Process Regression.

It implements Gaussian Process Regression (GPR), a popular machine-learning method capable of estimating underlying trends in prices as well as forecasting them. Users can set a Training Window by choosing 2 points. GPR will be calculated for the data between these 2 points.

Do remember that forecasting trends in the market is challenging, do not use this tool as a standalone for your trading decisions.

🔶 USAGE

When adding the indicator to the chart, users will be prompted to select a starting and ending point for the calculations, click on your chart to select those points.


Start & end point are named 'Anchor 1' & 'Anchor 2', the Training Window is located between these 2 points. Once both points are positioned, the Training Window is set, whereafter the Gaussian Process Regression (GPR) is calculated using data between both Anchors.

The blue line is the GPR fit, the red line is the GPR prediction, derived from data between the Training Window.

Two user settings controlling the trend estimate are available, Smooth and Sigma.


Smooth determines the smoothness of our estimate, with higher values returning smoother results suitable for longer-term trend estimates.


Sigma controls the amplitude of the forecast, with values closer to 0 returning results with a higher amplitude.


One of the advantages of the anchoring process is the ability for the user to evaluate the accuracy of forecasts and further understand how settings affect their accuracy.

The publication also shows the mean average (faint silver line), which indicates the average of the prices within the calculation window (between the anchors). This can be used as a reference point for the forecast, seeing how it deviates from the training window average.

🔶 DETAILS

🔹 Limited Training Window

The Training Window is limited due to matrix.new() limitations in size.


When the 2 points are too far from each other (as in the latter example), the line will end at the maximum limit, without giving a size error.


The red forecasted line is always given priority.

🔹 Positioning Anchors

Typically Anchor 1 is located further in history than Anchor 2, however, placing Anchor 2 before Anchor 1 is perfectly possibly, and won't give issues.

🔶 SETTINGS

  • Anchor 1 / Anchor 2: both points will form the Training Window.
  • Forecasting Length: Forecasting horizon, determines how many bars in the 'future' are forecasted.
  • Smooth: Controls the degree of smoothness of the model fit.
  • Sigma: Noise variance. Controls the amplitude of the forecast, lower values will make it more sensitive to outliers.

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.
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?