All indicators

Periodic Linear Regressions

By LuxAlgoSep 25, 2024

Periodic Linear Regressions is an indicator on Vela, our next-generation charting platform, written in Pine Script®.

Periodic Linear Regressions fits a 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, 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.
  • Period resets: each new calculation period starts a fresh fit; in Periodic mode a new static line, or a short gap in the rolling line, shows where it 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" is meant to run one calculation from the start and works exclusively with Rolling, but the current build still resets its sample count at each Anchor Period, so its line is not a true continuous regression.
  • 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

Free to use

Run it on Vela. Go further with a paid plan.

  • Up to 500 Custom Alerts, with webhook automation
  • Up to 10× the chart history of Free
  • Orderflow lookback up to full history
  • More Quant usage to customize it, plus extra usage when you need it
  • Futures data alongside crypto, stocks, forex and commodities
See plans

Also works on

TradingView
Original indicatorBuilt in-house by LuxAlgo

Run it on Vela. Make it yours with Quant.

Open this indicator free on Vela, our next-generation charting platform. Then ask Quant, our coding agent built into Vela, to retune it or turn it into a backtested strategy of your own.