liw0

Time Segmented Volume

Time Segmented Volume
an indicator I was asked to port by sunnyd76

CREDITS: quant.stackexchange....ime-segmented-volume

If you like it I would also be happy about a small donation
BTC 1GyfGTBsVHMbPovFGFeipe7b7ET1aebGx5

Questions or Comments? Just send me a PM!

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?
//      Written by liw0 active on https://www.tradingview.com/u/liw0
 
//      If you decide to use my script in your published charts,
//      please keep this header as it is now and leave the name unchanged!
//      It would make me happy to see my script put to use in other charts :)
 
//      If you like it I would also be happy about a small donation
//      BTC 1GyfGTBsVHMbPovFGFeipe7b7ET1aebGx5
 
//      Questions or Comments? Just send me a PM!

//      CREDITS: http://quant.stackexchange.com/questions/2816/how-to-calculate-time-segmented-volume

study("Time Segmented Volume")

l  = input(13, title="Length")
l_ma = input(7, title="MA Length")

t = sum(close>close[1]?volume*close-close[1]:close<close[1]?(volume*-1)*close-close:0,l)
m = sma(t ,l_ma )

plot(t, color=red, style=histogram)
plot(m, color=green)