OPEN-SOURCE SCRIPT
Volume and Volatility Ratio Indicator-WODI

该指标名为“交易量与波动率比例指标-WODI”,主要基于交易量和价格波动率构造一个复合指数,帮助识别市场内可能存在的异常或转折信号。具体实现如下:
用户自定义参数
用户可以设置交易量均线长度(vol_length)、指数的短期与长期均线长度(index_short_length、index_long_length)、均线敏感度(index_magnification)、阈值放大因子(index_threshold_magnification)以及检测K线形态的区间(lookback_bars)。这些参数为后续计算提供了灵活性,允许用户根据不同市场环境自定义指标的敏感度和响应速度。
交易量均线与百分比计算
首先通过 ta.sma 计算指定长度的交易量简单均线(vol_ma)。
接下来,将当前交易量与均线进行比较,计算出当前交易量占均线的百分比(vol_percent),这反映了短期内交易量的相对活跃程度。
波动率的衡量
使用当前K线的最高价和最低价计算振幅,再除以收盘价乘以100得到波动率(volatility),从而反映市场价格波动的幅度。
构建交易量/波动率指数
将交易量百分比与波动率相乘,形成了“交易量/波动率指数”(volatility_index)。该指数能够同时反映市场的交易活跃度和价格波动性,两者的联合作用帮助捕捉市场的“热度”。
计算指标均线与阈值
对交易量/波动率指数分别计算短期均线(index_short_ma)和长期均线(index_long_ma),并通过乘以一个敏感度参数(index_magnification)进行调整。
同时,依据长期均线计算一个阈值(index_threshold),起到过滤噪音的作用。当指数突破该阈值时,可能预示着市场的重要变化。
K线形态与反转模式检测
通过遍历最近几根K线(由lookback_bars控制),指标会检测是否符合一系列预定条件(涉及交易量、价格振幅、K线形态等),以判断是否存在反转模式。若符合条件,则标记为反转模式,从而为潜在的转折点提供提示。
图表展示
最终在独立窗口中绘制多个元素:
指数短均线与长均线:经过敏感度调整后显示,用于分析指数趋势。
交易量/波动率指数:采用阶梯线风格绘制,直观展示指数变化。
阈值线:作为参考水平,便于判断指数是否突破常规范围。
交易量柱状图:当当前交易量高于均线时,通过不同颜色显示;当检测到反转模式时,颜色会进一步强化,帮助用户迅速识别潜在信号。
English Description
This indicator, titled “Volume and Volatility Ratio Indicator - WODI”, is designed to construct a composite index based on trading volume and price volatility, aiding in the identification of abnormal market conditions or potential reversal signals. Its functionality is broken down as follows:
User-Defined Parameters
The indicator allows users to set parameters such as the moving average length for volume (vol_length), the short and long moving average lengths for the index (index_short_length and index_long_length), a sensitivity multiplier (index_magnification), a threshold magnification factor (index_threshold_magnification), and the number of bars for pattern detection (lookback_bars). These parameters provide flexibility to adjust the sensitivity and responsiveness of the indicator based on different market conditions.
Volume Moving Average and Percentage Calculation
A simple moving average (SMA) of volume is computed over the specified length (vol_ma) using the ta.sma function.
The current volume is then compared to its moving average to calculate the volume percentage (vol_percent), reflecting the relative trading intensity in the short term.
Measuring Volatility
Volatility is calculated based on the current bar’s high and low prices, normalized by the closing price and multiplied by 100, which provides a measure of the market’s price fluctuation magnitude.
Constructing the Volume/Volatility Index
The index (volatility_index) is derived by multiplying the volume percentage by the calculated volatility. This composite metric reflects both market activity and price movement, effectively capturing the overall “heat” of the market.
Calculating the Index Moving Averages and Threshold
Two moving averages for the volatility_index are computed: one short-term (index_short_ma) and one long-term (index_long_ma). These are then adjusted by the sensitivity multiplier (index_magnification).
A threshold level (index_threshold) is calculated based on the long-term moving average multiplied by the threshold magnification factor, serving to filter out market noise. When the index exceeds this threshold, it may signal significant market shifts.
Detection of Reversal Patterns
The indicator iterates through the recent bars (as determined by lookback_bars) to check whether a set of predetermined conditions (involving trends in the volatility_index, volume comparisons, price closes, and K-line patterns) are met. If these conditions are satisfied, it flags a reversal pattern, which may serve as a warning for a potential market turnaround.
Visualization on the Chart
The final display includes several elements plotted in a separate indicator window:
The short-term and long-term moving averages of the index (after sensitivity adjustment) which help visualize the trend of the composite index.
The volatility index itself is drawn using a step-line style for clarity.
A threshold line is plotted to provide a reference level against which index movements can be compared.
A volume histogram is also displayed, where bars are colored differently when the current volume exceeds the moving average; the color is further enhanced if a reversal pattern is detected, making it easy for users to quickly spot potential signals.
用户自定义参数
用户可以设置交易量均线长度(vol_length)、指数的短期与长期均线长度(index_short_length、index_long_length)、均线敏感度(index_magnification)、阈值放大因子(index_threshold_magnification)以及检测K线形态的区间(lookback_bars)。这些参数为后续计算提供了灵活性,允许用户根据不同市场环境自定义指标的敏感度和响应速度。
交易量均线与百分比计算
首先通过 ta.sma 计算指定长度的交易量简单均线(vol_ma)。
接下来,将当前交易量与均线进行比较,计算出当前交易量占均线的百分比(vol_percent),这反映了短期内交易量的相对活跃程度。
波动率的衡量
使用当前K线的最高价和最低价计算振幅,再除以收盘价乘以100得到波动率(volatility),从而反映市场价格波动的幅度。
构建交易量/波动率指数
将交易量百分比与波动率相乘,形成了“交易量/波动率指数”(volatility_index)。该指数能够同时反映市场的交易活跃度和价格波动性,两者的联合作用帮助捕捉市场的“热度”。
计算指标均线与阈值
对交易量/波动率指数分别计算短期均线(index_short_ma)和长期均线(index_long_ma),并通过乘以一个敏感度参数(index_magnification)进行调整。
同时,依据长期均线计算一个阈值(index_threshold),起到过滤噪音的作用。当指数突破该阈值时,可能预示着市场的重要变化。
K线形态与反转模式检测
通过遍历最近几根K线(由lookback_bars控制),指标会检测是否符合一系列预定条件(涉及交易量、价格振幅、K线形态等),以判断是否存在反转模式。若符合条件,则标记为反转模式,从而为潜在的转折点提供提示。
图表展示
最终在独立窗口中绘制多个元素:
指数短均线与长均线:经过敏感度调整后显示,用于分析指数趋势。
交易量/波动率指数:采用阶梯线风格绘制,直观展示指数变化。
阈值线:作为参考水平,便于判断指数是否突破常规范围。
交易量柱状图:当当前交易量高于均线时,通过不同颜色显示;当检测到反转模式时,颜色会进一步强化,帮助用户迅速识别潜在信号。
English Description
This indicator, titled “Volume and Volatility Ratio Indicator - WODI”, is designed to construct a composite index based on trading volume and price volatility, aiding in the identification of abnormal market conditions or potential reversal signals. Its functionality is broken down as follows:
User-Defined Parameters
The indicator allows users to set parameters such as the moving average length for volume (vol_length), the short and long moving average lengths for the index (index_short_length and index_long_length), a sensitivity multiplier (index_magnification), a threshold magnification factor (index_threshold_magnification), and the number of bars for pattern detection (lookback_bars). These parameters provide flexibility to adjust the sensitivity and responsiveness of the indicator based on different market conditions.
Volume Moving Average and Percentage Calculation
A simple moving average (SMA) of volume is computed over the specified length (vol_ma) using the ta.sma function.
The current volume is then compared to its moving average to calculate the volume percentage (vol_percent), reflecting the relative trading intensity in the short term.
Measuring Volatility
Volatility is calculated based on the current bar’s high and low prices, normalized by the closing price and multiplied by 100, which provides a measure of the market’s price fluctuation magnitude.
Constructing the Volume/Volatility Index
The index (volatility_index) is derived by multiplying the volume percentage by the calculated volatility. This composite metric reflects both market activity and price movement, effectively capturing the overall “heat” of the market.
Calculating the Index Moving Averages and Threshold
Two moving averages for the volatility_index are computed: one short-term (index_short_ma) and one long-term (index_long_ma). These are then adjusted by the sensitivity multiplier (index_magnification).
A threshold level (index_threshold) is calculated based on the long-term moving average multiplied by the threshold magnification factor, serving to filter out market noise. When the index exceeds this threshold, it may signal significant market shifts.
Detection of Reversal Patterns
The indicator iterates through the recent bars (as determined by lookback_bars) to check whether a set of predetermined conditions (involving trends in the volatility_index, volume comparisons, price closes, and K-line patterns) are met. If these conditions are satisfied, it flags a reversal pattern, which may serve as a warning for a potential market turnaround.
Visualization on the Chart
The final display includes several elements plotted in a separate indicator window:
The short-term and long-term moving averages of the index (after sensitivity adjustment) which help visualize the trend of the composite index.
The volatility index itself is drawn using a step-line style for clarity.
A threshold line is plotted to provide a reference level against which index movements can be compared.
A volume histogram is also displayed, where bars are colored differently when the current volume exceeds the moving average; the color is further enhanced if a reversal pattern is detected, making it easy for users to quickly spot potential signals.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
For quick access on a chart, add this script to your favorites — learn more here.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
For quick access on a chart, add this script to your favorites — learn more here.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.