OPEN-SOURCE SCRIPT
Cumulative Buy/Sell Volume Ratio[MIT]

Cumulative Volume Ratio
Description:
This dedicated indicator calculates and displays the ratio of cumulative buy volume to cumulative sell volume over the past n bars (Ratio = Cumulative Buy Volume / Cumulative Sell Volume).
Volume is split based on price movement:
Up bars (close > open) → All volume assigned to Buy
Down bars (close < open) → All volume assigned to Sell
Flat bars (close == open) → Configurable handling (Split 50/50, Ignore, All to Buy, or All to Sell)
Key Features:
Supports two display modes: Bars (柱状图) or Line (折线图)
Ratio > 1 shown in orange (strong buy pressure), Ratio < 1 shown in teal (strong sell pressure)
Built-in reference lines: 1:1 Equilibrium, Strong Buy (>1.5), Strong Sell (<0.67)
Optional debug label on the last bar showing current ratio value + raw buy/sell cumulative volumes
Inputs:
Lookback Period n: Number of bars for rolling cumulative calculation (default: 20)
Flat Bar Volume Handling: How to treat doji/flat bars (default: Split 50/50)
Display Ratio as Bars: true = Bars style, false = Line style
Show Current Ratio Value Label: Toggle debug label on last bar
Usage Tips:
Ratio > 1 indicates dominant buy pressure in recent volume → potential bullish momentum
Ratio < 1 indicates dominant sell pressure → potential bearish pressure
Best used in conjunction with price chart to spot divergences or confirmations
Performs best on stocks/instruments with active volume
累计成交量比率(Cumulative Volume Ratio)
本指标专门计算并显示过去 n 根 K 线的累计买入成交量与卖出成交量的比率(Ratio = 累计买入量 / 累计卖出量)。
根据 K 线价格走势对成交量进行拆分:
阳线(收盘 > 开盘)→ 全部成交量计入买入
阴线(收盘 < 开盘)→ 全部成交量计入卖出
平盘(收盘 = 开盘)→ 支持多种处理方式(50/50 平分、忽略、全部计买入、全部计卖出)
核心功能:
支持柱状图(Bars)或折线图(Line)两种显示方式
比率 > 1 时显示橙色(买方强势),比率 < 1 时显示青色(卖方强势)
内置关键参考线:1:1 均衡线、买方强势 (>1.5)、卖方强势 (<0.67)
可选在最后一根 K 线上显示调试标签,实时显示当前比率值及累计买/卖量数值
参数说明:
回看周期 n:累计计算的 K 线根数(默认 20)
平盘处理:如何处理收盘=开盘的 K 线(默认 50/50 平分)
比率显示为柱状图:开启为柱状图,关闭为折线图
显示当前比率数值标签:是否显示最后一根 K 线的数值标签(调试用)
使用建议:
比率 > 1 表示近期买入力量占优,适合关注潜在上涨动能
比率 < 1 表示卖出力量占优,可作为短线压力参考
建议与价格主图结合使用,观察比率与价格走势的背离或确认信号
在成交量活跃的个股上效果更明显
Description:
This dedicated indicator calculates and displays the ratio of cumulative buy volume to cumulative sell volume over the past n bars (Ratio = Cumulative Buy Volume / Cumulative Sell Volume).
Volume is split based on price movement:
Up bars (close > open) → All volume assigned to Buy
Down bars (close < open) → All volume assigned to Sell
Flat bars (close == open) → Configurable handling (Split 50/50, Ignore, All to Buy, or All to Sell)
Key Features:
Supports two display modes: Bars (柱状图) or Line (折线图)
Ratio > 1 shown in orange (strong buy pressure), Ratio < 1 shown in teal (strong sell pressure)
Built-in reference lines: 1:1 Equilibrium, Strong Buy (>1.5), Strong Sell (<0.67)
Optional debug label on the last bar showing current ratio value + raw buy/sell cumulative volumes
Inputs:
Lookback Period n: Number of bars for rolling cumulative calculation (default: 20)
Flat Bar Volume Handling: How to treat doji/flat bars (default: Split 50/50)
Display Ratio as Bars: true = Bars style, false = Line style
Show Current Ratio Value Label: Toggle debug label on last bar
Usage Tips:
Ratio > 1 indicates dominant buy pressure in recent volume → potential bullish momentum
Ratio < 1 indicates dominant sell pressure → potential bearish pressure
Best used in conjunction with price chart to spot divergences or confirmations
Performs best on stocks/instruments with active volume
累计成交量比率(Cumulative Volume Ratio)
本指标专门计算并显示过去 n 根 K 线的累计买入成交量与卖出成交量的比率(Ratio = 累计买入量 / 累计卖出量)。
根据 K 线价格走势对成交量进行拆分:
阳线(收盘 > 开盘)→ 全部成交量计入买入
阴线(收盘 < 开盘)→ 全部成交量计入卖出
平盘(收盘 = 开盘)→ 支持多种处理方式(50/50 平分、忽略、全部计买入、全部计卖出)
核心功能:
支持柱状图(Bars)或折线图(Line)两种显示方式
比率 > 1 时显示橙色(买方强势),比率 < 1 时显示青色(卖方强势)
内置关键参考线:1:1 均衡线、买方强势 (>1.5)、卖方强势 (<0.67)
可选在最后一根 K 线上显示调试标签,实时显示当前比率值及累计买/卖量数值
参数说明:
回看周期 n:累计计算的 K 线根数(默认 20)
平盘处理:如何处理收盘=开盘的 K 线(默认 50/50 平分)
比率显示为柱状图:开启为柱状图,关闭为折线图
显示当前比率数值标签:是否显示最后一根 K 线的数值标签(调试用)
使用建议:
比率 > 1 表示近期买入力量占优,适合关注潜在上涨动能
比率 < 1 表示卖出力量占优,可作为短线压力参考
建议与价格主图结合使用,观察比率与价格走势的背离或确认信号
在成交量活跃的个股上效果更明显
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.