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.


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.


🔹 Limited Training Window

The Training Window is limited due to 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.


  • 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 LuxAlgo indicators:

Join our 100k+ community:

All scripts & content provided by LuxAlgo are for informational & educational purposes only. Past performance does not guarantee future results.
Skript med en öppen källkod

I sann TradingView-anda har författaren publicerat detta skript med öppen källkod så att andra handlare kan förstå och verifiera det. Hatten av för författaren! Du kan använda det gratis men återanvändning av den här koden i en publikation regleras av våra ordningsregler. Du kan ange den som favorit för att använda den i ett diagram.

Frånsägelse av ansvar

Informationen och publikationerna är inte avsedda att vara, och utgör inte heller finansiella, investerings-, handels- eller andra typer av råd eller rekommendationer som tillhandahålls eller stöds av TradingView. Läs mer i Användarvillkoren.

Vill du använda det här skriptet i ett diagram?