Indicator · Pine Script v6 · On the chart

PVSR Candles MP

by midngtpickle· code credited to midnight pickle

PVSR Candles MP is a Pine Script indicator that colors candlesticks on the price chart according to synchronized Price Volume Spread Ratio Analysis.

View on GitHub

GitHub stars2on the repository
Pine versionv6current
Lines of code112
Settings14inputs
LicenceCustom licencefile: MPL-2.0
Last update4 weeks ago27 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

112 lines of Pine Script v6 from individual_scripts/pvsr_candles_.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

pvsr_candles_.pine
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © midnight pickle
//
// ============================================================================
//  PVSR Candles MP
//  PVSRA candle colouring (climax / above-average / regular) + vector alerts.
//
//  Split out of "EMA & PVSR Master". Classification logic unchanged.
//
//  ⚠️ SHARED CLASSIFICATION: PVSR Candles, PVSR Volume and PVSR Vector Zones
//  each carry their own copy of the classification inputs and maths. They only
//  agree with each other if the inputs are set identically in all three.
// ============================================================================

//@version=6
indicator("PVSR Candles MP", shorttitle="PVSR Candles MP", overlay=true)

// ==========================================
// 🔹 MASTER TOGGLE
// ==========================================

master_show_pvsr = input.bool(true, title="🔘 MASTER: Show PVSR Candles", group="⚡ MASTER TOGGLES", tooltip="Master toggle for PVSR candle colouring on the price chart")

// --- PVSR Candle Settings ---
show_pvsr_candles = input.bool(true, title="Show PVSR Candles", group="🕯️ PVSR Candle Settings")

// --- Alert Settings ---
show_vector_alerts = input.bool(true, title="Show Vector Candle Alerts", group="🔔 Alert Settings")

// ==========================================
// 🔹 PVSR CLASSIFICATION INPUTS
// ==========================================
// ⚠️ SHARED SETTINGS. These must be set identically in PVSR Candles, PVSR
// Volume and PVSR Vector Zones, or the three will classify the same bar
// differently and their colours will disagree on the chart.

// Classification thresholds
climax_mult   = input.float(2.0, title="Climax Volume ×",       minval=1.0, step=0.1, group="🕯️ PVSR Classification (must match across PVSR scripts)", tooltip="Volume ≥ this × average, or a volume-spread high, marks a climax (green/red) candle.")
aboveavg_mult = input.float(1.5, title="Above-Average Volume ×", minval=1.0, step=0.1, group="🕯️ PVSR Classification (must match across PVSR scripts)", tooltip="Volume ≥ this × average marks an above-average (blue/violet) candle.")
vol_lookback  = input.int(10,    title="Volume Lookback (bars)", minval=1,            group="🕯️ PVSR Classification (must match across PVSR scripts)", tooltip="Bars used for the average volume and volume-spread high.")

// How the lookback window is measured, and which climax test is active.
pvsr_exclude_current = input.bool(true, title="Exclude current bar from lookback", group="🕯️ PVSR Classification (must match across PVSR scripts)", tooltip="ON (canonical): the average volume and the volume-spread high are measured over the PREVIOUS N bars, matching the original PVSRA definition. OFF: the current bar sits inside its own comparison window, so an outsized bar raises the very threshold it is being tested against and can suppress its own signal. Turn OFF to reproduce charts drawn before this option existed.")
pvsr_use_spread_leg  = input.bool(true, title="Use volume × spread climax leg",  group="🕯️ PVSR Classification (must match across PVSR scripts)", tooltip="A bar is climax if volume ≥ climax × average OR volume × range is the highest of the lookback. That second leg fires whenever a bar sets a new lookback high in volume × range, which happens roughly once every N bars regardless of conditions, so it triggers far more often than the volume leg. Turn OFF to see classification driven by volume alone.")

// PVSR Color Settings (shared)
red_vector_color        = input.color(color.rgb(255, 82, 82),   title="Red Vector Candle",   group="🎨 PVSR Color Settings", inline="pvsrc")
green_vector_color      = input.color(color.rgb(76, 175, 80),   title="Green Vector Candle", group="🎨 PVSR Color Settings", inline="pvsrc")
violet_vector_color     = input.color(color.rgb(156, 39, 176),  title="Violet Vector Candle", group="🎨 PVSR Color Settings", inline="pvsrc")
blue_vector_color       = input.color(color.rgb(33, 150, 243),  title="Blue Vector Candle",  group="🎨 PVSR Color Settings", inline="pvsrc")
dark_grey_candle_color  = input.color(color.rgb(100, 100, 100), title="Regular Down Candle", group="🎨 PVSR Color Settings", inline="pvsrc")
light_gray_candle_color = input.color(color.rgb(169, 169, 169), title="Regular Up Candle",   group="🎨 PVSR Color Settings", inline="pvsrc")
// ==========================================
// 🔹 PVSR CLASSIFICATION
// ==========================================
// ⚠️ This block is duplicated byte-for-byte across PVSR Candles, PVSR Volume
// and PVSR Vector Zones. The three scripts only agree if the inputs above are
// set identically in all of them. If candle colours and volume-bar colours
// ever disagree, the cause is a drifted input, not a bug in the maths.

