RicardoSantos

[RS]Trade Volume Index V0

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

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.

Want to use this script on a chart?
//@version=2
study(title='[RS]Trade Volume Index V0', overlay=false)
smooth = input(title='Signal Smoothness, (<0 to hide):', type=integer, defval=4)
f_tvi()=>
    _min_tick = syminfo.mintick
    _price_change = close-open // can be change(close) if want to include gaps
    _direction = _price_change > _min_tick ? 1 : _price_change < -_min_tick ? -1 : _direction[1] //1=accumulation, -1=distribution
    _return_tvi = na(_return_tvi[1]) ? volume : _direction > 0 ? _return_tvi[1] + volume : _direction < 0 ? _return_tvi[1] - volume : _return_tvi[1]

plot(title='TVI', series=f_tvi(), color=black)
plot(title='Signal', series=smooth <= 0 ? na : sma(f_tvi(), smooth), color=red)
hline(title='0', price=0, color=black)