Indicator · Pine Script v5 · On the chart

Volume Bar Colors

by benso87

This indicator highlights price candles based on unusual volume expansion and directional volume imbalance.

View on GitHub

GitHub stars24on the repository
Pine versionv5runs as is
Lines of code32
Settings7inputs
LicenceMPL-2.0
Last update4 years ago5 Oct 2022

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

32 lines of Pine Script v5 from Volume Bar Colors.pine, published under MPL-2.0. Keep the author's credit and licence lines when you reuse it.

Volume Bar Colors.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © benso87

//@version=5
indicator("Volume Bar Colors", shorttitle='Volume Bars', overlay=true, max_bars_back=500)

// inputs
showBuy = input.bool(true, title='Buy Volume', inline='1', group='Volume')
highBuyColor = input.color(color.yellow, title='', inline='1', group='Volume')
showSell = input.bool(true, title='Sell Volume', inline='2', group='Volume')
highSellColor = input.color(color.orange, title='', inline='2', group='Volume')
bsRatio = input.float(2, title='Buy/Sell Ratio (2 = 200%)', inline='3', group='Volume')
volRatio = input.float(2, title='Total Volume Ratio (2 = 200%)', inline='3', group='Volume')
volPeriod = input.int(20, title='Volume Moving Average', inline='4', group='Volume')

// calculations
buyVol = high == low ? 0 : volume * (close - low) / (high - low)
sellVol = high == low ? 0 : volume * (high - close) / (high - low)

highVol = volume >= volRatio * ta.sma(volume, volPeriod)

highBuy = showBuy and highVol ? buyVol >= (bsRatio * buyVol[1]) and buyVol > sellVol : na
highSell = showSell and highVol ? sellVol >= (bsRatio * sellVol[1]) and sellVol > buyVol : na

// plots
barcolor(highBuy ? highBuyColor : highSell ? highSellColor : na)

// debug
// plotchar(buyVol, title='buyVol', location=location.abovebar, color=color.new(color.white, transp=100))
// plotchar(sellVol, title='sellVol', location=location.abovebar, color=color.new(color.white, transp=100))
// plotchar(buyVol[1], title='prev buyVol', location=location.abovebar, color=color.new(color.white, transp=100))
// plotchar(sellVol[1], title='prev sellVol', location=location.abovebar, color=color.new(color.white, transp=100))

Overview

Volume Bar Colors estimates buying and selling volume from the close position relative to the bar range. When total volume exceeds a multiple of its moving average, the script checks if buying or selling volume surpasses the opposing side and exceeds the prior bar by a configurable ratio. Qualifying candles are painted with custom colors directly on the main chart pane.

Details

Published by

benso87 on GitHub

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Volume, Candlestick patterns

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
Buy VolumebooltrueshowBuy
highBuyColorcolorcolor.yellowhighBuyColor
Sell VolumebooltrueshowSell
highSellColorcolorcolor.orangehighSellColor
Buy/Sell Ratio (2 = 200%)float2bsRatio
Total Volume Ratio (2 = 200%)float2volRatio
Volume Moving Averageint20volPeriod
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

23 stars

Point-Clip Unified Indicator plots breakout and directional labels on the price chart. It scores volume spikes against a volume average, range or opening-range breaks, optional VWAP or session-anchored VWAP, fast and slow EMA trend, and a higher-timeframe EMA

Indicator v6 BreakoutVolume Repaints
Updated 3 weeks ago · Custom licence GitHub repository of Point-Clip Unified Indicator
4 stars

This indicator recolors price candles from recent volume and range. It marks climax bars when current volume times range exceeds the prior ten-bar peak or volume is at least twice a ten-bar average, and rising bars at one and a half times that average. Bullish

Indicator v5 VolumeCandlestick patterns
Updated 9 months ago · None stated GitHub repository of Price-Volume Analysis

This overlay indicator draws rounded psychological price levels and optional PVSRA vector candle colors on the price chart. It plots quarter, half, and whole levels from a user-set rounding value, with separate color, line style, and width for each. Vector col

Indicator v5 Support & resistanceVolume
Updated 5 months ago · None stated GitHub repository of Level Theory + Vector Candles

Stella's Smart Money Proxy

by stella-entry
3 stars

This indicator detects institutional or large-scale market activity using candle body size and trading volume. It compares current candle bodies against a 20-period simple moving average and checks for volume spikes above an adjustable moving average filter. I

Indicator v6 VolumeCandlestick patterns
Updated 8 months ago · MIT GitHub repository of Stella's Smart Money Proxy
2 stars

This overlay approximates order-book liquidity from intrabar OHLCV buckets because true depth-of-market data is unavailable. It paints a decaying volume heatmap around price and labels absorption, exhaustion, rejection, and momentum when wick, body, delta, and

Indicator v6 VolumeSupport & resistance
Updated 4 months ago · None stated GitHub repository of Bookmap Liquidity Mapper [TReset]

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