Skip to content

add price volume trend indicator#45

Open
sp98 wants to merge 1 commit intosdcoffey:mainfrom
sp98:price-volume-trend-indicator
Open

add price volume trend indicator#45
sp98 wants to merge 1 commit intosdcoffey:mainfrom
sp98:price-volume-trend-indicator

Conversation

@sp98
Copy link

@sp98 sp98 commented Sep 19, 2021

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 sapillai@redhat.com

Signed-off-by: Santosh Pillai <sapillai@redhat.com>
@sdcoffey
Copy link
Owner

Thanks @sp98! Will take a look at this ASAP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants