Indicator · Pine Script v6 · On the chart

Linear Regression Volume

by vedkanani123· code credited to Lyro RS

An overlay indicator that computes a volume-weighted price average using SMA, RMA, HMA or ALMA, fits a linear regression to it as a fair value baseline, and draws bands at one, two and three standard deviations of price around it.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code70
Settings3inputs
LicenceNone statedfile: MPL-2.0
Last update2 months ago23 Aug 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

70 lines of Pine Script v6 from indicator/olg_7_6_26/LyroRS/17.txt, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

17.txt
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Lyro RS

//@version=6
indicator("Linear Regression Volume | Lyro RS", "LR Volume | 𝓛𝔂𝓻𝓸 𝓡𝓢", overlay=true)

// Inputs
len = input.int(35, title="Regression Length")
mult = input.float(1.0, title="Deviation Multiplier")
typeMA = input.string("SMA", "Type", ["SMA", "RMA", "HMA", "ALMA"], tooltip = "Change to what suits your style")
upperBandCOL = #ff026f
lowerBandCOL = #40ed49


// Volume Weighted Linear Regression Input // 
vw_linregSM(src, len) =>
    ta.sma(src * volume, len) / ta.sma(volume, len)
vw_linregRM(src, len) =>
    ta.rma(src * volume, len) / ta.rma(volume, len)
vw_linregHM(src, len) =>
    ta.hma(src * volume, len) / ta.hma(volume, len)
vw_linregAL(src, len) =>
    ta.alma(src * volume, len, 0, 0) / ta.alma(volume, len, 0, 0)

vw_linregCho(src, len, typeMA) =>
    switch typeMA
        "SMA" =>  ta.sma(src * volume, len) / ta.sma(volume, len)
        "RMA" =>  ta.rma(src * volume, len) / ta.rma(volume, len)
        "HMA" =>  ta.hma(src * volume, len) / ta.hma(volume, len)
        "ALMA" => ta.alma(src * volume, len, 0, 0) / ta.alma(volume, len, 0, 0)


// Fair value baseline
vw_price = vw_linregCho(close, len, typeMA)
baseline = ta.linreg(vw_price, len, 0)
slope = baseline - baseline[1]

// Deviation (volatility)
dev = mult * ta.stdev(close, len)

// Trend color based on slope
bandColor = slope > 0 ? #40ed49 : slope < 0 ? #ff026f : color.gray

// Bands
upper1 = baseline + dev
lower1 = baseline - dev
upper2 = baseline + dev * 2
lower2 = baseline - dev * 2
upper3 = baseline + dev * 3
lower3 = baseline - dev * 3


// Plot baseline and bands
plot(baseline, title="Fair Value", color=bandColor, linewidth=2)
upper1Plot = plot(upper1, color=color.new(upperBandCOL, 100))
lower1Plot = plot(lower1, color=color.new(upperBandCOL, 100))
upper2Plot = plot(upper2, color=color.new(upperBandCOL, 100))
lower2Plot = plot(lower2, color=color.new(lowerBandCOL, 100))
upper3Plot = plot(upper3, color=color.new(upperBandCOL, 100))
lower3Plot = plot(lower3, color=color.new(lowerBandCOL, 100))


// Fills
fill(upper1Plot, lower1Plot, color=color.new(bandColor, 85))
fill(upper2Plot, lower2Plot, color=color.new(bandColor, 92))
fill(upper3Plot, lower3Plot, color=color.new(bandColor, 96))

// Alerts
alertcondition(slope > 0, "Linear Regression Volume - Long", "Linear Regression Volume is Long {{exchange}}:{{ticker}}")
alertcondition(slope < 0, "Linear Regression Volume - Short", "Linear Regression Volume is Short {{exchange}}:{{ticker}}")

Overview

The baseline and band fills turn green when its slope rises and red when it falls. Settings are regression length, deviation multiplier and the average type. Alerts fire on rising and falling slope.

Details

Published by

vedkanani123 on GitHub

Code credit

Lyro RS, as written in the script's header

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Trend, Volume, Mean reversion

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Regression Lengthint35len
Deviation Multiplierfloat1.0mult
TypestringSMAtypeMA
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

The Momentum Setup is a multi-indicator visual tool designed for trend and momentum analysis directly on the price chart. It combines Relative Strength Index (RSI), Money Flow Index (MFI), Commodity Channel Index (CCI), Supertrend, and a 250-bar percentage cha

Indicator v5 Oscillators & momentumTrend
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - Ankush Bajaj Momentum Investing Setup
257 stars

This indicator plots auto trade signals for E-mini S&P 500 futures on the price chart. It computes an EMA200 filter along with day ETH RTH session levels and percentage-based entry zones. Signals trigger CALL or PUT cases when price crosses defined thresholds

Indicator v6 TrendSupport & resistance
Updated 6 weeks ago · None stated GitHub repository of Auto Trade Futures ES

Adaptive MA Slope

by capissimo
114 stars

This indicator calculates Kaufman's Adaptive Moving Average (KAMA) on a chosen price source and determines trend direction based on the slope across a configurable lookback window. Signals can be filtered by short-term volatility expansion using ATR comparison

Indicator v4 Moving averagesTrend
Updated 1 year ago · None stated GitHub repository of Adaptive MA Slope
92 stars

This indicator plots a volume-weighted average price of the typical price on the chart and colors that line by ADX strength. It draws a standard-deviation envelope around VWAP and tints the fill green when plus DI leads and red when minus DI leads. Triangle ma

Indicator v5 TrendOscillators & momentum
Updated 2 months ago · Custom licence GitHub repository of Moon Dev VWAP x ADX Explosion

Signal Strategy 15m

by tripolskypetr
72 stars

This indicator generates trend-following trade signals on the price chart by combining moving average crossovers with multi-factor filters. It triggers entry alerts when fast and slow EMAs cross in the direction of a baseline trend EMA, confirmed by non-extrem

Indicator v5 TrendMoving averages
Updated 4 days ago · MIT GitHub repository of Signal Strategy 15m

Copilot

by milocaetano
48 stars

Copilot is an order flow range-reversal indicator designed to overlay trading setups directly on the price chart. It evaluates four criteria: market context (sideways vs trending regime based on ATR height), structure (double top or double bottom retests), abs

Indicator v5 SMC / ICT / price actionSupport & resistance
Updated 2 days ago · MIT GitHub repository of Copilot

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers