Indicator · Pine Script v6 · Own pane

Buddha Money Flow Classic

by DarthBuddha

A separate-pane volume indicator that reads TradingView footprint data to plot buy, sell and total volume per bar.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code181
Settings13inputs
LicenceMIT
Last update3 months ago15 Jul 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

181 lines of Pine Script v6 from src/MoneyFlow.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

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

//@version=6
indicator(
  title = 'Buddha Money Flow',
  shorttitle = 'Money Flow',
  overlay = false,
  max_boxes_count = 500,
  max_lines_count = 500,
  max_labels_count = 500)

//----------------------------------------------------------------------------------------------------< CONSTANTs >---//

//----------------------------------------------------< COLORs
// @variable - Color - Buy volume
const color CLR_B = color.rgb(0, 128, 0)
// @variable - Color - Sell volume
const color CLR_S = color.rgb(128, 0, 0)
// @variable - Color - Total volume
const color CLR_T = color.rgb(120, 120, 120)
// @variable - Table frame color
const color CLR_FRAME = color.rgb(0, 0, 0)
// @variable - Table text color
const color CLR_TEXT = color.rgb(0, 0, 0)

//----------------------------------------------------< ENUMs
enum State
    On = 'ON'
    Off = 'OFF'

enum Tx
    Tiny = 'Tiny'
    Small = 'Small'
    Normal = 'Normal'
    Large = 'Large'
    Huge = 'Huge'

enum CvdMode
    Off = 'Off'
    Running = 'Running'
    Windowed = 'Windowed'


//-------------------------------------------------------------------------------------------------------< INPUTs >---//

const string g_Colors = "Volume Color"
// @variable - User input Buy volume color
i_CLR_B = input.color(CLR_B, 'Buy', group = g_Colors, inline = '1')
// @variable - User input Sell volume color
i_CLR_S = input.color(CLR_S, 'Sell', group = g_Colors, inline = '1')
// @variable - User input Neutral volume color
i_CLR_T = input.color(CLR_T, 'Total', group = g_Colors, inline = '1')

const string g_Table  = 'Table Settings'
i_TbState = input.enum(State.On,'', group = g_Table, inline = '1')
i_TxSize = input.enum(Tx.Normal, '', group = g_Table, inline = '1')

const string g_Footprint = 'Footprint Settings'
i_TicksPerRow = input.int(25, 'Ticks Per Row', minval = 1, group = g_Footprint)
i_ValueAreaPct = input.float(70.0, 'Value Area %', minval = 1.0, maxval = 100.0, step = 1.0, group = g_Footprint)
i_ImbalancePct = input.float(300.0, 'Imbalance %', minval = 1.0, step = 25.0, group = g_Footprint)

const string g_Display = 'Display Settings'
i_ShowTotalVolume = input.bool(true, 'Show Total Volume', group = g_Display)
i_ShowTable = input.bool(true, 'Show Table', group = g_Display)
i_PositiveColumnsOnly = input.bool(true, 'Columns Above Zero', group = g_Display)
i_CvdMode = input.enum(CvdMode.Windowed, 'CVD Mode', group = g_Display)
i_CvdLength = input.int(50, 'CVD Window', minval = 1, group = g_Display)


//----------------------------------------------------------------------------------------------------< FUNCTIONs >---//

// @function  - State Switch
// @returns   - true or false
switchState(simple State state) =>
    switch state
        State.On => true
        State.Off => false

clamp(x, lo, hi) =>
    math.max(lo, math.min(hi, x))

fmtPct(value) =>
  na(value) ? 'n/a' : str.tostring(value, '#.##') + '%'

//-------------------------------------------------------------------------------------------------< CALCULATIONs >---//

footprint chartFootprint = request.footprint(i_TicksPerRow, i_ValueAreaPct, i_ImbalancePct)
bool hasFootprint = not na(chartFootprint)

buyVol = hasFootprint ? footprint.buy_volume(chartFootprint) : na
sellVol = hasFootprint ? footprint.sell_volume(chartFootprint) : na
deltaValue = hasFootprint ? footprint.delta(chartFootprint) : na
totalVol = hasFootprint ? footprint.total_volume(chartFootprint) : na

