TradingView VOLUME MAS - TradingView Pine Editor Script

Shield

Well-known member
Staff member
Administrative
Register
Credits
4,491
TradingView Pine Editor Script


The Volume MAS Indicator helps traders identify volume strength, momentum, and trend reversals with accuracy.

πŸ”₯Features:
βœ… Volume strength detection
βœ… Momentum shift confirmation
βœ… Long/Short signal alerts
βœ… Works on all timeframes & pairs
βœ… Simple setup – ready to use

Copy and Paste the Script as you need.

Rich (BB code):
//@version=6
indicator("Volume MAs Oscillator | Lyro RS")

import LyroRS/LMAs/1 as DynamicMAs

// Groups
ma_g = "π— π—’π—©π—œπ—‘π—š π—”π—©π—˜π—₯π—”π—šπ—˜"
bands_g = "𝗕𝗔𝗑𝗗"
display_g = 'π——π—œπ—¦π—£π—Ÿπ—”π—¬'


// Inputs

// -- Moving Average
source = input.source(close, "Source", group= ma_g, tooltip= "Select where the data originates (open, high, low, close, etc..).")
ma_type = input.string("EMA", "Select Moving Average", options=["SMA", "EMA", "WMA", "VWMA", "DEMA", "TEMA", "RMA", "HMA", "LSMA", "SMMA", "ALMA", "ZLSMA", "FRAMA", "KAMA", "JMA", "T3"], group=ma_g, tooltip="Choose a moving average type to apply to the price multiplied by volume. VWMA already incorporates volume directly.")
ma_length = input.int(30, "Moving Average Length", group= ma_g, tooltip= "Defines the length or period of the selected moving average.")

// -- Bands
band_length = input.int(27, "Band Length", group=bands_g, tooltip="Number of bars used to calculate standard deviation.")
band_smoothing = input.float(0.8, "Band Smoothing", group=bands_g, minval=0, tooltip="Smooths the band edges to reduce noise.")
pbm = input.float(1.8, "Positive Band Multiplier", group=bands_g, minval=0, tooltip="Multiplier for the upper band distance.")
nbm = input.float(-0.85, "Negative Band Multiplier", group=bands_g, maxval=0, tooltip="Multiplier for the lower band distance.")


// Color Inputs
signal_type = input.string("Trend", "Select Signal Type", options=["Trend", "Reversion", "Valuation"], group=display_g, tooltip="Select which way to use the indicator.")
ColMode = input.string("Mystic", "Custom Color Palette", inline="drop", options=["Classic", "Mystic", "Accented", 'Royal'], display=display.none, group= display_g, tooltip="Select a predefined color scheme for the indicator display. (Major Themes color mode automatically switches colors based on the major asset you picked for valuation analysis.)")


