OPEN-SOURCE SCRIPT

Dynamic Linear Regression Oscillator | Adulari

Description:
This dynamic linear regression oscillator visualizes the general price trend of specific ranges in the chart based on the linear regression calculation, it automatically determines these ranges with pivot detection. The central line of the indicator is the baseline of the linear regression itself. This is a good tool to use to determine when a price is unusually far away from its baseline. The lines above or below it are overbought and oversold zones. These zones are based on the high or low of the range, in combination with the set multipliers.

The overbought and oversold lines indicate support and resistance; when the prices stay outside these levels for a significant period of time, a reversal can be expected soon. When the oscillator's value crosses above the signal or smoothed line the trend may become bullish. When it crosses below, the trend may become bearish.
https://www.tradingview.com/x/viqwYcpQ/
This indicator is quite special, as it first determines price ranges using pivot detection. It then uses the middle of the range to determine how far the current price is from the baseline. This value is then rescaled compared to a set amount of bars back, putting it into relevant proportions with the current price action.

How do I use it?
  • Never use this indicator as standalone trading signal, it should be used as confluence.
  • When the value crosses above the signal this indicates the current bearish trend is getting weak and may reverse upwards.
  • When the value crosses below the signal this indicates the current bullish trend is getting weak and may reverse downwards.
  • When the value is above the middle line this shows the bullish trend is strong.
  • When the value is below the middle line this shows the bearish trend is strong.
  • When the value crosses above the upper line this indicates the trend may reverse downwards.
  • When the value crosses below the lower line this indicates the trend may reverse upwards.


Features:
  • Oscillator value indicating how far the price has currently deviated from the middle of the range. Proportioned to data from a set amount of bars ago.
  • Signal value to indicate whether or not the price is abnormally far from the middle of the range.
  • Horizontal lines such as oversold, overbought and middle lines, indicating possible reversal zones.
  • Automatic range detection using pivots.
  • Built-in rescaling functionality to ensure values are proportionate with the latest data.


How does it work? (simplified)
1 — Calculate the middle of the range.
2 — Define whether the current price is above the middle of the range or below.
3 — If above the middle of the range, calculate the difference of the current high and the middle line. If below, calculate the difference of the current low and the middle line.
4 — Smooth the value using a set moving average type.
5 — Rescale the value to proportionate it with the latest data.
adulariATSlinear-regressionLinear RegressionOscillatorsSupport and Resistancesupportandresitance

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?


Adulari - Software Company
Site: adulari.dev
Discord: discord.gg/adulari
Also on:

Disclaimer