LazyBear

Indicator: Postivie / Negative Volume Indices

516
More info at www.investopedia.com/terms/p/pvi.asp

I have included both NVI and PVI. Enjoy :)

List of my free indicators: bit.ly/1LQaPK8
List of my indicators at Appstore: blog.tradingview.com/?p=970
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?
//
// @author LazyBear
// @credits http://www.investopedia.com/terms/p/pvi.asp
// Calculation of the PVI depends on how current volume compares with the previous 
// day's trading volume. If current volume is greater than the previous day's volume, 
// PVI = Previous PVI + {[(Today's Closing Price-Yesterday's Closing Price)/Yesterday's Closing Price)] 
//   x 
// Previous PVI}. If current volume is lower than the previous day's volume, PVI is unchanged.
// 
study(title = "Positive Volume Index [LazyBear]", shorttitle="PVI_LB")

length=input(365)
showEMA=input(true, title="Show EMA?", type=bool)
START_VALUE=100
pvi=(volume > volume[1]) ? nz(pvi[1]) + ((close - close[1])/close[1]) * (na(pvi[1]) ? pvi[1] : START_VALUE) : nz(pvi[1])
hline(0)
plot(pvi)
plot(showEMA ? ema(pvi, length) : na, color=orange, linewidth=2)