volume_row pocRow = hasFootprint ? footprint.poc(chartFootprint) : na
volume_row vahRow = hasFootprint ? footprint.vah(chartFootprint) : na
volume_row valRow = hasFootprint ? footprint.val(chartFootprint) : na

pocPrice = not na(pocRow) ? (volume_row.up_price(pocRow) + volume_row.down_price(pocRow)) * 0.5 : na
vahPrice = not na(vahRow) ? volume_row.up_price(vahRow) : na
valPrice = not na(valRow) ? volume_row.down_price(valRow) : na

buyImbalanceRows = 0
sellImbalanceRows = 0
float maxPositiveRowDelta = na
float maxNegativeRowDelta = na

if hasFootprint
    for row in footprint.rows(chartFootprint)
        float rowDelta = volume_row.delta(row)
        buyImbalanceRows += volume_row.has_buy_imbalance(row) ? 1 : 0
        sellImbalanceRows += volume_row.has_sell_imbalance(row) ? 1 : 0
        maxPositiveRowDelta := na(maxPositiveRowDelta) ? rowDelta : math.max(maxPositiveRowDelta, rowDelta)
        maxNegativeRowDelta := na(maxNegativeRowDelta) ? rowDelta : math.min(maxNegativeRowDelta, rowDelta)

deltaAbs = math.abs(nz(deltaValue, 0.0))
deltaPct = totalVol > 0 ? (deltaValue / totalVol) * 100.0 : na
buyPct = totalVol > 0 ? (buyVol / totalVol) * 100.0 : na
sellPct = totalVol > 0 ? (sellVol / totalVol) * 100.0 : na
cvdRunning = ta.cum(nz(deltaValue, 0.0))
cvdWindowed = math.sum(nz(deltaValue, 0.0), i_CvdLength)
cvd = switch i_CvdMode
    CvdMode.Running => cvdRunning
    CvdMode.Windowed => cvdWindowed
    => na

// Colors for delta bars
deltaColor = deltaValue > 0 ? i_CLR_B : deltaValue < 0 ? i_CLR_S : i_CLR_T

// Output Delta Value
plotDeltaValue = i_PositiveColumnsOnly ? deltaAbs : deltaValue

vmax = math.max(nz(totalVol, 0.0), 1e-10)

cvdBg = deltaValue >= 0
      ? color.from_gradient(deltaValue, 0.0,  vmax, CLR_T, color.lime)
      : color.from_gradient(deltaValue, -vmax, 0.0, color.red, CLR_T)

//--------------------------------------------------------------------------------------------------------< PLOTs >---//

// @variable - Total volume
plot_TotalVolume = plot(i_ShowTotalVolume ? totalVol : na, 'Total Volume', cvdBg, style = plot.style_columns, display = display.pane)

// Delta histogram (zero-centered)
plot_VolumeDelta = plot(plotDeltaValue, 'Volume Delta', deltaColor, style = plot.style_columns, display = display.pane)

hline(0, 'Zero', color.new(CLR_T, 65), hline.style_dotted)

//-------------------------------------------------------------------------------------------------------< TABLEs >---//

var t_CVD = table.new(position = position.middle_right, columns = 2, rows = 3, force_overlay = false)

TW = 0
TH = 33

table.set_frame_color(t_CVD, CLR_FRAME)
table.set_border_color(t_CVD, CLR_FRAME)
table.set_frame_width(t_CVD, 3)
table.set_border_width(t_CVD, 5)

if barstate.islast and switchState(i_TbState) and i_ShowTable
    textSize = str.lower(str.tostring(i_TxSize))

    table.cell(t_CVD, 0, 0, str.tostring(buyVol, '#,###,###'), TW, TH, CLR_TEXT,
      text_halign = text.align_right, text_size = textSize, bgcolor = CLR_B, text_formatting = text.format_bold)
    table.cell(t_CVD, 1, 0, fmtPct(buyPct), TW, TH, CLR_TEXT,
      text_halign = text.align_right, text_size = textSize, bgcolor = CLR_B, text_formatting = text.format_bold)

    table.cell(t_CVD, 0, 1, str.tostring(deltaValue, '#,###,###'), TW, TH, CLR_TEXT,
      text_halign = text.align_right, text_size = textSize, bgcolor = cvdBg, text_formatting = text.format_bold)
    table.cell(t_CVD, 1, 1, fmtPct(deltaPct), TW, TH, CLR_TEXT,
      text_halign = text.align_right, text_size = textSize, bgcolor = cvdBg, text_formatting = text.format_bold)

    table.cell(t_CVD, 0, 2, '- ' + str.tostring(sellVol, '#,###,###'), TW, TH, CLR_TEXT,
      text_halign = text.align_right, text_size = textSize, bgcolor = CLR_S, text_formatting = text.format_bold)
    table.cell(t_CVD, 1, 2, '- ' + fmtPct(sellPct), TW, TH, CLR_TEXT,
      text_halign = text.align_right, text_size = textSize, bgcolor = CLR_S, text_formatting = text.format_bold)

