Volume at price
The recorded volume traded at each price of a day, a week or a month in a script, with the point of control, the value area and the profile itself.
ChartDeck records every trade of the markets it follows, by price, with buys and sells apart. A script reads that record with the vap functions: the volume at price of a day, a week or a month. This is the traded volume itself. It is not a candle's volume spread evenly over its range, which is what a script can build from bars alone and which puts the point of control and the value area in the wrong place on a busy day.
The full volume at price comes with Plus, Pro and Elite. Every plan, Beginner included, gets the levels of a finished day: vap.poc("D", 1), vap.vah("D", 1) and vap.val("D", 1) (and further back, back of 1 or more). On Beginner the developing day, weeks, months, vap.profile() and vap.volume() read na; the script still compiles and runs.
#Where the volume comes from
The volume is Binance Futures for every market Binance lists, whatever exchange the chart shows, because it has the most volume. A market Binance does not list reads all recorded exchanges together. A market that is not recorded reads na, and the legend names it. vap.source() says which one the script got.
Periods are in UTC: a day, a week from Monday, a calendar month.
#The levels of a finished period
//@chartscript 1
indicator("Previous day value area", { overlay: true })
plot(vap.poc("D", 1), "pdPOC", { color: color.orange })
plot(vap.vah("D", 1), "pdVAH", { color: color.gray })
plot(vap.val("D", 1), "pdVAL", { color: color.gray })| Function | Gives |
|---|---|
vap.poc(period, back) | the point of control: the middle of the price row with the most volume |
vap.vah(period, back, percent) | the top edge of the value area |
vap.val(period, back, percent) | the bottom edge of the value area |
vap.volume(period, back, side) | the period's volume in base coin: all of it, or only "buy" or "sell" |
period is "D", "W" or "M". back counts periods from the one the bar is in: 1 is the last finished period, 2 the one before. So on a bar from Tuesday, vap.poc("D", 1) is Monday's point of control, and on a bar from Wednesday it is Tuesday's: the value never uses a day that had not finished at that bar.
The value area starts at the point of control and grows two rows at a time: it compares the next two rows above with the next two below and adds the larger pair (a single row where only one is left; on a tie only one side: the one whose nearer row is larger, the upper when those are equal too), until it holds percent of the period's volume. The default is 70. This is the standard rule, and the chart's own profiles use it too.
#The profile itself
vap.profile(period, back, side) returns the rows as a heatmap.column, so a script can apply its own rules: another value-area method, low-volume nodes, the buy and sell split of each row.
| Field | Meaning |
|---|---|
time, span | the period's start and its length (ms) |
bottom | the lower edge of the lowest row |
step | the height of one row, in price |
values | the volume of each row from the bottom up, in base coin |
max | the largest row |
Row i covers the prices from bottom + i * step up to bottom + (i + 1) * step. Every profile a script reads on one chart has the same step (vap.step()), and a profile has at most 2,000 rows.
//@chartscript 1
indicator("Previous day low-volume node", { overlay: true })
const p = vap.profile("D", 1)
let thin: float = na
if (!na(p)) {
let least = p.max
for (let i = 1; i < p.values.size() - 1; i++) {
const v = p.values.get(i)
if (v > 0 && v < least) {
least = v
thin = p.bottom + (i + 0.5) * p.step
}
}
}
plot(thin, "Thinnest row")Reading the rows costs loop steps like any other loop. Read a profile once per period (for example when vap.poc("D", 1) changes) and keep what you need in state variables.
#The developing period
back = 0 is the period the bar is in, up to that bar's close: vap.poc("D", 0) is the developing point of control.
- For the last 7 days the developing profile is exact in 15-minute steps, and the newest bar is up to the minute.
- Further back, only whole finished days are known. The developing week and month there step once a day, and the developing day is
nauntil its last bar.
#How far back
Daily, weekly and monthly profiles are kept from the day ChartDeck began recording the market (vap.since()). A period that began before the recording did is left out: a partial profile would look like a whole one. Before that, the functions read na.
vap reads the chart's own market, so it is na inside a request expression. Read it outside the request.