bool  hasVolume    = not na(volume)
float volumeSpread = volume * (high - low)

// Canonical PVSRA measures both comparisons over the PREVIOUS vol_lookback
// bars. With the current bar inside its own window, a large bar drags its own
// average up and can fail the very test it should pass, and the spread test
// degenerates into "is this bar the highest of the last N including itself".
// The [1] offset excludes the current bar from both.
float averageVolume    = pvsr_exclude_current ? ta.sma(volume, vol_lookback)[1]            : ta.sma(volume, vol_lookback)
float highestVolSpread = pvsr_exclude_current ? ta.highest(volumeSpread, vol_lookback)[1]  : ta.highest(volumeSpread, vol_lookback)

// Split out so each climax leg can be toggled and read independently. The
// spread leg fires roughly once every vol_lookback bars by construction, so it
// dominates the volume leg unless it is switched off.
bool climaxByVolume = hasVolume and not na(averageVolume)    and volume      >= climax_mult * averageVolume
bool climaxBySpread = hasVolume and not na(highestVolSpread) and pvsr_use_spread_leg and volumeSpread >= highestVolSpread
bool aboveAverage   = hasVolume and not na(averageVolume)    and volume      >= aboveavg_mult * averageVolume

color pvsraColor  = na
int   pvsraCode   = na
bool  vectorAlert = false

if climaxByVolume or climaxBySpread
    // Climax
    pvsraColor := close > open ? green_vector_color : red_vector_color
    pvsraCode  := close > open ? 3 : -3
    vectorAlert := true
else if aboveAverage
    // Above average
    pvsraColor := close > open ? blue_vector_color : violet_vector_color
    pvsraCode  := close > open ? 2 : -2
    vectorAlert := true
else
    // Regular (also the fallback when volume is unavailable, and on the first
    // vol_lookback bars where the shifted average is not yet defined)
    pvsraColor := close > open ? light_gray_candle_color : dark_grey_candle_color
    pvsraCode  := close > open ? 1 : -1
    vectorAlert := false

// ==========================================
// 🔹 PLOTTING
// ==========================================

candleColorToUse = master_show_pvsr and show_pvsr_candles ? pvsraColor : na
barcolor(candleColorToUse)

// ==========================================
// 🔹 ALERTS
// ==========================================

alertcondition(show_vector_alerts and vectorAlert and pvsraCode >= 2, title="Bullish Vector Candle", message="Bullish Vector Candle")
alertcondition(show_vector_alerts and vectorAlert and pvsraCode <= -2, title="Bearish Vector Candle", message="Bearish Vector Candle")

Overview

PVSR Candles MP classifies each bar as climax volume (colored green or red when volume meets or exceeds average or volume-spread high thresholds), above-average volume (blue or violet), or regular volume (gray). The script draws directly on the price chart with optional vector candle alerts to highlight supply or demand zones. Main settings control master toggles, classification multipliers, lookback periods, current-bar exclusion, and spread-leg climax detection. This provides real-time volume-based market structure visualization without repainting or lookahead.

Details

Published by

midngtpickle on GitHub

Code credit

midnight pickle, as written in the script's header

Type

Indicator, Pine Script v6

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
🔘 MASTER: Show PVSR Candlesbooltruemaster_show_pvsr
Show PVSR Candlesbooltrueshow_pvsr_candles
Show Vector Candle Alertsbooltrueshow_vector_alerts
Climax Volume ×float2.0climax_mult
Above-Average Volume ×float1.5aboveavg_mult
Volume Lookback (bars)int10vol_lookback
Exclude current bar from lookbackbooltruepvsr_exclude_current
Use volume × spread climax legbooltruepvsr_use_spread_leg
Red Vector Candlecolorcolor.rgb(255, 82, 82)red_vector_color
Green Vector Candlecolorcolor.rgb(76, 175, 80)green_vector_color
Violet Vector Candlecolorcolor.rgb(156, 39, 176)violet_vector_color
Blue Vector Candlecolorcolor.rgb(33, 150, 243)blue_vector_color
Show all 14 settings
SettingTypeDefaultVariable
Regular Down Candlecolorcolor.rgb(100, 100, 100)dark_grey_candle_color
Regular Up Candlecolorcolor.rgb(169, 169, 169)light_gray_candle_color
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