Data Sources
Volume Delta
Volume delta OHLC candles.
Legacy Scripting v2
These docs remain available while the v2 engine is supported. For new scripts, use Scripting v3.
data.VD exposes volume delta candles where each bar tracks buy - sell.
data.VD supports aggregated exchange strings and trade-size buckets.
const vd = subscribe(data.VD, { bucket: 1 })Functions
vd.open(offset?) -> number
vd.high(offset?) -> number
vd.low(offset?) -> number
vd.close(offset?) -> number
vd.unix(offset?) -> number
vd.bucket() -> number
vd.bucketInfo() -> { id: number, label: string, minValue: number, maxValue: number }offset?: optional bar offset on the VD subscription clock
Bucket Selection
Use options.bucket or options.bucketGroup with subscribe(...) to choose the stored VD bucket.
const vdAll = subscribe(data.VD, { bucket: 1 })
const vdWhales = subscribe(data.VD, { bucket: 10 })bucket() returns the active bucket id for the subscription.
bucketInfo() returns metadata for the selected bucket:
| Bucket | Label | Range |
|---|---|---|
1 | all | all trades |
2 | 1-1K | 1 to 1,000 |
3 | 1K-10K | 1,000 to 10,000 |
4 | 10K-25K | 10,000 to 25,000 |
5 | 25K-50K | 25,000 to 50,000 |
6 | 50K-100K | 50,000 to 100,000 |
7 | 100K-250K | 100,000 to 250,000 |
8 | 250K-500K | 250,000 to 500,000 |
9 | 500K-1M | 500,000 to 1,000,000 |
10 | 1M-5M | 1,000,000 to 5,000,000 |
11 | 5M+ | 5,000,000+ |
Example
//@version=2
indicator("Volume Delta", false)
const vd = subscribe(data.VD, {
exchange: agg("bybitf", "binancef"),
bucket: 3
})
function onBar(index) {
const value = vd.close()
plotHistogram("VD", value, {
color: value >= 0 ? color.teal : color.orange
})
}