Indicator · Pine Script v5 · Own pane

Adapting a built-in [PineCoders]

by regalouisei· code credited to PineCoders

This indicator adapts the built-in TradingView volume tool by adding extended visualization options in a separate pane.

View on GitHub

GitHub stars2on the repository
Pine versionv5runs as is
Lines of code79
Settings9inputs
LicenceNone statedfile: MPL-2.0
Last update8 months ago25 Feb 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

79 lines of Pine Script v5 from pinescript/editors_picks/adapting-a-built-in-pinecoders.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

adapting-a-built-in-pinecoders.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © PineCoders

//@version=5
indicator("Adapting a built-in [PineCoders]", "Vol", format = format.volume)

// Adapting a built-in [PineCoders]
// v3, 2022.10.01

// This code was written using the recommendations from the Pine Script™ User Manual's Style Guide:
//   https://www.tradingview.com/pine-script-docs/en/v5/writing/Style_guide.html



// ———————————————————— Constants and Inputs {


// ————— Constants
color BULL  = #00FF00
color BEAR  = #FF0000
color MA    = color.new(color.gray, 40)
color GRAY  = #808080ff
color WHITE = #FFFFFFff

// ————— Inputs
bool    showMaInput             = input.bool(true,          "Show MA, ",                inline = "ma")
int     maLengthInput           = input.int(20,             "Length",                   inline = "ma", minval = 1)
bool    usePrevClInput          = input.bool(false,         "Color columns based on previous close")
bool    showInfoBoxInput        = input.bool(true,          "Show values")
string  infoBoxSizeInput        = input.string("normal",    "Size ",                    inline = "display", options = ["tiny", "small", "normal", "large", "huge", "auto"])
string  infoBoxYPosInput        = input.string("top",       "↕",                        inline = "display", options = ["top", "middle", "bottom"])
string  infoBoxXPosInput        = input.string("left",      "↔",                        inline = "display", options = ["left", "center", "right"])
color   infoBoxTxtColorInput    = input.color(WHITE,        "T",                        inline = "display")
float   leftMarginInput         = input.float(2.0,          "Left margin",              minval =  1,  maxval = 100, step = 0.5, tooltip = "1-100")
// } 



// ———————————————————— Calculations {


// Color of the volume columns.
color columns = usePrevClInput ? close[1] > close ? BEAR : BULL : open > close ? BEAR : BULL
// MA of volume calculation. We use `nz()` so that value is zero when the symbol has no volume information.
float ma = ta.sma(nz(volume), maLengthInput)
// Detect when the MA is rising. Will be used to determine the color of the background of the MA value's table cell.
bool maRises = ta.rising(ma, 1)
// }



// ———————————————————— Visuals {


// ————— Display table
if showInfoBoxInput
    // Create a 4-column, 1-row table.
    var table infoBox = table.new(infoBoxYPosInput + "_" + infoBoxXPosInput, 4, 1)
    // MA cell's bg is bull color when MA is rising.
    color bgMa = maRises ? BULL : BEAR
    // Volume cell's bg is bull color when volume is above its MA.
    color bgVol = volume > ma ? BULL : BEAR
    if barstate.isfirst
        // Left margin.
        table.cell(infoBox, 0, 0, " ", width = leftMarginInput)
        table.cell(infoBox, 1, 0, "",  text_color = infoBoxTxtColorInput, text_size = infoBoxSizeInput, bgcolor = bgMa)
        // Small space between values (note that you can use a float width).
        table.cell(infoBox, 2, 0, " ", width = 0.5)
        table.cell(infoBox, 3, 0, "",  text_color = infoBoxTxtColorInput, text_size = infoBoxSizeInput, bgcolor = bgVol)
    else if barstate.islast
        table.cell_set_text(   infoBox, 1, 0, str.format("SMA({0}): {1,number,###,####,###}", maLengthInput, ma))
        table.cell_set_bgcolor(infoBox, 1, 0, bgMa) 
        table.cell_set_text(   infoBox, 3, 0, str.format("Vol: {0,number,###,####,###}", nz(volume)))
        table.cell_set_bgcolor(infoBox, 3, 0, bgVol)  
        
