Indicator · Pine Script v5 · On the chart

Candle Color by Volume

by suyons· code credited to the_MarketWhisperer

This indicator recolors candlestick bodies directly on the main price chart based on relative trading volume.

View on GitHub

GitHub stars7on the repository
Pine versionv5runs as is
Lines of code44
Settings1inputs
LicenceNone statedfile: MPL-2.0
Last update4 months ago21 Jun 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

44 lines of Pine Script v5 from volume/01-candle-color-by-volume.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

01-candle-color-by-volume.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © the_MarketWhisperer
// Version 1.0
// (Based on a code that I found somewhere in the TV world)
// A simple indicator that paints candles with different shades of colors based on the volume transacted. 
// Supports 6 levels of sensitivity at present.
// Darkest indicates the most volume transacted. Lightest, the least.
// Use it for your Volume Spread Analysis and/or in conjunction with any other strategies that you employ.
// Relative volume is calculated based on EMA (set to 20 period by default)

//@version=5
indicator(title='Candle Color by Volume', shorttitle='Candle Color by Volume', overlay=true)

length = input(20, 'MA Length')
volumeRatio = volume / ta.sma(volume, length)
isUp = close > open

//{
//=============================================================================================================================
//Green and red color repository. 1 = lightest / 6 = darkest
g_01 = #82E0AA
g_02 = #58D68D
g_03 = #2ECC71
g_04 = #28B463
g_05 = #239B56
g_06 = #1D8348

r_01 = #F1948A
r_02 = #EC7063
r_03 = #E74C3C
r_04 = #CB4335
r_05 = #B03A2E
r_06 = #943126
//-----------------------------------------------------------------------------------------------------------------------------
//}

color candleColor = na

if isUp
    candleColor := volumeRatio > 2 ? g_01 : volumeRatio > 1.5 ? g_02 : volumeRatio > 1.2 ? g_03 : volumeRatio > 0.8 ? g_04 : volumeRatio > 0.4 ? g_05 : g_06
else
    candleColor := volumeRatio > 2 ? r_01 : volumeRatio > 1.5 ? r_02 : volumeRatio > 1.2 ? r_03 : volumeRatio > 0.8 ? r_04 : volumeRatio > 0.4 ? r_05 : r_06

barcolor(candleColor)

Overview

Candle Color by Volume calculates volume relative to a simple moving average (SMA) over a user-defined length. Up bars and down bars are assigned one of six distinct color shades depending on how far the current volume exceeds or falls below the average. Traders can adjust the moving average length to customize the baseline relative volume sensitivity.

Details

Published by

suyons on GitHub

Code credit

the_MarketWhisperer, as written in the script's header

Type

Indicator, Pine Script v5

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.

Settings

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

SettingTypeDefaultVariable
MA Lengthint20length
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 10 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
219 stars

An educational Pine Script v4 indicator demonstrating how to plot volume histograms on the main price chart using unscaled axes. The code includes examples and commented templates for creating vertical line markers at specific dates or time zones, such as mark

Indicator v4 Sessions & timeVolume
Updated 5 years ago · None stated GitHub repository of 教學-畫垂直線1

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