Responsive Linear Regression Channels

This is a linear trend indicator that can:
- automagically adjust to different chart resolutions
- snap to day/session boundaries on intraday
- totally not do the above and use ye olde good fixed lookback window
- show the regression trend and its RMSE channels
- disregard the trend and just show the period average and standard deviation lines (often acting as support and resistance )

The main idea was to allow you to quickly view linear trends for different time periods without having to calculate the required amount of bars.
By default, you will be able to quickly switch between 1-3 months, 6 months, 1 year, 2 years and 5 years of data, as well as various daily lookback periods.
Please adjust resolution settings to your liking.

- More data means more noise and slower calculations.
- HLC3 source is recommended, especially at resolutions above hourly.
- Trend will be slightly different if you use extended hours.
- If you use extended hours and don't have a data subscription, trend will be SUBSTANTIALLY different, especially at smaller resolutions like 1m.
- You might want to use 3.5 days per week for crypto (it's 7 days by default).

Known problems:
- If you can't see the trendlines , scroll to the left or zoom out - the origin could be outside of your viewport.
- Futures' sessions start on the previous day. We currently snap only to day boundaries, not session breaks.
- UVXY and the like that have extremely high price datapoints. The calculations will be wrong on some resolutions.
- Replay can freeze circa bar_index 244 — disable smart lookback and keep your window under 240 bars if you encounter this.

Many thanks to alexgrover for his extremely efficient functions (used with permission)
Script open-source

Dans le plus pur esprit de TradingView, l'auteur de ce texte l'a publié en open-source, afin que les traders puissent le comprendre et le vérifier. Bravo à l'auteur ! Vous pouvez l'utiliser gratuitement, mais la réutilisation de ce code dans une publication est régie par les règles internes. Vous pouvez le mettre en favori pour l'utiliser sur un graphique.

Vous voulez utiliser ce script sur un graphique ?


500 coins
+7 Répondre
Great job
100 coins
This publication is now featured in our Editors' Picks. In the name of all TradingView traders, thank you for your valuable contribution to the TradingView community, and congrats!
+7 Répondre
corgalicious PineCoders
@PineCoders, wow thanks! It's an honor!
+6 Répondre
Does this work on all time frames?
+6 Répondre
@JS009, yes, it's literally what this indicator is for
thabeger corgalicious
@corgalicious, I cannot get this to work on 5 min. crypto's..........
@thabeger, try zooming the chart out a bit
thabeger corgalicious
@corgalicious, Got it! How can I make this on a 5 day period? I tried using the settings but it does not appear to change the length? I really appreciate this indicator, it is similar to the standard deviation channel on TOS.
@thabeger, thanks! Have you tried adjusting period settings at the bottom of the settings pane? You might need to scroll down, depending on your display height.

There's a section called SMART PERIOD FINE-TUNING that could help with this. You can assign custom day ranges for 1m, 3m/5m and 10m intervals; everything else is either weeks or bars.

So if you wanted to see 5 days, you could map the 3/5m to 5 days. Just play around with the settings, see what makes most sense to you. :)

(re: TOS — they are similar indeed, but this is actually the StdErr one. StDev on TOS is not giving you the correct visualization for the method it uses)