OPEN-SOURCE SCRIPT

Volume and Volatility Ratio Indicator-WODI

172
策略名称
交易量与波动率比例策略-WODI


一、用户自定义参数

vol_length:交易量均线长度,计算基础交易量活跃度。

index_short_length / index_long_length:指数短期与长期均线长度,用于捕捉中短期与中长期趋势。

index_magnification:敏感度放大倍数,调整指数均线的灵敏度。

index_threshold_magnification:阈值放大因子,用于动态过滤噪音。

lookback_bars:形态检测回溯K线根数,用于捕捉反转模式。

fib_tp_ratio / fib_sl_ratio:斐波那契止盈与止损比率,分别对应黄金分割(0.618/0.382 等)级别。

enable_reversal:反转信号开关,开启后将原有做空信号反向为做多信号,用于单边趋势加仓。

二、核心计算逻辑

交易量百分比

使用 ta.sma 计算 vol_ma,并得到 vol_percent = volume / vol_ma * 100。

价格波动率

volatility = (high – low) / close * 100。

构建复合指数

volatility_index = vol_percent * volatility,并分别计算其短期与长期均线(乘以 index_magnification)。

动态阈值

index_threshold = index_long_ma * index_threshold_magnification,过滤常规波动。

三、信号生成与策略执行

做多/做空信号

当短期指数均线自下而上突破长期均线,且 volatility_index 突破 index_threshold 时,发出做多信号。

当短期指数均线自上而下跌破长期均线,且 volatility_index 跌破 index_threshold 时,发出做空信号。

反转信号模式(可选)

若 enable_reversal = true,则所有做空信号反向为做多,用于在强趋势行情中加仓。

止盈止损管理

进场后自动设置斐波那契止盈位(基于入场价 × fib_tp_ratio)和止损位(入场价 × fib_sl_ratio)。

支持多级止盈:可依次以 0.382、0.618 等黄金分割比率分批平仓。

四、图表展示

策略信号标记:图上用箭头标明每次做多/做空(或反转加仓)信号。

斐波那契区间:在K线图中显示止盈/止损水平线。

复合指数与阈值线:与原版相同,在独立窗口绘制短、长期指数均线、指数曲线及阈值。

量能柱状:高于均线时染色,反转模式时额外高亮。

Strategy Name
Volume and Volatility Ratio Strategy – WODI


1. User-Defined Parameters

vol_length: Length for volume SMA.

index_short_length / index_long_length: Short and long MA lengths for the composite index.

index_magnification: Sensitivity multiplier for index MAs.

index_threshold_magnification: Threshold multiplier to filter noise.

lookback_bars: Number of bars to look back for pattern detection.

fib_tp_ratio / fib_sl_ratio: Fibonacci take-profit and stop-loss ratios (e.g. 0.618, 0.382).

enable_reversal: Toggle for reversal mode; flips short signals to long for trend-following add-on entries.

2. Core Calculation

Volume Percentage:

vol_ma = ta.sma(volume, vol_length)

vol_percent = volume / vol_ma * 100

Volatility:

volatility = (high – low) / close * 100

Composite Index:

volatility_index = vol_percent * volatility

Short/long MAs applied and scaled by index_magnification.

Dynamic Threshold:

index_threshold = index_long_ma * index_threshold_magnification.

3. Signal Generation & Execution

Long/Short Entries:

Long when short MA crosses above long MA and volatility_index > index_threshold.

Short when short MA crosses below long MA and volatility_index < index_threshold.

Reversal Mode (optional):

If enable_reversal is on, invert all short entries to long to scale into trending moves.

Fibonacci Take-Profit & Stop-Loss:

Automatically set TP/SL levels at entry price × respective Fibonacci ratios.

Supports multi-stage exits at 0.382, 0.618, etc.

4. Visualization

Signal Arrows: Marks every long/short or reversal-add signal on the chart.

Fibonacci Zones: Plots TP/SL lines on the price panel.

Index & Threshold: Same as v1.0, with MAs, index curve, and threshold in a separate sub-window.

Volume Bars: Colored when above vol_ma; extra highlight if a reversal-add signal triggers

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.