# Periodic Linear Regressions

Fits a linear regression to each anchor period and resets when the next begins: VWAP-style anchoring applied to best-fit lines, drawn as a static line or a rolling series, with RMSE-scaled extremities framing support and resistance. Bicolor and gradient modes flag slope direction instantly. For traders who want trend and channel structure that resets on schedule.

- Indicator in the LuxAlgo Library, by LuxAlgo, published Sep 25, 2024.
- 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=cmpwn4i88006avhsg34gdnp8v
- Page: https://www.luxalgo.com/library/indicator/periodic-linear-regressions/

**Periodic Linear Regressions** fits a [linear regression](https://www.luxalgo.com/library/concept/linear-regression/) to price over each anchor period and resets when a new period begins: anchored calculation in the spirit of periodic VWAPs, applied to best-fit lines. Optional extremities scaled by the root mean squared error between price and the fit surround it with a [linear regression channel](https://www.luxalgo.com/library/concept/linear-regression-channel/), turning a slope estimate into usable support and resistance.

## How to Trade the Periodic Linear Regressions?

- **Slope color**: with Bicolor enabled, green marks an upward fit and red a downward one, an immediate per-period regime read.
- **Price at an extremity**: the RMSE bands mark the channel's edges, most useful inside ranges and channels.
- **Static line's angle**: the straight fit shows how linear the period's trend has been and hints at its continuation.
- **Anchor marks**: flag where each new calculation period begins.

Two mechanical notes: a regression needs at least two points, so the static line cannot exist on a period's first bar and the rolling line starts plotting on the third; and the static line re-fits (and may repaint) until its period ends, while the rolling line extends from previously calculated points.

## Periodic Linear Regressions Settings

- **Method**: "Static" draws the period's straight best-fit line; "Rolling" plots the evolving endpoint of successive fits.
- **Anchor Type**: "Periodic" resets each Anchor Period; "First Bar" runs one calculation from the start and works exclusively with Rolling.
- **Anchor Period**: the reset interval for periodic anchoring.
- **Source**: the input series being fitted.
- **Multiple**: scales the distance of the RMSE extremities.
- **Show Extremities**: toggles the upper and lower bands.
- Color, gradient (Rolling only), and dashboard location/size options handle presentation.

## Frequently Asked Questions

### Should I use the Rolling or Static method?
Static gives the cleanest picture of a period's trend linearity but readjusts as new bars arrive until the period ends. Rolling builds its line from each successive fit's latest point, suiting traders who want the plot to advance rather than redraw.

### How does the anchoring compare with VWAP?
The reset logic is the same idea that gives the [VWAP](https://www.luxalgo.com/library/indicator/vwap/) its session-by-session identity: each anchor period gets its own calculation. Choose First Bar (with Rolling) and the fit instead runs continuously, useful for locating longer-term potential highs and lows.

### How do I access Periodic Linear Regressions?
The indicator is free on the LuxAlgo Library and can be opened in Quant, our coding agent, directly from this page. No purchase is needed to experiment with anchors and methods. You can also copy the source code from this page and run it anywhere Pine Script® runs.

## Related indicators

- [Linear Regression Histogram](https://www.luxalgo.com/library/indicator/linear-regression-histogram/) (Linear Regression): markdown at https://www.luxalgo.com/library/indicator/linear-regression-histogram.md
- [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
- [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/periodic-linear-regressions/ (LuxAlgo Library). Free to use with attribution: https://www.luxalgo.com/library/license/
