Indicator · Pine Script v6 · On the chart

Volume MAs Supertrend

by vedkanani123· code credited to LyroRS

An overlay Supertrend that is built on a volume-weighted moving average instead of raw price, with a choice of nine average types and a length.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code144
Settings9inputs
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

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

18.txt
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © LyroRS

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


// Imports
import TradingView/ta/10 as ta



// Groups
st_g = "𝗦𝗨𝗣𝗘𝗥𝗧𝗥𝗘𝗡𝗗"
ma_g = "𝗠𝗢𝗩𝗜𝗡𝗚 𝗔𝗩𝗘𝗥𝗔𝗚𝗘"
colors_g = '𝗖𝗢𝗟𝗢𝗥𝗦'



// Inputs
st_len = input.int(10, "Supertrend Len", group=st_g, tooltip="Sets the ATR period used in Supertrend calculations. A higher value smooths out signals.")
l_mult = input.float(3.6, "Long Multiplier", step=0.01, minval=0.01, group=st_g, tooltip="Multiplier applied to ATR to calculate the upper Supertrend band (used for long entries).")
s_mult = input.float(1.8, "Short Multiplier", step=0.01, minval=0.01, group=st_g, tooltip="Multiplier applied to ATR to calculate the lower Supertrend band (used for short entries).")



// MA Inputs
MA_Type = input.string("EMA", "Select Moving Average", options=["SMA", "EMA", "WMA", "VWMA", "DEMA", "TEMA", "RMA", "HMA", "ALMA"], group=ma_g, tooltip="Choose the type of volume-adjusted moving average to use in trend calculation.")
MA_len = input.int(12, "Moving Average Length", group=ma_g, tooltip="Length of the selected moving average. Determines how many bars are considered in smoothing the trend.")



// Color Inputs
ColMode = input.string("Mystic", "Custom Color Palette", inline="drop", options=["Classic", "Mystic", "Accented", "Royal"], display=display.none, group=colors_g,  tooltip="Choose a predefined color scheme for indicator visualization.")

cpyn = input.bool(false, "Use Custom Palette", tooltip="Enable manual selection of custom colors for trend signals.", group=colors_g, display=display.none)
cp_UpC = input.color(#00ff00, "Custom Up", inline="Custom Palette", tooltip="Set a custom color for bullish signals.", group=colors_g, display=display.none)
cp_DnC = input.color(#ff0000, "Custom Down", inline="Custom Palette", tooltip="Set a custom color for bearish signals.", group=colors_g, display=display.none)



// Colors
color UpC = na
color DnC = na

switch ColMode
    "Classic" =>
        UpC := #00E676
        DnC := #880E4F
    "Mystic" =>
        UpC := #30FDCF
        DnC := #E117B7
    "Accented" =>
        UpC := #9618F7
        DnC := #FF0078
    "Royal" =>
        UpC := #FFC107
        DnC := #673AB7


if cpyn
    UpC := cp_UpC
    DnC := cp_DnC



// Moving Average Switch
f_mas(MA_len_) =>
    source_ = close
    float ma = na
    switch MA_Type
        "SMA" => ma := ta.sma(source_ * volume, MA_len_) / ta.sma(volume, MA_len_)
        "EMA" => ma := ta.ema(source_ * volume, MA_len_) / ta.ema(volume, MA_len_)
        "WMA" => ma := ta.wma(source_ * volume, MA_len_) / ta.wma(volume, MA_len_)
        "VWMA" => ma := ta.vwma(source_ * volume, MA_len_) / ta.vwma(volume, MA_len_)
        "DEMA" => ma := ta.dema(source_ * volume, MA_len_) / ta.dema(volume, MA_len_)
        "TEMA" => ma := ta.tema(source_ * volume, MA_len_) / ta.tema(volume, MA_len_)
        "RMA" => ma := ta.rma(source_ * volume, MA_len_) / ta.rma(volume, MA_len_)
        "HMA" => ma := ta.hma(source_ * volume, MA_len_) / ta.hma(volume, MA_len_)
        "ALMA" => ma := ta.alma(source_ * volume, MA_len_, 0, 20) / ta.alma(volume, MA_len_, 0, 20)


    ma

// Supertrend Function
Supertrend(atrPeriod) =>
    source = close
    src = f_mas(MA_len)
    atr = ta.atr(atrPeriod)
    u = src + l_mult * atr
    l = src - s_mult * atr
    pl = nz(l[1])
    pu = nz(u[1])

    l := l > pl or source[1] < pl ? l : pl
    u := u < pu or source[1] > pu ? u : pu
    int d = na
    float st = na
    pt = st[1]
    if na(atr[1])
        d := 1
    else if pt == pu
        d := source > u ? -1 : 1
    else
        d := source < l ? 1 : -1
    st := d == -1 ? l : u
    [st, d]


[x, d] = Supertrend(st_len)

st_l = ta.crossunder(d, 0)
st_s = ta.crossover(d, 0)

// Conditions
Long = st_l
Short = st_s


// IF Statement
var color pc = na
if Long and not Short
    pc := UpC


if Short
    pc := DnC



p1 = plot(x, color=pc, title= "Volume MAs Supertrend")
p2 = plot(hl2, display = display.none, editable = false)


fill(p1, p2, hl2, x, na, pc)


barcolor(pc, title= "Coloring Bars")
plotcandle(open, high, low, close, color= pc, wickcolor=pc, bordercolor = pc, force_overlay = true, title= "Plotting Candles", display=display.pane)


// Alerts
alertcondition(Long, "Volume MAs Supertrend - Long", "Volume MAs Supertrend  is Long {{exchange}}:{{ticker}}")
alertcondition(Short, "Volume MAs Supertrend  - Short", "Volume MAs Supertrend  is Short {{exchange}}:{{ticker}}")

Overview

Volume MAs Supertrend uses an ATR period with separate long and short multipliers, so the two band sides can sit at different distances. The line and trend are colored using one of several palettes or custom colors. It imports the TradingView technical analysis library.

Details

Published by

vedkanani123 on GitHub

Code credit

LyroRS, as written in the script's header

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Trend, Volatility & bands, Volume

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
Supertrend Lenint10st_len
Long Multiplierfloat3.6l_mult
Short Multiplierfloat1.8s_mult
Select Moving AveragestringEMAMA_Type
Moving Average Lengthint12MA_len
Custom Color PalettestringMysticColMode
Use Custom Paletteboolfalsecpyn
Custom Upcolor#00ff00cp_UpC
Custom Downcolor#ff0000cp_DnC
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

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

This overlay indicator marks Wyckoff-style buying and selling climaxes on the price chart. It filters trend with an exponential moving average and a higher-timeframe EMA, then flags accumulation or distribution when price and ATR sit relative to their swing av

Indicator v6 TrendVolatility & bands
Updated 1 year ago · MIT GitHub repository of Ultimate Wyckoff Indicator V3 (Refined)

Vein Exhaustion is a price-chart indicator that scores how stretched a directional move is before structure confirms a turn. It builds separate bull and bear scores from consecutive directional bars, EMA distance in ATR units, RSI and MFI extremes, volume-base

Indicator v6 TrendOscillators & momentum
Updated 2 days ago · MIT GitHub repository of Vein: Exhaustion [WavesUnchained]
9 stars

This indicator plots a volume-weighted moving average as a central trend baseline and surrounds it with ATR-based volatility bands. It colors the trend and optional price bars according to whether price is on the bullish or bearish side of those bands. Users c

Indicator v6 TrendMoving averages
Updated 4 months ago · MIT GitHub repository of Volume Weighted Trend [QuantAlgo]

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