OPEN-SOURCE SCRIPT
Std Dev Channel [fmb]

What it is
A professional regression channel that combines standard deviation divisions, an extreme price envelope, and a trend quality gauge. It is designed for fast read-and-act decisions on any timeframe, with sensible presets and log-space math for instruments that trend exponentially.
Why it’s different
Most channels draw fixed ±1σ and ±2σ around a regression line. This tool adds:
- Fibonacci-spaced σ divisions for precise scaling
- An objective MaxEnvelope of actual extremes with optional 1.272 and 1.618 extensions
- Pearson’s R labelling that classifies the trend as Strong Up, Moderate, Weak, or Strong Down
- A log-space option so channels behave correctly on long trends and high beta charts
How it works
Base line
- Linear regression of the last Length bars, drawn as a ray.
- Optional colour change by regime using Pearson’s R.
Divisions (StdDev or MaxEnvelope)
- StdDev basis: σ of residuals around the regression line.
- MaxEnvelope basis: distances from the base line to the farthest highs and lows in the lookback.
- Divisions can be Fibonacci multiples (0.382, 0.618, 1.000, 1.272 by default) or uniform steps.
Outer rails
- ENV 1.0 touches the farthest highs and lows within the window.
- Optional extensions at 1.272 and 1.618 highlight stretch and breakout zones.
Trend quality (Pearson’s R)
- R is computed on the same series and window.
- Default thresholds: Strong when |R| ≥ 0.70, Weak when |R| < 0.40.
- The label reads: R 0.XXX • Class, plotted near the most recent base value.
Log-space math
- When enabled, the model runs on ln(price) and converts the outputs back to price.
- Safer on multi-year charts and large percentage trends.
Presets
- Swing: Length 125, StdDev basis, Fib divisions, ENV 1.0 and 1.272 on
- Intraday: Length 240, StdDev basis, simple ±1 and ±2 style divisions, ENV off by default
- Position: Length 200, StdDev basis, compact Fib set for higher timeframes
You can turn preset overrides off to make every input respond instantly.
Inputs you will actually use
- Length, Source, Log-space ON or OFF
- Basis: StdDev or MaxEnvelope
- Divisions: Fib list or Step and Max multiple
- Outer rails: show ENV 1.0, show 1.272, show 1.618
- Labels and sizes, extend left or right
- Hide divisions or outer rails automatically when the regime is Weak
Alerts included
- Close crosses above or below ENV 1.0
- Close crosses above or below ENV 1.272 and 1.618 (if enabled)
Practical playbook
Trend following
- In Strong Uptrend: buy pullbacks near 0.382 to 0.618 above the base with stops just beyond the next lower division.
- In Strong Downtrend: sell bounces into 0.382 to 0.618 below the base with stops just beyond the next upper division.
Mean reversion
- When R is Moderate or Weak, fade moves that tag ENV 1.0 back toward the base.
- If price closes through an ENV extension, treat it as potential regime change and stand down on fades.
Breakouts
- A close through ENV 1.0 with R rising toward Strong often precedes trend acceleration.
- Use the next division or the 1.272 rail as the first target and trail on the base.
Tips
- Keep Length stable across symbols you compare. Consistency beats curve fitting.
- Use log-space on multi-year equities and crypto. Use linear for short intraday work.
- If you want a classic look, disable Fib and rails, set Step 1.0 and Max 2.0.
Notes
- The tool draws more lines when Fib divisions are active. If it feels busy, show divisions only and hide labels, or keep ENV 1.0 plus one extension.
- Pearson’s R is descriptive, not predictive. Combine with price structure and volume for entries.
A professional regression channel that combines standard deviation divisions, an extreme price envelope, and a trend quality gauge. It is designed for fast read-and-act decisions on any timeframe, with sensible presets and log-space math for instruments that trend exponentially.
Why it’s different
Most channels draw fixed ±1σ and ±2σ around a regression line. This tool adds:
- Fibonacci-spaced σ divisions for precise scaling
- An objective MaxEnvelope of actual extremes with optional 1.272 and 1.618 extensions
- Pearson’s R labelling that classifies the trend as Strong Up, Moderate, Weak, or Strong Down
- A log-space option so channels behave correctly on long trends and high beta charts
How it works
Base line
- Linear regression of the last Length bars, drawn as a ray.
- Optional colour change by regime using Pearson’s R.
Divisions (StdDev or MaxEnvelope)
- StdDev basis: σ of residuals around the regression line.
- MaxEnvelope basis: distances from the base line to the farthest highs and lows in the lookback.
- Divisions can be Fibonacci multiples (0.382, 0.618, 1.000, 1.272 by default) or uniform steps.
Outer rails
- ENV 1.0 touches the farthest highs and lows within the window.
- Optional extensions at 1.272 and 1.618 highlight stretch and breakout zones.
Trend quality (Pearson’s R)
- R is computed on the same series and window.
- Default thresholds: Strong when |R| ≥ 0.70, Weak when |R| < 0.40.
- The label reads: R 0.XXX • Class, plotted near the most recent base value.
Log-space math
- When enabled, the model runs on ln(price) and converts the outputs back to price.
- Safer on multi-year charts and large percentage trends.
Presets
- Swing: Length 125, StdDev basis, Fib divisions, ENV 1.0 and 1.272 on
- Intraday: Length 240, StdDev basis, simple ±1 and ±2 style divisions, ENV off by default
- Position: Length 200, StdDev basis, compact Fib set for higher timeframes
You can turn preset overrides off to make every input respond instantly.
Inputs you will actually use
- Length, Source, Log-space ON or OFF
- Basis: StdDev or MaxEnvelope
- Divisions: Fib list or Step and Max multiple
- Outer rails: show ENV 1.0, show 1.272, show 1.618
- Labels and sizes, extend left or right
- Hide divisions or outer rails automatically when the regime is Weak
Alerts included
- Close crosses above or below ENV 1.0
- Close crosses above or below ENV 1.272 and 1.618 (if enabled)
Practical playbook
Trend following
- In Strong Uptrend: buy pullbacks near 0.382 to 0.618 above the base with stops just beyond the next lower division.
- In Strong Downtrend: sell bounces into 0.382 to 0.618 below the base with stops just beyond the next upper division.
Mean reversion
- When R is Moderate or Weak, fade moves that tag ENV 1.0 back toward the base.
- If price closes through an ENV extension, treat it as potential regime change and stand down on fades.
Breakouts
- A close through ENV 1.0 with R rising toward Strong often precedes trend acceleration.
- Use the next division or the 1.272 rail as the first target and trail on the base.
Tips
- Keep Length stable across symbols you compare. Consistency beats curve fitting.
- Use log-space on multi-year equities and crypto. Use linear for short intraday work.
- If you want a classic look, disable Fib and rails, set Step 1.0 and Max 2.0.
Notes
- The tool draws more lines when Fib divisions are active. If it feels busy, show divisions only and hide labels, or keep ENV 1.0 plus one extension.
- Pearson’s R is descriptive, not predictive. Combine with price structure and volume for entries.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.