// ————— Plots
plot(volume, "Volume", columns, 1, plot.style_columns)
plot(showMaInput ? ma : na, "Volume MA", MA, 1, plot.style_area)
// }

Overview

Adapting a built-in [PineCoders] plots volume columns colored by price direction relative to the open or previous close, alongside a simple moving average of volume. An optional on-screen information box displays the volume simple moving average value and highlights whether the moving average is rising or if current volume exceeds the average. User settings adjust the moving average period, volume coloring criteria, and the placement and appearance of the dashboard table.

Details

Published by

regalouisei on GitHub

Code credit

PineCoders, as written in the script's header

Type

Indicator, Pine Script v5

Draws

Separate pane below the chart

Category

Volume, Moving averages, Screeners & dashboards

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
Show MA, booltrueshowMaInput
Lengthint20maLengthInput
Color columns based on previous closeboolfalseusePrevClInput
Show valuesbooltrueshowInfoBoxInput
Size stringnormalinfoBoxSizeInput
↕stringtopinfoBoxYPosInput
↔stringleftinfoBoxXPosInput
TcolorWHITEinfoBoxTxtColorInput
Left marginfloat2.0leftMarginInput
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

7 stars

This indicator combines a fast and slow exponential moving average crossover, an RSI filter, and a volume flow indicator into a weighted directional score. It draws an on-chart dashboard for those components and can plot buy or sell arrows when the score meets

Indicator v6 Screeners & dashboardsMoving averages
Updated 3 months ago · None stated GitHub repository of Scalping 3-Signal Dashboard v2
257 stars

Donald SPX - Options Trading is an indicator designed to assist SPX index option traders by tracking session benchmarks and multi-timeframe moving average data. It calculates a 200-period weighted moving average (WMA) and requests multi-timeframe bar data from

Indicator v5 Moving averagesScreeners & dashboards Repaints
Updated 6 weeks ago · None stated GitHub repository of Donald SPX - Options Trading
218 stars

Multi-Timeframe Analysis Suite calculates trend direction and momentum conditions across five user-selected timeframes using moving averages, RSI, and Stochastic oscillators. It evaluates moving average slope and oscillator levels to compute trend alignment, m

Indicator v6 Screeners & dashboardsTrend
Updated 3 months ago · None stated GitHub repository of Multi-Timeframe Analysis Suite

KamaFama

by Mastaaa1987
141 stars

KamaFama is an indicator that translates a Freqtrade trading strategy into Pine Script for visualization. It combines Kaufman Adaptive Moving Average (KAMA), MAMA/FAMA calculations derived via Hilbert Transform, Williams %R, and correlation trend filters to ev

Indicator v6 Moving averagesOscillators & momentum
Updated 6 weeks ago · MIT GitHub repository of KamaFama

Aggregate Signal (v.2)

by capissimo
114 stars

Aggregate Signal (v.2) is an oscillator indicator that combines multiple technical factors into a single composite score. It scales OHLCV data using minimax normalization and evaluates indicators such as MACD, RSI, Stochastic, CCI, Momentum, On-Balance Volume,

Indicator v4 Oscillators & momentumMoving averages Repaints
Updated 1 year ago · None stated GitHub repository of Aggregate Signal (v.2)

Volume-Weighted MACD

by mihakralj
99 stars

This indicator plots a volume-weighted MACD in a separate pane. It subtracts a slow volume-weighted moving average of close from a faster one, then smooths that line with an exponential moving average to form the signal. A column histogram shows the gap betwee

Indicator v5 Oscillators & momentumMoving averages
Updated 4 weeks ago · Apache-2.0 GitHub repository of Volume-Weighted MACD

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