Indicator · Pine Script v5 · On the chart

Vector Candles

by TamTH-Dev· code credited to tamth_

Vector Candles is an overlay indicator that recolors price bars according to relative trading volume and volume spread.

View on GitHub

GitHub stars2on the repository
Pine versionv5runs as is
Lines of code93
Settings6inputs
LicenceNone statedfile: MPL-2.0
Last update5 weeks ago18 Sep 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

93 lines of Pine Script v5 from collections/VectorCandles.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

VectorCandles.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © tamth_

// @version=5
indicator(title = "Vector Candles", shorttitle = "Vector Candles", overlay = true, max_bars_back = 500, max_boxes_count = 500, max_lines_count = 500, max_labels_count = 500)


//-----------------------------------------------------------------------------*
//  Constants
//-----------------------------------------------------------------------------{
color TRANSPARENT_COLOR = #ffffff00
color WHITE_COLOR = #ffffff
color RED_COLOR = #e91e62
color AQUA_COLOR = #00bbf9
color LIGHT_GRAY_COLOR = #364156
color DARK_GRAY_COLOR = #212d40
color GREEN_COLOR = #A4F233
color YELLOW_COLOR = #F2CA63
color PURPLE_COLOR = #764AF1
color PINK_COLOR = #D557F2
color TXT_COLOR = #787b86
color BLOCK_COLOR = #5d606b19

//-----------------------------------------------------------------------------}


//-----------------------------------------------------------------------------*
// Common Functions
//-----------------------------------------------------------------------------{
debug(simple string txt) =>
    // Create label on the first bar
    var label = label.new(bar_index, na, txt, xloc.bar_index, yloc.price, color(na), label.style_none, WHITE_COLOR, size.large, text.align_left)
    // On next bars, update the label"s x and y position, and the text it displays
    label.set_xy(label, bar_index, ta.highest(10)[1])
    label.set_text(label, txt)

//-----------------------------------------------------------------------------}


//-----------------------------------------------------------------------------*
// Settings
//-----------------------------------------------------------------------------{
string vcsGrp = "Vector Candles"
color lgVolUpCandleColor = input.color(GREEN_COLOR, title = "Large Volume Up Candle Color", group = vcsGrp)
color mdVolUpCandleColor = input.color(YELLOW_COLOR, title = "Medium Volume Up Candle Color", group = vcsGrp)
color lgVolDnCandleColor = input.color(PURPLE_COLOR, title = "Large Volume Down Candle Color", group = vcsGrp)
color mdVolDnCandleColor = input.color(PINK_COLOR, title = "Medium Volume Down Candle Color", group = vcsGrp)
string ncsGrp = "Normal Candles"
color norUpCandleColor = input.color(AQUA_COLOR, title = "Normal Up Candle Color", group = ncsGrp)
color norDnCandleColor = input.color(RED_COLOR, title = "Normal Down Candle Color", group = ncsGrp)

//-----------------------------------------------------------------------------}


//-----------------------------------------------------------------------------*
// Functions
//-----------------------------------------------------------------------------{
getVcsColor(series float _vol, series float _high, series float _low, series float _close, series float _open, simple color lgVolDnCandleColor, simple color lgVolUpCandleColor, simple color mdVolDnCandleColor, simple color mdVolUpCandleColor, simple color norDnCandleColor, simple color norUpCandleColor) =>
    float avgVol = math.sum(_vol[1], 10) / 10.0
    float volSpread = _vol * (_high - _low)
    float highestVolSpread = ta.highest(volSpread[1], 10)
    color vcsColor = na
    
    // Large volume
    if _vol >= 2 * avgVol or volSpread >= highestVolSpread
        vcsColor := _close > _open ? lgVolUpCandleColor : lgVolDnCandleColor
    // Medium volume
    else if _vol >= 1.5 * avgVol
        vcsColor := _close > _open ? mdVolUpCandleColor : mdVolDnCandleColor
    // Normal volume
    else
        vcsColor := _close > _open ? norUpCandleColor : norDnCandleColor

    vcsColor

//-----------------------------------------------------------------------------}


//-----------------------------------------------------------------------------*
// Get Values
//-----------------------------------------------------------------------------{
[_vol, _high, _low, _close, _open] = request.security(syminfo.tickerid, timeframe.period, [volume,high,low,close,open], barmerge.gaps_off, barmerge.lookahead_off)

//-----------------------------------------------------------------------------}


//-----------------------------------------------------------------------------*
// Render Vector Candles
//-----------------------------------------------------------------------------{
vcsColor = getVcsColor(_vol, _high, _low, _close, _open, lgVolDnCandleColor, lgVolUpCandleColor, mdVolDnCandleColor, mdVolUpCandleColor, norDnCandleColor, norUpCandleColor)
barcolor(vcsColor)

//-----------------------------------------------------------------------------}

Overview

Vector Candles compares current volume against a 10-bar moving average and evaluates volume spread relative to recent highs. Bars are categorized and highlighted as large volume, medium volume, or normal volume, with distinct colors for bullish and bearish closes. The settings allow users to customize colors for each volume and direction tier.

Details

Published by

TamTH-Dev on GitHub

Code credit

tamth_, as written in the script's header

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
Large Volume Up Candle ColorcolorGREEN_COLORlgVolUpCandleColor
Medium Volume Up Candle ColorcolorYELLOW_COLORmdVolUpCandleColor
Large Volume Down Candle ColorcolorPURPLE_COLORlgVolDnCandleColor
Medium Volume Down Candle ColorcolorPINK_COLORmdVolDnCandleColor
Normal Up Candle ColorcolorAQUA_COLORnorUpCandleColor
Normal Down Candle ColorcolorRED_COLORnorDnCandleColor
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

Vector Candles

by benso87
24 stars

Vector Candles is an overlay indicator that recolors price candles using PVSRA volume rules taken from the Traders Reality concept. It compares each bar's volume with the average of the previous ten bars and also checks the product of spread and volume against

Indicator v5 VolumeCandlestick patterns
Updated 4 years ago · MPL-2.0 GitHub repository of Vector Candles
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

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