# Machine Learning: Anchored Gaussian Process Regression

Machine Learning: Anchored Gaussian Process Regression is an indicator on [Vela](https://vela.luxalgo.com/chart), our next-generation charting platform, written in Pine Script®.

Gaussian process regression trained on the slice of history you choose: drop two anchors on the chart and the model fits the span between them, up to an internal size limit, then projects a forecast forward. Smooth and Sigma shape the fit and its amplitude, while a mean-price line benchmarks how far the forecast strays from the training window's average.

- Indicator in the LuxAlgo Library, by LuxAlgo, published Nov 2, 2023.
- Access: free.
- Concepts: [Gaussian Process Regression](https://www.luxalgo.com/library/concept/gaussian-process-regression/) (primary), [Kernel Regression](https://www.luxalgo.com/library/concept/kernel-regression/)
- Open on Vela: https://vela.luxalgo.com/chart?pineScriptCodeId=cmpwn3att004kvhsgv5n842ls
- Page: https://www.luxalgo.com/library/indicator/machine-learning-anchored-gaussian-process-regression/

**Machine Learning: Anchored Gaussian Process Regression** hands you control of the training set: place two anchors on the chart and the model fits a [kernel-based regression](https://www.luxalgo.com/library/concept/kernel-regression/) to the price data between them, drawing the fit as a blue line and extending a red forecast beyond it. Anchoring makes experimentation honest: you can see exactly which regime the estimate learned from and how each setting reshapes the projection.

A faint silver line plots a moving average with the Training Window's length from Anchor 1 onward; at Anchor 2 it equals the window's average price, a simple benchmark for judging how far the forecast deviates from the window's average.

## How to Trade the Machine Learning: Anchored Gaussian Process Regression?

- **Blue line**: the model's fit across the window defined by Anchor 1 and Anchor 2.
- **Red line**: the forward projection computed from that window, a trend scenario, never a standalone entry trigger.
- **Forecast versus mean line**: comparing the two shows at a glance how far the projection strays from the window's average price.
- **Regime testing**: re-anchor across different market phases to compare how your Smooth and Sigma choices hold up.

The Training Window has an internal size cap: anchors set too far apart draw up to the limit and stop, with the red forecast taking priority. Anchor order does not matter: placing Anchor 2 before Anchor 1 works fine.

## Machine Learning: Anchored Gaussian Process Regression Settings

- **Anchor 1 / Anchor 2**: the start and end points of the Training Window.
- **Forecasting Length**: how many bars ahead the forecast extends.
- **Smooth**: higher values produce smoother, longer-term trend estimates.
- **Sigma**: controls noise variance; values near zero increase sensitivity and amplify the forecast.

## Frequently Asked Questions

### How does this differ from the rolling GPR indicator?

The original [Machine Learning: Gaussian Process Regression](https://www.luxalgo.com/library/indicator/machine-learning-gaussian-process-regression/) always trains on the most recent bars; the anchored build lets you pin the window to any segment you choose, better for studying specific regimes and validating settings.

### Why does my fit line start after my first anchor?

The Training Window is size-limited, so with widely spaced anchors the model trains on the bars leading up to Anchor 2, up to the maximum, and the blue fit begins after Anchor 1 without raising an error. Bring the anchors closer together to fit the full span.

### How do I add this indicator to my chart?

Free of charge. The tool is part of the LuxAlgo Library, and this page is all you need to get it running. You can also copy the source code from this page and run it anywhere Pine Script® runs.

## Related indicators

- [Machine Learning: Gaussian Process Regression](https://www.luxalgo.com/library/indicator/machine-learning-gaussian-process-regression/) (Gaussian Process Regression): markdown at https://www.luxalgo.com/library/indicator/machine-learning-gaussian-process-regression.md
- [Nadaraya-Watson Smoothers](https://www.luxalgo.com/library/indicator/nadaraya-watson-smoothers/) (Kernel Regression): markdown at https://www.luxalgo.com/library/indicator/nadaraya-watson-smoothers.md
- [Nadaraya-Watson Envelope](https://www.luxalgo.com/library/indicator/nadaraya-watson-envelope/) (Kernel Regression): markdown at https://www.luxalgo.com/library/indicator/nadaraya-watson-envelope.md
- [Gaussian Volume Profile](https://www.luxalgo.com/library/indicator/gaussian-volume-profile/) (Kernel Density Estimation): markdown at https://www.luxalgo.com/library/indicator/gaussian-volume-profile.md
- [KDE Value Clouds](https://www.luxalgo.com/library/indicator/kde-value-clouds/) (Kernel Density Estimation): markdown at https://www.luxalgo.com/library/indicator/kde-value-clouds.md
- [Structural SVM Ranker](https://www.luxalgo.com/library/indicator/structural-svm-ranker/) (Support Vector Machines): markdown at https://www.luxalgo.com/library/indicator/structural-svm-ranker.md
- [Decision Trees](https://www.luxalgo.com/library/indicator/decision-trees/) (Machine Learning): markdown at https://www.luxalgo.com/library/indicator/decision-trees.md
- [Gradient Boosting](https://www.luxalgo.com/library/indicator/gradient-boosting/) (Machine Learning): markdown at https://www.luxalgo.com/library/indicator/gradient-boosting.md

---

Source: https://www.luxalgo.com/library/indicator/machine-learning-anchored-gaussian-process-regression/ (LuxAlgo Library). Free to use with attribution: https://www.luxalgo.com/library/license/
