techan icon indicating copy to clipboard operation
techan copied to clipboard

add price volume trend indicator

Open sp98 opened this issue 4 years ago • 1 comments

Reference: https://www.investopedia.com/terms/v/vptindicator.asp

Formula Used:

  1. For second candle: [((CurrentClose - PreviousClose) / PreviousClose) x Volume] + 0 (because there is no PVT to first candle)

  2. 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]

sp98 avatar Sep 19 '21 14:09 sp98

Thanks @sp98! Will take a look at this ASAP

sdcoffey avatar Sep 23 '21 18:09 sdcoffey