# Machine Learning Regression Trend

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

Fits a linear regression channel using RANSAC, a machine-learning routine that repeatedly re-fits on random samples and keeps the model that best ignores outliers. The result is a trend channel anchored to genuine structure rather than volatile spikes, with flagged outliers doubling as a noise gauge and the fit projecting forward as a forecast.

- Indicator in the LuxAlgo Library, by LuxAlgo, published Aug 23, 2023.
- Access: free.
- Concepts: [Linear-regression Channel](https://www.luxalgo.com/library/concept/linear-regression-channel/) (primary)
- Open on Vela: https://vela.luxalgo.com/chart?pineScriptCodeId=cmpwn3cum004nvhsgwbwvu18d
- Page: https://www.luxalgo.com/library/indicator/machine-learning-regression-trend/

**Machine Learning Regression Trend** fits a [linear regression channel](https://www.luxalgo.com/library/concept/linear-regression-channel/) the robust way: a RANSAC routine repeatedly samples the data, fits candidate lines, and keeps the model with the most inliers, so volatile spikes cannot drag the trend around. You get the familiar channel (support and resistance plus a forward projection) centered on a line fitted only to the observations that genuinely agree on a trend.

RANSAC works iteratively: select two random samples, fit a line, count how many points fall within the allowed error, save the model if inliers beat the threshold, and repeat until the iteration budget is spent. That inlier-first logic makes it deliberately conservative next to a plain least-squares fit that weighs every bar equally.

## How to Trade the Machine Learning Regression Trend?

- **Channel rails**: use the fitted channel as support and resistance, exactly as with a conventional regression channel, but with outliers excluded from the fit.
- **Red dots**: detected outliers; the more that appear, the noisier the tracked trend, so treat channel touches with extra caution.
- **Blue margin**: visualizes the allowed error band used to separate inliers from outliers.
- **Projection**: the extended fit sketches where the robust trend points next.

## Machine Learning Regression Trend Settings

- **Length**: the linear regression's calculation window.
- **Channel Width**: a multiplier on the fit's error (RMSE) that sets how wide the channel is drawn.
- **Source**: the input series used for the fit.
- **Minimum Inliers**: how many inliers a candidate model needs to be considered valid.
- **Allowed Error**: the tolerance for classifying inliers. "Auto" multiplies the average candle body size by your value, "Fixed" uses your value directly as the price tolerance.
- **Maximum Iterations Steps**: caps the RANSAC iteration count.

## Frequently Asked Questions

### What does RANSAC add over ordinary linear regression?

A standard fit, like the library's [Linear Regression tool](https://www.luxalgo.com/library/indicator/linear-regression/), treats every bar in the window identically, so one violent move can tilt the whole channel. RANSAC detects and discards those outliers, which matters most in volatile markets.

### What do the red dots tell me?

Each dot is a bar the model rejected as an outlier. A cluster of them means the trend is being tracked through heavy noise, a useful warning before leaning on the channel's levels.

### How is the Machine Learning Regression Trend accessed?

Free through the LuxAlgo Library: get it on this page. It also runs inside Quant, our coding agent, if you want to push the idea further.

## Related indicators

- [Linear Regression Histogram](https://www.luxalgo.com/library/indicator/linear-regression-histogram/) (Linear-regression Channel): markdown at https://www.luxalgo.com/library/indicator/linear-regression-histogram.md
- [Periodic Linear Regressions](https://www.luxalgo.com/library/indicator/periodic-linear-regressions/) (Linear-regression Channel): markdown at https://www.luxalgo.com/library/indicator/periodic-linear-regressions.md
- [Volume Profile Regression Channel](https://www.luxalgo.com/library/indicator/volume-profile-regression-channel/) (Linear-regression Channel): markdown at https://www.luxalgo.com/library/indicator/volume-profile-regression-channel.md
- [Volumetric Regression Heatmap](https://www.luxalgo.com/library/indicator/volumetric-regression-heatmap/) (Linear-regression Channel): markdown at https://www.luxalgo.com/library/indicator/volumetric-regression-heatmap.md
- [Linear Regression](https://www.luxalgo.com/library/indicator/linear-regression/) (Linear-regression Channel): markdown at https://www.luxalgo.com/library/indicator/linear-regression.md
- [Trendlines with Breaks](https://www.luxalgo.com/library/indicator/trendlines-with-breaks/) (Trendline): markdown at https://www.luxalgo.com/library/indicator/trendlines-with-breaks.md
- [Trendline Breakout Navigator](https://www.luxalgo.com/library/indicator/trendline-breakout-navigator/) (Trendline): markdown at https://www.luxalgo.com/library/indicator/trendline-breakout-navigator.md
- [FVG Channel](https://www.luxalgo.com/library/indicator/fvg-channel/) (Parallel Channel): markdown at https://www.luxalgo.com/library/indicator/fvg-channel.md

---

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