Volume Profile

All functions · nseries package

VolumeProfileHistogram

func (s Series) VolumeProfileHistogram(h, l, c, v Series, n int, bins ...int) (mins Series, widths Series, hist [][]float64)

VolumeProfileHistogram exposes the per-bin volume histogram for each rolling window of length n. It returns three aligned outputs of length len(c): - mins[i]: the minimum price (window low) for window [i-n+1, i], or 0 for i < n-1 - widths[i]: the bin width for that window (may be 0 for degenerate ranges), or 0 for i < n-1 - hist[i]: the per-bin volumes slice of length k for that window; nil for i < n-1 or invalid inputs

Parameters are identical to the other Volume Profile functions. The optional bins parameter selects the number of bins explicitly (must be >0). When omitted or non-positive, the bin count is instead inferred from each window’s price range and tick granularity, capped at 40; it is not simply a fixed default of 40. Each bar’s volume is allocated to bins using exact interval overlap between the bar’s high-low range and each bin’s boundaries, with no epsilon tolerance at bin edges; a bar with zero range (a point bar) allocates its full volume to the single bin containing its close.

VolumeProfileHVNCount

func (s Series) VolumeProfileHVNCount(h, l, c, v Series, n int, bins ...int) Series

VolumeProfileHVNCount computes, for each rolling window of length n, the number of high-volume bins (HVNs) in the volume profile histogram.

Definition: a bin is considered a high-volume node if its volume is a strict local maximum relative to its immediate neighbours; edge bins are compared to their single neighbour. Tied highs are not counted.

Parameters mirror the other Volume Profile functions. If bins is omitted or <= 0, the number of bins is auto-inferred per window and clamped to 40.

Returns a Series aligned to the input length; entries before the first full window (i < n-1) are zero.

VolumeProfileIsAtHVN

func (s Series) VolumeProfileIsAtHVN(h, l, c, v Series, n int, price Series, bins ...int) Series

VolumeProfileIsAtHVN returns a binary Series indicating whether a provided price Series lies at a High-Volume Node (HVN) for each rolling window of length n. For index i, it builds the volume profile over [i-n+1, i], finds the bin containing price[i], and sets result[i]=1 if that bin is a strict local maximum in the histogram (edge bins compare to their single neighbour). Ties are not counted. Indices i < n-1 yield 0.

If bins is omitted or <= 0, the number of bins is auto-inferred per window (default/clamped to 40). If inputs are invalid or the window is degenerate, the result is 0 at that index. A price[i] strictly outside the window’s actual support (below its low or above its high) also yields 0, rather than being clamped into the nearest bin; a price exactly at the window’s high remains in-support.

VolumeProfileIsAtLVN

func (s Series) VolumeProfileIsAtLVN(h, l, c, v Series, n int, price Series, bins ...int) Series

VolumeProfileIsAtLVN returns a binary Series indicating whether a provided price Series lies at a Low-Volume Node (LVN) for each rolling window of length n. For index i, it builds the volume profile over [i-n+1, i], finds the bin containing price[i], and sets result[i]=1 if that bin is a strict local minimum in the histogram (edge bins compare to their single neighbour). Ties are not counted. Indices i < n-1 yield 0.

If bins is omitted or <= 0, the number of bins is auto-inferred per window (default/clamped to 40). If inputs are invalid or the window is degenerate, the result is 0 at that index. A price[i] strictly outside the window’s actual support (below its low or above its high) also yields 0, rather than being clamped into the nearest bin; a price exactly at the window’s high remains in-support.

VolumeProfilePOC

func (s Series) VolumeProfilePOC(h, l, c, v Series, n int, bins ...int) Series

VolumeProfilePOC computes the rolling Point of Control (price at the highest volume bin) from a Volume Profile built over the last n bars, using H/L/C and distributing each bar’s volume evenly across its price range.

Parameters: - h, l, c, v: High, Low, Close, Volume series (must be the same length) - n: lookback window (number of bars) - bins: optional number of price bins. If omitted or <=0, the bin count is inferred from the window using the smallest non-zero price delta (tick), clamped to a maximum of 40 bins; if the tick cannot be determined, it defaults to 40.

Returns a Series of the same length. For indices < n-1 (insufficient history), the value is 0.

VolumeProfileVAH

func (s Series) VolumeProfileVAH(h, l, c, v Series, n int, valueAreaFraction float64, bins ...int) Series

VolumeProfileVAH computes the rolling Value Area High (upper bound) price that, together with VAL, encloses approximately valueAreaFraction (conventionally 0.70) of the total volume in the profile, expanding outwards from the POC.

valueAreaFraction is a fraction, so 0.70 means 70%. It must be finite and in (0, 1], where 1 gives the whole range: 0, a negative value, NaN, an infinity or a value above 1 (including a percentage such as 70) is invalid and gives all zeros. The warm-up reads 0, not NaN: bars 0 to n-2 are 0, a price level far from any price.

VolumeProfileVAL

func (s Series) VolumeProfileVAL(h, l, c, v Series, n int, valueAreaFraction float64, bins ...int) Series

VolumeProfileVAL computes the rolling Value Area Low (lower bound) price that, together with VAH, encloses approximately valueAreaFraction (conventionally 0.70) of the total volume in the profile, expanding outwards from the POC.

valueAreaFraction is a fraction, so 0.70 means 70%. It must be finite and in (0, 1], where 1 gives the whole range: 0, a negative value, NaN, an infinity or a value above 1 (including a percentage such as 70) is invalid and gives all zeros. The warm-up reads 0, not NaN: bars 0 to n-2 are 0, a price level far from any price.