# Linear Regression Histogram

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

The Linear Regression Histogram counts how often price lands in each bin of a linear regression channel, turning trend data into a frequency map. Each bin's hit count is drawn as a histogram bar beside the latest bar, so the bins price keeps revisiting stand out as zones of interest, giving trend traders statistically grounded support and resistance that travels with the slope instead of sitting flat.

- Indicator in the LuxAlgo Library, by LuxAlgo, published Oct 25, 2021.
- Access: free.
- Concepts: [Linear Regression](https://www.luxalgo.com/library/concept/linear-regression/) (primary), [Linear-regression Channel](https://www.luxalgo.com/library/concept/linear-regression-channel/)
- Open on Vela: https://vela.luxalgo.com/chart?pineScriptCodeId=cmpwn2vd9003zvhsg8sbo2fzx
- Page: https://www.luxalgo.com/library/indicator/linear-regression-histogram/

**Linear Regression Histogram** treats a trend the way a statistician treats a dataset. It fits a [least-squares regression](https://www.luxalgo.com/library/concept/linear-regression/) through recent closes, wraps the fit in a [regression channel](https://www.luxalgo.com/library/concept/linear-regression-channel/) sized by a multiple of the RMSE, slices that channel into equal-width bins, and counts how many price values land in each one. Each bin's count is drawn as a histogram bar to the right of the latest bar, so the bins collecting the most hits show the longest bars: the zones this trend keeps coming back to.

## How to Trade the Linear Regression Histogram?

- **Longest histogram bars**: prices cluster there more than anywhere else in the channel, marking zones of interest inside the prevailing trend.
- **Revisit behavior**: because these intervals have absorbed price repeatedly, they can act like support or resistance that follows the trend rather than sitting at a fixed level.
- **Granularity control**: more bins carve the channel into finer zones, fewer bins merge activity into broader areas. Match the resolution to how precise your entries need to be.

As the regression rolls forward, the channel and its bins update with it, so the highlighted zones always describe the current fit rather than stale structure.

## Linear Regression Histogram Settings

- **Length**: how many past closing prices feed the regression. Longer settings describe the broader trend, shorter ones hug recent action.
- **Bins Number**: the number of channel lines drawn; the channel is divided into one fewer interval than this (9 at the default of 10), controlling how granular the frequency map is.
- **Mult**: multiplies the RMSE to set channel width. Raise it to capture more of the price action, lower it to focus on the trend's core.
- **Src**: the price source used for the analysis.

## Frequently Asked Questions

### What do the longest histogram bars represent?

They are the channel intervals where price has appeared most often over the analysis window. That clustering points to areas of market interest within the trend: prices where activity concentrated before and may concentrate again, sometimes behaving as support or resistance.

### What does it add over a plain regression channel?

A standard channel shows the fit and its outer bands; this build adds a frequency count inside the channel, revealing where along the slope price actually spent its time. If you would rather have fresh fits drawn period by period, [Periodic Linear Regressions](https://www.luxalgo.com/library/indicator/periodic-linear-regressions/) covers that angle.

### Is the Linear Regression Histogram free to use?

Yes. It is available free through the LuxAlgo Library. You can also run and backtest it in Quant, our coding agent, straight from this page. You can also copy the source code from this page and run it anywhere Pine Script® runs.

## Related indicators

- [Linear Regression Fan](https://www.luxalgo.com/library/indicator/linear-regression-fan/) (Linear Regression): markdown at https://www.luxalgo.com/library/indicator/linear-regression-fan.md
- [Periodic Linear Regressions](https://www.luxalgo.com/library/indicator/periodic-linear-regressions/) (Linear Regression): markdown at https://www.luxalgo.com/library/indicator/periodic-linear-regressions.md
- [Rolling Segment](https://www.luxalgo.com/library/indicator/rolling-segment/) (Linear Regression): markdown at https://www.luxalgo.com/library/indicator/rolling-segment.md
- [Rolling Trendline](https://www.luxalgo.com/library/indicator/rolling-trendline/) (Linear Regression): markdown at https://www.luxalgo.com/library/indicator/rolling-trendline.md
- [Extrapolated Previous Trend](https://www.luxalgo.com/library/indicator/extrapolated-previous-trend/) (Linear Regression): markdown at https://www.luxalgo.com/library/indicator/extrapolated-previous-trend.md
- [Bitcoin Power Law](https://www.luxalgo.com/library/indicator/bitcoin-power-law/) (Linear Regression): markdown at https://www.luxalgo.com/library/indicator/bitcoin-power-law.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

---

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