C4 — Volume Profile. Bin the volume of every candle in view across the
price range [priceMin, priceMax], split into bins equal-width intervals.
Distribution model: each candle's volume is spread over the bins its
[low, high] range overlaps, proportionally to the overlap length — a
candle spanning three bins evenly contributes a third of its volume to each;
one whose range covers only the top half of a bin contributes only that
fraction. A candle with low == high (or whose range collapses to a point
after clamping) drops its whole volume into the single bin containing that
price. Volume of candles entirely outside [priceMin, priceMax] is clamped
to the nearest edge bin (so an off-range bar still counts toward
totalVolume rather than silently vanishing).
pocIndex is the highest-volume bin. The value area is the smallest set
of contiguous bins around the POC whose summed volume reaches
valueAreaPct (default 0.70) of totalVolume, grown one bin at a time
toward whichever adjacent side holds more volume — the standard
market-profile expansion. Its price extent is returned as
valueAreaLow/valueAreaHigh.
NaN-safe: candles with a non-finite low, high, or volume, or
non-positive volume, are skipped. A degenerate request (bins < 1, a
non-finite or inverted price range) yields a single empty bin spanning the
(repaired) range with pocIndex = -1. Pure; allocates only the result.
C4 — Volume Profile. Bin the volume of every candle in
viewacross the price range[priceMin, priceMax], split intobinsequal-width intervals.Distribution model: each candle's volume is spread over the bins its
[low, high]range overlaps, proportionally to the overlap length — a candle spanning three bins evenly contributes a third of its volume to each; one whose range covers only the top half of a bin contributes only that fraction. A candle withlow == high(or whose range collapses to a point after clamping) drops its whole volume into the single bin containing that price. Volume of candles entirely outside[priceMin, priceMax]is clamped to the nearest edge bin (so an off-range bar still counts towardtotalVolumerather than silently vanishing).pocIndexis the highest-volume bin. The value area is the smallest set of contiguous bins around the POC whose summed volume reachesvalueAreaPct(default 0.70) oftotalVolume, grown one bin at a time toward whichever adjacent side holds more volume — the standard market-profile expansion. Its price extent is returned asvalueAreaLow/valueAreaHigh.NaN-safe: candles with a non-finite
low,high, orvolume, or non-positive volume, are skipped. A degenerate request (bins < 1, a non-finite or inverted price range) yields a single empty bin spanning the (repaired) range withpocIndex = -1. Pure; allocates only the result.