# Volume Profile (VPVR)

> View-adaptive price-by-volume histogram with Point of Control (POC), Value Area (VAH/VAL), HVN/LVN nodes, and buy/sell skew.

Canonical page: [https://docs.kami.trade/studies/vpvr/](https://docs.kami.trade/studies/vpvr/)

`vpvr` builds a horizontal volume-at-price histogram across the active visible chart range, computing Point of Control (`POC`), Value Area High (`VAH`), Value Area Low (`VAL`), High-Volume Nodes (`HVN`), Low-Volume Nodes (`LVN`), and buy/sell volume skew.

> **Always view-adaptive by default.** Unlike the other 14 studies, `vpvr` belongs to `VIEW_ADAPTIVE` — it recalculates over the visible viewport even when chart scope is set to `Fixed`. Pass an explicit numeric `window` parameter if you want to pin `vpvr` to a fixed trailing bar count.

## Parameters

| Parameter | Default | Range | Type | Timeframe overrides |
| --- | --- | --- | --- | --- |
| `window` | `500` | `60..2000` | integer | Ignored in `view` mode unless explicitly passed |
| `bins` | `48` | `12..120` | integer | — |
| `valueAreaPct` | `70` | `50..90` | number (%) | — |

## Algorithm & Nuances

1. **Proportional candle distribution (`vpvrScan`)**: Divides `[minL, maxH]` across `bins` equal-width buckets (`step = (maxH - minL) / bins`). Each candle's volume is allocated proportionally across every price bucket overlapped by `[l[i], h[i]]`.
2. **Buy/sell split**: Approximates per-candle buyer aggression via `buyShare = clamp((c - l) / (h - l), 0, 1)` (`0.5` when `h <= l`), splitting each bucket's volume into buy and sell stacks.
3. **Point of Control (`POC`)**: Selects the highest-volume bucket. Ties break toward the center bucket `(bins - 1) / 2`, then the lower price bucket.
4. **Market Profile Value Area (`VAH` / `VAL`)**: Expands outward from `POC` using standard 2-bin lookahead — comparing the combined volume of the next 2 buckets above `(up1 + up2)` against the next 2 buckets below `(dn1 + dn2)` — stepping into the heavier side until cumulative volume reaches `totalVol * (valueAreaPct / 100)`.
5. **High- & Low-Volume Nodes**:
   - **HVNs**: Up to `3` local volume peaks (`idx !== pocIdx`) with volume `>= 0.65 * pocVol`, ranked by volume.
   - **LVNs**: Up to `3` local volume valleys strictly inside `[valIdx, vahIdx]` with volume `<= 0.35 * pocVol`, ranked lowest first.
6. **Skew & position**: Computes `skew = r2((totalBuy / totalVol) * 2 - 1)` in `[-1, 1]` and classifies `lastClose` as `'above_va'`, `'inside_va'`, or `'below_va'`.

## Drawings & Facts

- **Drawings**: `1` `profile` overlay anchored to the right edge (`clamp(width * 0.22, 48, 180)` px wide) showing split buy/sell histogram bars, shaded Value Area, solid `POC` line, dashed `VAH`/`VAL` lines, and right-edge price tags.
- **Facts (`VpvrFacts`)**: `lastClose`, `poc`, `vah`, `val`, `position`, `vaWidthAtr`, `hvns[]`, `lvns[]`, `skew`, and `bins`.

## Activation

- **Studies menu**: `Volume profile: POC and value area` (`VPVR`)
- **Slash command**: `/vpvr`
- **Chat phrases**: `vpvr`, `profile`, `poc`, `vah`, `val`, `vp`
