Indicator · Pine Script v5 · On the chart

PriceCatch Volume Analysis Fixed Range

by PriceCatch

Calculates and compares estimated buying and selling volume over a fixed lookback period from the latest bar.

View on GitHub

GitHub stars2on the repository
Pine versionv5runs as is
Lines of code55
Settings3inputs
LicenceMPL-2.0
Last update1 year ago24 Apr 2025

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

55 lines of Pine Script v5 from Pinescripts/PriceCatch Volume Analysis Fixed Range.pinescript, published under MPL-2.0. Keep the author's credit and licence lines when you reuse it.

PriceCatch Volume Analysis Fixed Range.pinescript
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © PriceCatch
//@version=5
indicator("PriceCatch Volume Analysis Fixed Range", shorttitle='PriceCatch Volume Analysis Fixed Range', overlay=true, max_bars_back=500)
lbp = input.int(20,title="Lookback period", minval = 3, maxval=498, display=display.none, tooltip="Lookback period from current bar for Volume analysis")
upvolbg = input.color(#0098b3, title="Up Volume", group="Volume Box Background Color", inline="xx0", display=display.none)
dnvolbg = input.color(#e9b60d, title="Down Volume", group="Volume Box Background Color", inline="xx0", display=display.none)

var float volprcnt = na 
var startBar = 0
var endBar = 0

if barstate.islast
    startBar := bar_index[lbp-1]
    endBar := bar_index

    float upvol = 0
    float dnvol = 0
    int upcount = 0 
    int dncount = 0

    var label lbl_vpfvol = na 
    var line connectline = na 
    for i = 0 to lbp-1
        buy_distance = high[i] - low[i]
        sell_distance = (open[i] - low[i]) + (high[i] - close[i])
        tot_distance = buy_distance + sell_distance
        buy_volume = buy_distance / tot_distance * volume[i]
        sell_volume = sell_distance / tot_distance * volume[i]
        upvol += buy_volume
        dnvol += sell_volume
            
        if close[i] > open[i]
            upcount += 1
        if close[i] <= open[i]
            dncount += 1

    volprcnt := (100 * upvol / dnvol) - 100 
    _volan_bx_color = volprcnt > 0 ? upvolbg : dnvolbg
    _volan_ln_color = _volan_bx_color

    _txt0 = "LAST " + str.tostring(lbp) + " BARS VOLUME (Vol) \n"
    volstrength = upvol > dnvol ? "Up Vol > Down Vol " : "Up Vol < Down Vol "    
    _txt1 = "by: " + str.tostring(volprcnt,format.percent)  + "\n" 
    _txt2 = "(" + str.tostring(upcount)  + ")  Up Vol   : " + str.tostring(upvol, format.volume) + "\n"
    _txt3 = "(" + str.tostring(dncount)  + ")  Down Vol : " + str.tostring(dnvol, format.volume)

    finaltxt = _txt0 + volstrength + _txt1 + _txt2 + _txt3
    ypos = math.min(low[lbp], low)
    lbl_vpfvol := label.new(x=bar_index+1, y=ypos, text=finaltxt, color=_volan_bx_color,textcolor = #1b1b1b,text_font_family = font.family_monospace, style = label.style_label_left, textalign = text.align_left) 
    label.delete(lbl_vpfvol[1]) 
    connectline := line.new(startBar, ypos, endBar,ypos, style=line.style_arrow_both, color=color.new(_volan_ln_color,60))
    line.delete(connectline[1])

// eof

Overview

For each bar in the range, volume is apportioned between buyers and sellers according to price movement distances. The indicator displays an informational label and a horizontal range line directly on the price chart, detailing the volume breakdown, up and down candle counts, and percentage difference. Key inputs allow adjusting the lookback length and label colors. Computations execute on the last bar.

Details

Published by

PriceCatch on GitHub

Draws

On the price 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.

Topics

javascriptlightweight-chartspinescriptpythontrading-strategies

Settings

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

SettingTypeDefaultVariable
Lookback periodint20lbp
Up Volumecolor#0098b3upvolbg
Down Volumecolor#e9b60ddnvolbg
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

Calculates an Elastic Volume Weighted Moving Average (EVWMA), incorporating trading volume to dynamically adjust moving average responsiveness over a specified lookback length. It plots directly on the price chart as a single moving average line. Optional colo

Indicator v4 Moving averagesVolume
Updated 12 days ago · GPL-3.0 GitHub repository of Elastic Volume Weighted Moving Average

This overlay indicator screens a pasted list of up to forty symbols and draws a table on the price chart. It classifies bullish or bearish setups from the percent change between the current candle and the candle 250 bars back, then shows RSI with a simple movi

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

This overlay indicator draws a fixed-range volume profile on the price chart, splitting traded activity into up and down volume at each price level. It also plots a sentiment profile, a developing point of control, and value-area high and low around a configur

Indicator v5 VolumeSupport & resistance
Updated 2 months ago · MIT GitHub repository of Volume Profile and Indicator by DGT

META-tracker

by Allen1212
303 stars

This indicator overlays historical ARK Invest buy and sell events for META on the price chart. It places green labels below bars for purchases and red labels above bars for sales, with a same-day count of how many selected ARK ETFs traded the stock. The ETF in

Indicator v4 Volume
Updated 2 years ago · None stated GitHub repository of META-tracker
228 stars

Comprehensive Volume Profile is an overlay indicator that calculates and plots volume distribution across specified time ranges such as daily sessions, weekly, monthly, or custom bar lengths. It identifies key structural price levels including the Point of Con

Indicator v6 VolumeSupport & resistance
Updated 3 months ago · None stated GitHub repository of Comprehensive Volume Profile

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