cpyn           = input.bool  (true,             "Use Custom Palette", group= display_g, display=display.none, tooltip="Enables custom color selection for signals.")
cp_UpC        = input.color (#00ff00,         "Custom Up", inline = "Custom Palette", group= display_g, display=display.none, tooltip="")
cp_DnC        = input.color (#ff0000,         "Custom Down", inline = "Custom Palette", group= display_g, display=display.none, tooltip="User specifed bullish and bearish colors.")
d_obos_sigs           = input.bool  (true,             "Display Oversold/Overbought Signs", group= display_g, display=display.none, tooltip="Enables triangle signs to be displayed.")
d_signs           = input.bool  (true,             "Display Signs", group= display_g, display=display.none, tooltip="Enables signs for Trend mode.")
d_bgcol           = input.bool  (true,             "Display Background Color", group= display_g, display=display.none, tooltip="Enables background color for Reversion & Valuation mode.")



// Colors
color UpC = na
color DnC = na


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


// -- Custom Colors
if cpyn
    UpC := cp_UpC
    DnC := cp_DnC


// Coloring Function for Valuation
coloring(src) =>
    color.from_gradient(src, ta.lowest(src, band_length), ta.highest(src, band_length), UpC, DnC)


// Moving Average Switch
float ma = na
switch ma_type
    "SMA"   => ma := DynamicMAs.SMA(source * volume, ma_length) / DynamicMAs.SMA(volume, ma_length)
    "EMA"   => ma := DynamicMAs.EMA(source * volume, ma_length) / DynamicMAs.EMA(volume, ma_length)
    "WMA"   => ma := DynamicMAs.WMA(source * volume, ma_length) / DynamicMAs.WMA(volume, ma_length)
    "VWMA"  => ma := DynamicMAs.VWMA(source, volume, ma_length) // Already Volume Based MA
    "DEMA"  => ma := DynamicMAs.DEMA(source * volume, ma_length) / DynamicMAs.DEMA(volume, ma_length)
    "TEMA"  => ma := DynamicMAs.TEMA(source * volume, ma_length) / DynamicMAs.TEMA(volume, ma_length)
    "RMA"   => ma := DynamicMAs.RMA(source * volume, ma_length) / DynamicMAs.RMA(volume, ma_length)
    "HMA"   => ma := DynamicMAs.HMA(source * volume, ma_length) / DynamicMAs.HMA(volume, ma_length)
    "LSMA"  => ma := DynamicMAs.LSMA(source * volume, ma_length, 0) / DynamicMAs.LSMA(volume, ma_length, 0)
    "SMMA"  => ma := DynamicMAs.SMMA(source * volume, ma_length) / DynamicMAs.SMMA(volume, ma_length)
    "ALMA"  => ma := DynamicMAs.ALMA(source * volume, ma_length, 0, 20) / DynamicMAs.ALMA(volume, ma_length, 0, 20)
    "ZLSMA" => ma := DynamicMAs.ZLSMA(source * volume, ma_length) / DynamicMAs.ZLSMA(volume, ma_length)
    "FRAMA" => ma := DynamicMAs.FRAMA(source * volume, ma_length) / DynamicMAs.FRAMA(volume, ma_length)
    "KAMA"  => ma := DynamicMAs.KAMA(source * volume, ma_length) / DynamicMAs.KAMA(volume, ma_length)
    "JMA"   => ma := DynamicMAs.JMA(source * volume, ma_length, 0) / DynamicMAs.JMA(volume, ma_length, 0)
    "T3"    => ma := DynamicMAs.T3(source * volume, ma_length, 0.5) / DynamicMAs.T3(volume, ma_length, 0.5)





price_diff = ((source - ma) / ma) * 100 // Percentage Difference between Source and the Moving Average of the source




// Calculations for the Bands
std          = ta.stdev(price_diff, band_length)
upperBandRaw = std * pbm
lowerBandRaw = std * nbm

var float upperBand = na
var float lowerBand = na
// Smooth
upperBand := upperBandRaw * band_smoothing + nz(upperBand[1]) * (1 - band_smoothing)
lowerBand := lowerBandRaw * band_smoothing + nz(lowerBand[1]) * (1 - band_smoothing)


// Plot Color
var color pc = na
var color uB_color = na
var color lB_color = na
var int signal = 0

if signal_type == "Trend"
    uB_color := UpC
    lB_color := DnC
    if price_diff > upperBand
        pc := UpC
        signal := 1

    if price_diff < lowerBand
        pc := DnC
        signal := -1



if signal_type == "Reversion"
    uB_color := DnC
    lB_color := UpC

    if price_diff > upperBand
        pc := DnC
        signal := -1

    else if price_diff < lowerBand
        pc := UpC
        signal := 1

    else
        pc := color.gray
        signal := 0



if signal_type == "Valuation"
    uB_color := UpC
    lB_color := DnC

    pc := coloring(price_diff)




// Plot
plot(price_diff, color= pc, linewidth = 2, title= "Volume MAs Oscillator")
plot(upperBand, color= color.new(uB_color, 50), title= "Upper Band")
plot(lowerBand, color= color.new(lB_color, 50), title= "Lower Band")

plot(0, color= color.new(pc, 60), linewidth = 2, display= display.pane, title= "Mid Line")
plot(0, color= color.new(pc, 75), linewidth = 5, display= display.pane, title= "Mid Line Glow 1")
plot(0, color= color.new(pc, 85), linewidth = 10, display= display.pane, title= "Mid Line Glow 2")

plotchar(upperBand + 0.5, char='β–Ό', color= ta.crossunder(price_diff, upperBand) ? DnC : na, location=location.absolute, title= "Overbought Signal", display= d_obos_sigs ?  display.pane : display.none, size= size.tiny)
plotchar(lowerBand - 0.5, char='β–²', color= ta.crossover(price_diff, lowerBand) ? UpC : na, location=location.absolute, title= "Oversold Signal", display= d_obos_sigs ?  display.pane : display.none, size= size.tiny)



reversion_enable = signal_type == "Reversion"
valuation_enable = signal_type == "Valuation"

bgcolor(d_bgcol and ((valuation_enable and price_diff > upperBand) or (reversion_enable and ta.crossunder(price_diff, upperBand))) ? color.new(DnC, 85) : na, title= "BG Color OB")
bgcolor(d_bgcol and ((valuation_enable and price_diff > upperBand) or (reversion_enable and ta.crossunder(price_diff, upperBand))) ? color.new(DnC, 85) : na, title= "BG Color OB Overlay", force_overlay = true)

bgcolor(d_bgcol and ((valuation_enable and price_diff < lowerBand) or (reversion_enable and ta.crossover(price_diff, lowerBand))) ? color.new(UpC, 85) : na, title= "BG Color OS")
bgcolor(d_bgcol and ((valuation_enable and price_diff < lowerBand) or (reversion_enable and ta.crossover(price_diff, lowerBand))) ? color.new(UpC, 85) : na, title= "BG Color OS Overlay", force_overlay = true)



plotshape(ta.crossover(signal, 0), title="Buy Signal", location=location.belowbar,
           style=shape.labelup, text="𝓛𝓸𝓷𝓰", textcolor=#000000, size=size.small,
           color=UpC, force_overlay=true, display= signal_type == "Trend" and d_signs == true ? display.pane : display.none)

plotshape(ta.crossunder(signal, 0), title="Sell Signal", location=location.abovebar,
           style=shape.labeldown, text="𝓒𝓱𝓸𝓻𝓽", textcolor=#000000, size=size.small,
           color=DnC, force_overlay=true, display= signal_type == "Trend" and d_signs == true ? display.pane : display.none)


plotcandle(open, high, low, close, color= pc, wickcolor = pc, bordercolor = pc, force_overlay = true, display= display.pane, title= "Plot Candle")
barcolor(pc, title= "Barcolor")
 
Back
Top