TradingView
LuxAlgo
Nov 2, 2023 2:50 PM

Machine Learning: Anchored Gaussian Process Regression [LuxAlgo] 

Bitcoin all time history indexINDEX

Description

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.
Comments
Tkysl
All anchored indicators are difficult to backtest and I think they are less useful when trading than others (fixed range, lookback etc.) . Thanks.
alexgrover
@Tkysl, The code is open source, up to you to use it to perform backtesting ;)
sachinbaringe15
How to apply this
joffbouge
This script is amazing. How can i change that script so it can be use on a custom time serie on another pane? I change all the (close) value by my time serie let's says (gold/silver) and i turn the indicator overlay to false. Do i need to change something else?
santos86
Perfect... Thanks for sharing... This will help to improve something I did, because I didn't know how to apply a real-time matrix correction on an already no-delay projection. It works on a spreadsheet with manual enter price values. So this is the last touch 👍
OutsourcE
Add chebyshev distance, as bands, to it, plz
aaiMutairi
👍
Sem19678
Добрый день.Огромное Вам спасибо за Ваш труд.
Neev3009
I like the concept here. Not sure if its more accurate than VIDYA or other similar reacting indicators though. Linear regression has been hard for me to get right, with out the best settings.
Pratik_4Clover
Thanks!
More