OPEN-SOURCE SCRIPT

自己

80
//version=5
indicator("CVD + Delta + OBV + A/D Signals", overlay=true)

// 1. Volume Profile 设置
profileRange = input.timeframe("D", "Volume Profile 周期")
vp = request.security(syminfo.tickerid, profileRange, volume)

// 2. 计算 Delta Volume
delta = volume * (close > open ? 1 : close < open ? -1 : 0)
cumDelta = ta.cum(delta)

// 3. 计算 CVD(累计成交量差)
buyVol = volume * (close > open ? 1 : 0)
sellVol = volume * (close < open ? 1 : 0)
cvd = ta.cum(buyVol - sellVol)

// 4. OBV 和 A/D 线
obv = ta.obv
ad = ta.accdist

// 5. 绘制信号
buySignal = ta.crossover(cvd, cumDelta) and close > ta.valuewhen(ta.highest(vp, 1), close, 0)
sellSignal = ta.crossunder(cvd, cumDelta) and close < ta.valuewhen(ta.lowest(vp, 1), close, 0)

plotshape(buySignal, style=shape.triangleup, color=color.green, size=size.small)
plotshape(sellSignal, style=shape.triangledown, color=color.red, size=size.small)

// 6. 可视化
plot(cvd, "CVD", color.blue)
plot(cumDelta, "Cumulative Delta", color.orange)
plot(obv, "OBV", color.purple, display=display.data_window)
plot(ad, "A/D Line", color.teal, display=display.data_window)

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.