New AI Backtesting Assistant Launch!

Periodic Linear Regressions

Sep 25, 2024
Static chart image
Dynamic Overlays
Support and Resistance
Channels

Works on the Following Platforms

tradingviewSymbolTradingView
For free use on the TradingView platform
ninjatraderNinjaTrader
For free use on the NinjaTrader platform
metatrader4MetaTrader 4
For free use on the MetaTrader 4 platform
metatrader5MetaTrader 5
For free use on the MetaTrader 5 platform
thinkorswimThinkorswim
For free use on the Thinkorswim platform

The Periodic Linear Regressions (PLR) indicator calculates linear regressions periodically (similar to the VWAP indicator) based on a user-set period (anchor).

This allows for estimating underlying trends in the price, as well as providing potential supports/resistances.

USAGE

indicator image

The Periodic Linear Regressions indicator calculates a linear regression over a user-selected interval determined from the selected "Anchor Period".

The PLR can be visualized as a regular linear regression (Static), with a fit readjusting for new data points until the end of the selected period, or as a moving average (Rolling), with new values obtained from the last point of a linear regression fitted over the calculation interval. While the static method line is prone to repainting, it has value since it can further emphasize the linearity of an underlying trend, as well as suggest future trend directions by extrapolating the fit.

indicator image

Extremities are included in the indicator, these are obtained from the root mean squared error (RMSE) between the price and calculated linear regression. The Multiple setting allows the users to control how far each extremity is from the other.

Periodic Linear Regressions can be helpful in finding support/resistance areas or even opportunities when ranging in a channel.

indicator image

indicator image

The anchor - where a new period starts - can be shown (in this case in the top right corner).

indicator image

The shown bands can be visualized by enabling Show Extremities in settings (Rolling or Static method).

indicator image

The script includes a background gradient color option for the bands, which only applies when using the Rolling method.

The indicator colors can be suggestive of the detected trend and are determined as follows:

  • Method Rolling: a gradient color between red and green indicates the trend; more green if the output is rising, suggesting an uptrend, and more red if it is decreasing, suggesting a downtrend.
  • Method Static: green if the slope of the line is positive, suggesting an uptrend, red if negative, suggesting a downtrend.

DETAILS

Anchor Type

When the Anchor Type is set to Periodic, the indicator will be reset when the "Anchor Period" changes, after which calculations will start again.

An anchored rolling line set at First Bar won't reset at a new session; it will continue calculating the linear regression from the first bar to the last; in other words, every bar is included in the calculation. This can be useful to detect potential long-term tops/bottoms.

indicator image

Note that a linear regression needs at least two values for its calculation, which explains why you won't see a static line at the first bar of the session. The rolling linear regression will only show from the 3rd bar of the session since it also needs a previous value.

Rolling/Static

When Anchor Type is set at Periodic, a linear regression is calculated between the first bar of the chosen session and the current bar, aiming to find the line that best fits the dataset.

indicator image

The example above shows the lines drawn during the session. The offered script, though, shows the last calculated point connected to the previous point when the Rolling method is chosen, while the Static method shows the latest line.

indicator image

Note that linear regression needs at least two values, which explains why you won't see a static line at the first bar of the session. The rolling line will only show from the 3rd bar of the session since it also needs a previous value.

SETTINGS

  • Method: Indicator method used, with options: "Static" (straight line) / "Rolling" (rolling linear regression).
  • Anchor Type: "Periodic / First Bar" (the latter works only when "Method" is set to "Rolling").
  • Anchor Period: Only applicable when "Anchor Type" is set at "Periodic".
  • Source: open, high, low, close, ...
  • Multiple: Alters the width of the bands when "Show Extremities" is enabled.
  • Show Extremities: Display one upper and one lower extremity.

Color Settings

  • Mono Color: color when "Bicolor" is disabled
  • Bicolor: Toggle on/off + Colors
  • Gradient: Background color when "Show extremities" is enabled + level of gradient

Dashboard

  • Show Dashboard
  • Location of dashboard
  • Text size

Trading is risky and many will lose money in connection with trading activities. All content on this site is not intended to, and should not be, construed as financial advice. Decisions to buy, sell, hold or trade in securities, commodities and other markets involve risk and are best made based on the advice of qualified financial professionals. Past performance does not guarantee future results.

Hypothetical or Simulated performance results have certain limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, including, but not limited to, lack of liquidity. Simulated trading programs in general are designed with the benefit of hindsight, and are based on historical information. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.

Testimonials appearing on this website may not be representative of other clients or customers and is not a guarantee of future performance or success.

As a provider of technical analysis tools for charting platforms, we do not have access to the personal trading accounts or brokerage statements of our customers. As a result, we have no reason to believe our customers perform better or worse than traders as a whole based on any content or tool we provide.

Charts used on this site are by TradingView in which the majority of our tools are built on. TradingView® is a registered trademark of TradingView, Inc. www.TradingView.com. TradingView® has no affiliation with the owner, developer, or provider of the Services described herein.

This does not represent our full Disclaimer. Please read our full disclaimer.

© 2025 LuxAlgo Global, LLC.