//----------------------------------------------------< END-CODE >----------------------------------------------------//

Overview

Columns can be kept above zero for readability, and a cumulative volume delta line can run continuously or over a chosen window. A summary table can be shown. Settings cover ticks per row, value area percentage, imbalance percentage, colours and text size. It needs a plan and symbol feed that supply footprint data, and bars without it show no value.

Details

Published by

DarthBuddha on GitHub

Draws

Separate pane below the chart

Category

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
BuycolorCLR_Bi_CLR_B
SellcolorCLR_Si_CLR_S
TotalcolorCLR_Ti_CLR_T
i_TbStateenumState.Oni_TbState
i_TxSizeenumTx.Normali_TxSize
Ticks Per Rowint25i_TicksPerRow
Value Area %float70.0i_ValueAreaPct
Imbalance %float300.0i_ImbalancePct
Show Total Volumebooltruei_ShowTotalVolume
Show Tablebooltruei_ShowTable
Columns Above Zerobooltruei_PositiveColumnsOnly
CVD ModeenumCvdMode.Windowedi_CvdMode
Show all 13 settings
SettingTypeDefaultVariable
CVD Windowint50i_CvdLength
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

Money Flow Index

by everget
947 stars

Calculates the standard Money Flow Index (MFI) oscillator alongside an exponential moving average signal line in a separate pane. The script visually highlights trend conditions through dynamic ribbon filling, optional difference histogram bars, and overbought

Indicator v4 Oscillators & momentumVolume
Updated 11 days ago · GPL-3.0 GitHub repository of Money Flow Index

This indicator plots a Supertrend-based trend-following setup in a separate pane and skips conditions it treats as a sideways market. A volatility range is built from an ATR value, with RMA, SMA, EMA, or WMA smoothing, or from a fixed point distance. Optional

Indicator v5 TrendVolatility & bands
Updated 1 year ago · MPL-2.0 GitHub repository of Trend Following Setup - Sideways Market Skipper
550 stars

Range Volume Change compares volume inside a chosen session window with the same window on the previous day and plots that change as a percentage. It accumulates volume during the window and, when enabled, volume outside it, drawing growing columns in a separa

Indicator v5 VolumeSessions & time Repaints
Updated 10 months ago · None stated GitHub repository of Range Volume Change
257 stars

This indicator builds a footprint of estimated buy and sell volume across price rows and plots it in a separate pane. It fills rows from bar low to high, stores volume per row, and draws buy and sell volume boxes, volume-profile boxes, row labels, and cumulati

Indicator v5 Volume Repaints
Updated 6 weeks ago · None stated GitHub repository of Footprint Delta Lite

Commitment Gauge

by harryguiacorn
220 stars

This indicator measures directional momentum by evaluating candlestick body proportions and volume over a user-defined lookback window. It computes the ratio of candle body to total range, weights the cumulative value by volume and absolute body size, and dete

Indicator v4 VolumeCandlestick patterns
Updated 1 year ago · None stated GitHub repository of Commitment Gauge

Aggregate Signal

by capissimo
114 stars

This indicator builds an aggregate oscillator in a separate pane. It scales open, high, low, close, and volume into a 0 to 1 range, then averages scaled readings from MACD, a MACD histogram, RSI, stochastic, CCI, momentum, OBV, a directional index, volume-weig

Indicator v4 Oscillators & momentumVolume Repaints
Updated 1 year ago · None stated GitHub repository of Aggregate Signal

More Volume scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

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

Compare brokers