PROTECTED SOURCE SCRIPT

Logarithimic Regression Fib Deviation Bands

14
Overview
This indicator builds a logarithmic regression growth curve and wraps it in Fibonacci-scaled deviation bands to create a long-horizon valuation corridor. It is designed for assets where percentage moves matter more than absolute price moves (for example Bitcoin and other crypto assets), and it remains readable thanks to rainbow band colouring and right-offset labels.

What this indicator does

1) Fits a regression midline in log price space
  • []The midline is a best-fit curve for the asset’s long-term trend
    []Because the regression is performed on log(price), the trend behaves in percentage terms rather than linear price terms
  • This makes the curve suitable for multi-cycle and exponential-growth markets


2) Measures deviation around the midline
  • []The indicator calculates the residual distance between price and the regression midline in log space
    []A single expanding deviation measure is derived from these residuals
    []Deviation can be calculated using either:
    • []Expanding standard deviation (smoother, more robust)
    • Expanding maximum deviation (widest possible corridor)


3) Builds Fibonacci-scaled deviation bands
  • []Upper and lower bands are placed at Fibonacci multiples of the deviation
    []Included levels:
    • []0.236, 0.382, 0.500, 0.618, 0.786
      []1.000, 1.272, 1.618, 1.786, 2.000
      []Extended levels above 2.0: 2.272, 2.414, 2.500, 2.618, 2.720, 3.000
    []Bands are calculated in log space and then converted back to price space for plotting


4) Keeps the chart clean and readable
  • []Upper bands have individual visibility toggles
    []Lower bands have:
    • []A master enable / disable switch
      []Individual per-level toggles
    []Sensible defaults are used (only the most commonly relevant lower levels are enabled by default)
    []All labels are offset to the right so they do not overlap current price action


Why this indicator is useful

This tool is designed for context, structure, and regime awareness, not short-term entry signals.

  • []Long-term valuation context
    Helps visualise where price sits relative to a fitted growth curve
    []Cycle extremes
    Upper Fibonacci deviation bands highlight historically stretched conditions and potential blow-off zones
    []Mean-reversion and discount zones
    Lower bands highlight historically depressed conditions and deep drawdown regions
    []Consistency across time
    Because the model operates in log space, all distances are interpreted as percentages, making behaviour comparable across multiple cycles


How it works (plain English)

  • []Price is converted to log(price)[]A regression is fitted to log(price) using an anchored time axis
    []Two time modes are available:
    []Days: log(price) vs linear time (exponential curve in price space)
    []Log(Days): log(price) vs log(time), which often behaves like a power-law corridor over very long histories
    []Residuals (distance from the midline) are measured in log space
    []A deviation width is calculated from those residuals
    []Fibonacci ratios are applied to that deviation to create the band levels
  • Bands are converted back to normal price and plotted


Inputs guide

  • []Model timeframe
    Regression and deviation are calculated on a chosen timeframe (default Daily) and displayed on all chart timeframes
    []Time axis mode
    • []Days = exponential-style trend
      []Log(Days) = power-law-style trend (often better for very long cycles)
    []Deviation model
    • []Expanding StdDev = smoother, more statistically robust corridor
      []Expanding MaxAbs = widest possible corridor
    []Midline shift (%)
    Shifts the entire corridor up or down by a constant percentage (useful for centring the model across different assets)
    []Lower band controls
    Master toggle plus per-level toggles allow you to show only the lower levels that are relevant for the current regime
    []Label offset
    Moves labels into the future by a fixed number of bars so they do not interfere with live price action


Typical usage ideas

  • []Use Log(Days) + Expanding StdDev as a default for multi-cycle assets
    []Treat upper bands as risk or stretch zones, not automatic sell signals
    []Treat lower bands as discount or stress zones, not automatic buy signals
    []Enable deeper lower bands only when price action approaches those regions


Notes and limitations

  • []This indicator is not a prediction tool[]Bands evolve as more historical data becomes available
  • Results may vary depending on the amount and quality of historical data for a given symbol

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.