techan
techan copied to clipboard
add price volume trend indicator
Reference: https://www.investopedia.com/terms/v/vptindicator.asp
Formula Used:
-
For second candle:
[((CurrentClose - PreviousClose) / PreviousClose) x Volume] + 0 (because there is no PVT to first candle) -
For subsequent candles:
[((CurrentClose - PreviousClose) / PreviousClose) x Volume] + PreviousPVT
Usage:
closePrices := techan.NewClosePriceIndicator(series)
volume := techan.NewVolumeIndicator(series)
pvtIndicator := techan.NewPriceVolumeTrendIndicator(closePrices, volume, 1)
fmt.Println("PVT - ", pvtIndicator.Calculate(n)
pvtSignalIndicator := techan.NewPVTAndSignalIndicator(pvtIndicator, techan.NewEMAIndicator(pvtIndicator, 21))
fmt.Println("PVT - Signal - ", pvtSignalIndicator.Calculate(n)
Where n is the index. It should be size of the series.
Signed-off-by: Santosh Pillai [email protected]
Thanks @sp98! Will take a look at this ASAP