Volume Price Trend
Install and import
npm install fintech-algorithmsimport { volume_price_trend } from "fintech-algorithms/technical-indicators/volume-indicators/volume-price-trend";Signature
volume_price_trend(close, volume, initial)Like OBV, but each bar contributes volume scaled by the size of the return rather than only its sign — so a 3% move counts for more than a 0.1% one.
Parameters
| Name | Type | Notes |
|---|---|---|
close | number[] | Per-bar closing prices, chronological. |
volume | number[] | Per-bar traded volume, aligned index-for-index with the price series. |
initial | number | Starting value of the running total. optional |
Returns
Record<string, (number | null)[]> · length same-as-input
Parallel series: price_return, volume, volume_contribution and vpt.
Warm-up
The first 1 positions are null. The first bar has no prior close, so no return.
Errors
- When the input series are not all the same length — throws RangeError
Complexity: time O(n),
space O(n).
Worked example
executed Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.
Input
[100.28, 100.686113, 101.200346, 101.789282, 102.408843, 103.010585]Showing 6 of 120 elements.
[990000, 1066468.036, 1130033.236, 1170141.961, 1180511.26, 1160272.794]Showing 6 of 120 elements.
Call
volume_price_trend(close, volume, initial)Returns
object with 4 fields: price_return, volume, volume_contribution, vpt
{
"price_return": [
0,
0.004049790586358245,
0.005107288231496136,
0.005819505794970345,
0.006086701741348411,
0.005875879292963026
],
"volume": [990000, 1066468.036, 1130033.236, 1170141.961, 1180511.26, 1160272.794],
"volume_contribution": [
0,
4318.972212844767,
5771.405447422296,
6809.647922977462,
7185.419941923407,
6817.622884452954
],
"vpt": [
0,
4318.972212844767,
10090.377660267062,
16900.025583244525,
24085.445525167932,
30903.068409620886
]
}Other exports
This module also exports
obv, accumulation_distribution_line, chaikin_money_flow, money_flow_index, force_index. Every module additionally exports run as an alias of its
primary function, and a meta object carrying its catalog id, domain, family,
shape and article URL.
Diagrams
How it works
This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.
References
- Price Volume Trend (PVT) — TradingView
- On Balance Volume (OBV) — TradingView
- Volume — TradingView
- Consolidated Tape — U.S. Securities and Exchange Commission, Investor.gov
- Closing Price — U.S. Securities and Exchange Commission, Investor.gov
- What is Volume? — CME Group
- Claim-role ledger
- Evidence boundary
- Enhanced claim-to-source map
- Public evidence boundary