Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add price volume trend indicator #45

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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