Anchored Log-Linear Regression Channels

This indicator fits an exponential (log-linear) regression line to a range you select directly on the chart and projects it forward with up to four standard-deviation bands.
Because the fit runs on the natural logarithm of the source, the channel describes a constant percentage growth rate instead of a constant price slope. The bands are offset by a fixed distance in log space and converted back with exp, so their absolute width grows as the channel rises.
How to use
1. Add the indicator. TradingView requests two anchor points — click the start bar and the end bar on the chart.
2. Drag either vertical anchor line afterwards to re-fit the channel.
3. Untick "Use End Anchor" to keep the regression running up to the latest bar instead of stopping at the second anchor.
The two anchors are sorted automatically, so the order of the clicks does not matter.
Settings
- Source — the series to regress. It must stay strictly positive, because the logarithm is taken.
- Extend Right (Bars) — projection length past the end anchor. The maximum is 500 bars, which is the furthest distance TradingView draws into the future.
- Max Bars for Drawing — clamps only the drawn left end of the lines. The regression itself always uses the full anchored range, so accuracy is preserved on very long ranges while the historical buffer limit is respected.
- Bands — four independent bands, each with a sigma multiplier, color, width and line style.
Calculation
Slope, intercept and residual deviation come from an ordinary least-squares fit in log space. The residual deviation is unbiased, with n − 2 degrees of freedom.
The required sums are carried by three cumulative prefix sums, so every bar costs the same amount of work regardless of how long the anchored range is. The script contains no per-bar loop and no historic lookback.
Notes
- The channel is drawn on the last bar only, as a visual overlay. Its values are not exposed to the data window or to other indicators.
- If the source reaches zero or a negative value inside the anchor range, the logarithm is undefined and the regression is invalid. Keep the source strictly positive.
Because the fit runs on the natural logarithm of the source, the channel describes a constant percentage growth rate instead of a constant price slope. The bands are offset by a fixed distance in log space and converted back with exp, so their absolute width grows as the channel rises.
How to use
1. Add the indicator. TradingView requests two anchor points — click the start bar and the end bar on the chart.
2. Drag either vertical anchor line afterwards to re-fit the channel.
3. Untick "Use End Anchor" to keep the regression running up to the latest bar instead of stopping at the second anchor.
The two anchors are sorted automatically, so the order of the clicks does not matter.
Settings
- Source — the series to regress. It must stay strictly positive, because the logarithm is taken.
- Extend Right (Bars) — projection length past the end anchor. The maximum is 500 bars, which is the furthest distance TradingView draws into the future.
- Max Bars for Drawing — clamps only the drawn left end of the lines. The regression itself always uses the full anchored range, so accuracy is preserved on very long ranges while the historical buffer limit is respected.
- Bands — four independent bands, each with a sigma multiplier, color, width and line style.
Calculation
Slope, intercept and residual deviation come from an ordinary least-squares fit in log space. The residual deviation is unbiased, with n − 2 degrees of freedom.
The required sums are carried by three cumulative prefix sums, so every bar costs the same amount of work regardless of how long the anchored range is. The script contains no per-bar loop and no historic lookback.
Notes
- The channel is drawn on the last bar only, as a visual overlay. Its values are not exposed to the data window or to other indicators.
- If the source reaches zero or a negative value inside the anchor range, the logarithm is undefined and the regression is invalid. Keep the source strictly positive.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.