data reference
Subscriptions to market data and their snapshot queries.
data name = subscribe(data.ohlcv) subscribes to the chart’s own bars; exchange, symbol and timeframe arguments pick another market or period. Period sources (ohlcv, oi, cvd, vd, statistics) drive on handlers; data.book and data.volume are snapshots read from another subscription’s handler.
Sources
data.book
source data.book -> BookSubProvides order-book snapshots to read from another subscription’s handler.
exchange,symbol, andtimeframechoose the market and period. Omit them or use null to inherit the chart’s settings, the window’s settings, or the run settings when there is no chart or window.historyrequests earlier data as a number of source periods or a duration. Null uses the default. Zero (0or0s) asks for live data only: no earlier snapshots are loaded, and reads return snapshots from the period the script started in onward. A negative constant is an error.
Read snapshots from a handler on another subscription. An explicit timeframe
sets the snapshot periods independently of the chart. barsAgo counts these
source periods. Reads use the latest source boundary at or before the handler’s
time. Missing periods return null. Higher-timeframe reads use completed periods;
they do not reveal the final contents of a period still in progress.
Each book period uses its latest high-definition snapshot, not an average.
A positive history can raise the default history request but cannot reduce
it. Initial snapshot history loads up to 250 source periods, separately from
the chart’s replay range, and is also limited by the source’s available
history.
| Parameter | Type |
|---|---|
exchange | string|string[]? |
symbol | string? |
timeframe | timeframe? |
history | int|duration? |
data.cvd
source data.cvd -> CvdSubSubscribes to cumulative volume delta bars.
exchange,symbol, andtimeframechoose the market and period. Omit them or use null to inherit the chart’s settings, the window’s settings, or the run settings when there is no chart or window.historyrequests earlier data as a number of source periods or a duration. Null uses the default. Zero (0,0s, ortime.seconds(0)) asks for live data only: nothing is loaded before the script goes live, handlers on this subscription run only on live updates, and reads return null until then. A live-only subscription does not make the chart’s history finer. A negative constant is an error; a negative input value also means live data only. During the history replay itsisHistoryreads true. Once live, a live-only subscription finer than the chart adds its updates to the chart’s live history, so the chart keeps fewer of its own bars after running for a while.bucketselects a size group from 1 to 11, defaulting to 1. Other values are rejected before the script runs.
Completed bars and the current forming bar are available. history can raise
the amount of data loaded before the visible range so indicators have enough
samples at the left edge. A positive value cannot reduce the default of 750
intraday bars. A longer history can help an EMA settle. Calculations still
return null until they have enough samples.
| Parameter | Type |
|---|---|
exchange | string|string[]? |
symbol | string? |
timeframe | timeframe? |
history | int|duration? |
bucket | int |
data.ohlcv
source data.ohlcv -> OhlcvSubSubscribes to price and volume bars.
exchange,symbol, andtimeframechoose the market and period. Omit them or use null to inherit the chart’s settings, the window’s settings, or the run settings when there is no chart or window.historyrequests earlier data as a number of source periods or a duration. Null uses the default. Zero (0,0s, ortime.seconds(0)) asks for live data only: nothing is loaded before the script goes live, handlers on this subscription run only on live updates, and reads return null until then. A live-only subscription does not make the chart’s history finer. A negative constant is an error; a negative input value also means live data only. During the history replay itsisHistoryreads true. Once live, a live-only subscription finer than the chart adds its updates to the chart’s live history, so the chart keeps fewer of its own bars after running for a while. The chart subscription (no exchange, symbol, or timeframe) cannot be live only. A live-only subscription with the same market and timeframe as one the script needs for a.formingread of a longer timeframe loads history like a normal subscription.
Completed bars and the current forming bar are available. history can raise
the amount of data loaded before the visible range so indicators have enough
samples at the left edge. A positive value cannot reduce the default of 750
intraday bars. A longer history can help an EMA settle. Calculations still
return null until they have enough samples.
| Parameter | Type |
|---|---|
exchange | string|string[]? |
symbol | string? |
timeframe | timeframe? |
history | int|duration? |
data.oi
source data.oi -> OiSubSubscribes to open interest bars.
exchange,symbol, andtimeframechoose the market and period. Omit them or use null to inherit the chart’s settings, the window’s settings, or the run settings when there is no chart or window.historyrequests earlier data as a number of source periods or a duration. Null uses the default. Zero (0,0s, ortime.seconds(0)) asks for live data only: nothing is loaded before the script goes live, handlers on this subscription run only on live updates, and reads return null until then. A live-only subscription does not make the chart’s history finer. A negative constant is an error; a negative input value also means live data only. During the history replay itsisHistoryreads true. Once live, a live-only subscription finer than the chart adds its updates to the chart’s live history, so the chart keeps fewer of its own bars after running for a while.
Completed bars and the current forming bar are available. history can raise
the amount of data loaded before the visible range so indicators have enough
samples at the left edge. A positive value cannot reduce the default of 750
intraday bars. A longer history can help an EMA settle. Calculations still
return null until they have enough samples.
| Parameter | Type |
|---|---|
exchange | string|string[]? |
symbol | string? |
timeframe | timeframe? |
history | int|duration? |
data.stat
source data.stat -> StatSubSubscribes to market statistics bars.
exchange,symbol, andtimeframechoose the market and period. Omit them or use null to inherit the chart’s settings, the window’s settings, or the run settings when there is no chart or window.historyrequests earlier data as a number of source periods or a duration. Null uses the default. Zero (0,0s, ortime.seconds(0)) asks for live data only: nothing is loaded before the script goes live, handlers on this subscription run only on live updates, and reads return null until then. A live-only subscription does not make the chart’s history finer. A negative constant is an error; a negative input value also means live data only. During the history replay itsisHistoryreads true. Once live, a live-only subscription finer than the chart adds its updates to the chart’s live history, so the chart keeps fewer of its own bars after running for a while.
Completed bars and the current forming bar are available. history can raise
the amount of data loaded before the visible range so indicators have enough
samples at the left edge. A positive value cannot reduce the default of 750
intraday bars. A longer history can help an EMA settle. Calculations still
return null until they have enough samples.
| Parameter | Type |
|---|---|
exchange | string|string[]? |
symbol | string? |
timeframe | timeframe? |
history | int|duration? |
data.trades
source data.trades -> TradesSubDelivers individual trades to a trade handler.
exchangeandsymbolchoose the market. Null inherits the chart’s market, the window’s market, or the run settings when neither is present.minSizekeeps only trades withsize >= minSize. Null applies no size filter. A non-positive or non-finite value is rejected before the subscription starts.historyrequests earlier trades as a duration. Null uses the default; your data plan may cap the requested history. When every trades subscription on the market sets a positivehistory, only that much is loaded, however long the chart’s range is. Zero (0sortime.seconds(0)) asks for live trades only: no earlier trades are loaded and the trade handler runs only for trades that arrive after the script goes live, not for earlier trades of the current bar. A negative constant is an error.
| Parameter | Type |
|---|---|
exchange | string? |
symbol | string? |
minSize | float? |
history | duration? |
data.vd
source data.vd -> VdSubSubscribes to volume delta bars.
exchange,symbol, andtimeframechoose the market and period. Omit them or use null to inherit the chart’s settings, the window’s settings, or the run settings when there is no chart or window.historyrequests earlier data as a number of source periods or a duration. Null uses the default. Zero (0,0s, ortime.seconds(0)) asks for live data only: nothing is loaded before the script goes live, handlers on this subscription run only on live updates, and reads return null until then. A live-only subscription does not make the chart’s history finer. A negative constant is an error; a negative input value also means live data only. During the history replay itsisHistoryreads true. Once live, a live-only subscription finer than the chart adds its updates to the chart’s live history, so the chart keeps fewer of its own bars after running for a while.bucketselects a size group from 1 to 11, defaulting to 1. Other values are rejected before the script runs.
Completed bars and the current forming bar are available. history can raise
the amount of data loaded before the visible range so indicators have enough
samples at the left edge. A positive value cannot reduce the default of 750
intraday bars. A longer history can help an EMA settle. Calculations still
return null until they have enough samples.
| Parameter | Type |
|---|---|
exchange | string|string[]? |
symbol | string? |
timeframe | timeframe? |
history | int|duration? |
bucket | int |
data.volume
source data.volume -> VolumeSubProvides volume-profile snapshots to read from another subscription’s handler.
exchange,symbol, andtimeframechoose the market and period. Omit them or use null to inherit the chart’s settings, the window’s settings, or the run settings when there is no chart or window.historyrequests earlier data as a number of source periods or a duration. Null uses the default. Zero (0or0s) asks for live data only: no earlier snapshots are loaded, and reads return snapshots from the period the script started in onward. A negative constant is an error.
Read snapshots from a handler on another subscription. An explicit timeframe
sets the snapshot periods independently of the chart. barsAgo counts these
source periods. Reads use the latest source boundary at or before the handler’s
time. Missing periods return null. Higher-timeframe reads use completed periods;
they do not reveal the final contents of a period still in progress.
Higher timeframes may use wider price bins. Read their width with binSize().
There is no forming volume-profile view.
A positive history can raise the default history request but cannot reduce
it. Initial snapshot history loads up to 250 source periods, separately from
the chart’s replay range, and is also limited by the source’s available
history.
| Parameter | Type |
|---|---|
exchange | string|string[]? |
symbol | string? |
timeframe | timeframe? |
history | int|duration? |
Methods
data.book.askRange
data.book.askRange(from: float, to: float, barsAgo: int = 0) -> BookSideSummary?Summarizes ask levels within a price range.
from and to include both ends of the range. Reversed bounds or a range
with no levels returns null. Unavailable book data also returns null.
barsAgo counts periods on this subscription, with 0 selecting the current
snapshot. An invalid position, a position outside available history, or a missing
snapshot returns null.
avgPrice is the quantity-weighted average price of the selected levels.
Your data plan may limit the levels available to read individually. Built-in summary methods use the full book, so their totals may differ from a loop over the levels available on your plan.
| Parameter | Type |
|---|---|
from | float |
to | float |
barsAgo | int |
Returns BookSideSummary?
Available in Handlers and functions called from handlers.
data.book.asks
data.book.asks(barsAgo: int = 0) -> BookLevels?Returns ask levels, starting with the best price.
barsAgo counts periods on this subscription, with 0 selecting the current
snapshot. An invalid position, a position outside available history, or a missing
snapshot returns null.
Levels are sorted lowest to highest price. A snapshot with no asks returns an
empty view with len == 0.
Read the results in a for loop or a local let variable within the handler.
They cannot be saved in state, record fields, or collections, passed to another
function, or returned from one.
Your data plan may limit the levels available to read individually. Built-in summary methods use the full book, so their totals may differ from a loop over the levels available on your plan.
| Parameter | Type |
|---|---|
barsAgo | int |
Returns BookLevels?
Available in Handlers and functions called from handlers.
data.book.asksTo
data.book.asksTo(price: float, barsAgo: int = 0) -> BookSideSummary?Summarizes ask depth from the best price to a chosen price.
Includes ask levels at or below price. A price beyond the far end of the
book includes the whole side. An empty selection or unavailable book data returns
null. avgPrice is the quantity-weighted average of the selected prices.
barsAgo counts periods on this subscription, with 0 selecting the current
snapshot. An invalid position, a position outside available history, or a missing
snapshot returns null.
Your data plan may limit the levels available to read individually. Built-in summary methods use the full book, so their totals may differ from a loop over the levels available on your plan.
| Parameter | Type |
|---|---|
price | float |
barsAgo | int |
Returns BookSideSummary?
Available in Handlers and functions called from handlers.
data.book.bestAsk
data.book.bestAsk(barsAgo: int = 0) -> float?Returns the lowest ask price.
barsAgo counts periods on this subscription, with 0 selecting the current
snapshot. An invalid position, a position outside available history, or a missing
snapshot returns null.
A snapshot with no asks returns null.
| Parameter | Type |
|---|---|
barsAgo | int |
Returns float?
Available in Handlers and functions called from handlers.
data.book.bestBid
data.book.bestBid(barsAgo: int = 0) -> float?Returns the highest bid price.
barsAgo counts periods on this subscription, with 0 selecting the current
snapshot. An invalid position, a position outside available history, or a missing
snapshot returns null.
A snapshot with no bids returns null.
| Parameter | Type |
|---|---|
barsAgo | int |
Returns float?
Available in Handlers and functions called from handlers.
data.book.bidRange
data.book.bidRange(from: float, to: float, barsAgo: int = 0) -> BookSideSummary?Summarizes bid levels within a price range.
from and to include both ends of the range. Reversed bounds or a range
with no levels returns null. Unavailable book data also returns null.
barsAgo counts periods on this subscription, with 0 selecting the current
snapshot. An invalid position, a position outside available history, or a missing
snapshot returns null.
avgPrice is the quantity-weighted average price of the selected levels.
Your data plan may limit the levels available to read individually. Built-in summary methods use the full book, so their totals may differ from a loop over the levels available on your plan.
| Parameter | Type |
|---|---|
from | float |
to | float |
barsAgo | int |
Returns BookSideSummary?
Available in Handlers and functions called from handlers.
data.book.bids
data.book.bids(barsAgo: int = 0) -> BookLevels?Returns bid levels, starting with the best price.
barsAgo counts periods on this subscription, with 0 selecting the current
snapshot. An invalid position, a position outside available history, or a missing
snapshot returns null.
Levels are sorted highest to lowest price. A snapshot with no bids returns an
empty view with len == 0.
Read the results in a for loop or a local let variable within the handler.
They cannot be saved in state, record fields, or collections, passed to another
function, or returned from one.
Your data plan may limit the levels available to read individually. Built-in summary methods use the full book, so their totals may differ from a loop over the levels available on your plan.
| Parameter | Type |
|---|---|
barsAgo | int |
Returns BookLevels?
Available in Handlers and functions called from handlers.
data.book.bidsTo
data.book.bidsTo(price: float, barsAgo: int = 0) -> BookSideSummary?Summarizes bid depth from the best price to a chosen price.
Includes bid levels at or above price. A price beyond the far end of the
book includes the whole side. An empty selection or unavailable book data returns
null. avgPrice is the quantity-weighted average of the selected prices.
barsAgo counts periods on this subscription, with 0 selecting the current
snapshot. An invalid position, a position outside available history, or a missing
snapshot returns null.
Your data plan may limit the levels available to read individually. Built-in summary methods use the full book, so their totals may differ from a loop over the levels available on your plan.
| Parameter | Type |
|---|---|
price | float |
barsAgo | int |
Returns BookSideSummary?
Available in Handlers and functions called from handlers.
data.book.binSize
data.book.binSize(barsAgo: int = 0) -> float?Returns the width of each book price bin.
barsAgo counts periods on this subscription, with 0 selecting the current
snapshot. An invalid position, a position outside available history, or a missing
snapshot returns null.
| Parameter | Type |
|---|---|
barsAgo | int |
Returns float?
Available in Handlers and functions called from handlers.
data.book.depth
data.book.depth(outerPct: float, ref: number? = null, innerPct: float? = null, barsAgo: int = 0) -> BookDepth?Summarizes order-book depth around a price.
outerPctsets the distance on either side ofref, as a percentage: fromref * (1 - outerPct/100)toref * (1 + outerPct/100). Values outside its allowed range stop the script with an error.refdefaults to the mid price. Without both a bid and an ask, the default reference is unavailable and the result is null.innerPctoptionally excludes prices strictly inside a smaller band around the reference. Null or zero excludes nothing.
barsAgo counts periods on this subscription, with 0 selecting the current
snapshot. An invalid position, a position outside available history, or a missing
snapshot returns null.
An empty price band or unavailable book data also returns null. Read this from
another subscription’s handler; book subscriptions have no handlers.
Your data plan may limit the levels available to read individually. Built-in summary methods use the full book, so their totals may differ from a loop over the levels available on your plan.
| Parameter | Type |
|---|---|
outerPct | float |
ref | number? |
innerPct | float? |
barsAgo | int |
Returns BookDepth?
Available in Handlers and functions called from handlers.
data.book.imbalance
data.book.imbalance(outerPct: float, unit: BookUnit = 2, ref: number? = null, innerPct: float? = null, barsAgo: int = 0) -> float?Returns the balance between bids and asks around a price.
outerPctsets the price band, as fordepth. Values outside its allowed range stop the script with an error.unitchooses quote value (bookunit.quote, the default) or base quantity (bookunit.base).refdefaults to the mid price.innerPctdefaults to null.
barsAgo counts periods on this subscription, with 0 selecting the current
snapshot. An invalid position, a position outside available history, or a missing
snapshot returns null.
Returns (bid - ask) / (bid + ask). Quote units match depth(...).ratioValue;
base units match depth(...).ratioQty. A zero total gives NaN. The result is
null whenever the corresponding depth call is null.
Your data plan may limit the levels available to read individually. Built-in summary methods use the full book, so their totals may differ from a loop over the levels available on your plan.
| Parameter | Type |
|---|---|
outerPct | float |
unit | BookUnit |
ref | number? |
innerPct | float? |
barsAgo | int |
Returns float?
Available in Handlers and functions called from handlers.
data.book.mid
data.book.mid(barsAgo: int = 0) -> float?Returns the midpoint between the best bid and ask.
barsAgo counts periods on this subscription, with 0 selecting the current
snapshot. An invalid position, a position outside available history, or a missing
snapshot returns null.
Calculates (bestBid + bestAsk) / 2. Returns null if either side is empty.
| Parameter | Type |
|---|---|
barsAgo | int |
Returns float?
Available in Handlers and functions called from handlers.
data.book.numAsks
data.book.numAsks(barsAgo: int = 0) -> int?Counts the ask levels in a book snapshot.
barsAgo counts periods on this subscription, with 0 selecting the current
snapshot. An invalid position, a position outside available history, or a missing
snapshot returns null.
A snapshot with no asks returns 0.
Your data plan may limit the levels available to read individually. Built-in summary methods use the full book, so their totals may differ from a loop over the levels available on your plan.
| Parameter | Type |
|---|---|
barsAgo | int |
Returns int?
Available in Handlers and functions called from handlers.
data.book.numBids
data.book.numBids(barsAgo: int = 0) -> int?Counts the bid levels in a book snapshot.
barsAgo counts periods on this subscription, with 0 selecting the current
snapshot. An invalid position, a position outside available history, or a missing
snapshot returns null.
A snapshot with no bids returns 0.
Your data plan may limit the levels available to read individually. Built-in summary methods use the full book, so their totals may differ from a loop over the levels available on your plan.
| Parameter | Type |
|---|---|
barsAgo | int |
Returns int?
Available in Handlers and functions called from handlers.
data.book.range
data.book.range(from: float, to: float, barsAgo: int = 0) -> BookDepth?Summarizes both bid and ask levels within a price range.
from and to include both ends of the range. Reversed bounds or a range
with no levels returns null. Unavailable book data also returns null.
barsAgo counts periods on this subscription, with 0 selecting the current
snapshot. An invalid position, a position outside available history, or a missing
snapshot returns null.
Your data plan may limit the levels available to read individually. Built-in summary methods use the full book, so their totals may differ from a loop over the levels available on your plan.
| Parameter | Type |
|---|---|
from | float |
to | float |
barsAgo | int |
Returns BookDepth?
Available in Handlers and functions called from handlers.
data.book.spread
data.book.spread(barsAgo: int = 0) -> float?Returns the gap between the best ask and bid.
barsAgo counts periods on this subscription, with 0 selecting the current
snapshot. An invalid position, a position outside available history, or a missing
snapshot returns null.
Calculates bestAsk - bestBid. Returns null if either side is empty.
| Parameter | Type |
|---|---|
barsAgo | int |
Returns float?
Available in Handlers and functions called from handlers.
data.book.time
data.book.time(barsAgo: int = 0) -> time?Returns the start time of the book snapshot period.
barsAgo counts periods on this subscription, with 0 selecting the current
snapshot. An invalid position, a position outside available history, or a missing
snapshot returns null.
| Parameter | Type |
|---|---|
barsAgo | int |
Returns time?
Available in Handlers and functions called from handlers.
data.bookLevels.get
data.bookLevels.get(index: int) -> BookLevel?Reads an order-book level by index.
index counts from 0, starting with the best price. A negative index or one at
or beyond len returns null. view[i] is equivalent to view.get(i).
The level’s value equals price * qty.
| Parameter | Type |
|---|---|
index | int |
Returns BookLevel?
Available in Handlers and functions called from handlers.
data.cvd.change
data.cvd.change() -> float?Returns the change from open to close on the confirmed bar.
Calculates close - open for this subscription’s current confirmed bar.
Returns null if the bar or either field is unavailable.
Returns float?
Available in Handlers and functions called from handlers.
data.cvd.range
data.cvd.range() -> float?Returns the high-to-low range of the confirmed bar.
Calculates high - low for this subscription’s current confirmed bar.
Returns null if the bar or either field is unavailable.
Returns float?
Available in Handlers and functions called from handlers.
data.ohlcv.change
data.ohlcv.change() -> float?Returns the change from open to close on the confirmed bar.
Calculates close - open for this subscription’s current confirmed bar.
Returns null if the bar or either field is unavailable.
Returns float?
Available in Handlers and functions called from handlers.
data.ohlcv.delta
data.ohlcv.delta() -> float?Returns the current OHLCV buy-sell volume delta.
Calculates buyVolume - sellVolume for this subscription’s current confirmed bar.
Returns null if the bar or either field is unavailable.
Returns float?
Available in Handlers and functions called from handlers.
data.ohlcv.range
data.ohlcv.range() -> float?Returns the high-to-low range of the confirmed bar.
Calculates high - low for this subscription’s current confirmed bar.
Returns null if the bar or either field is unavailable.
Returns float?
Available in Handlers and functions called from handlers.
data.ohlcv.tradeDelta
data.ohlcv.tradeDelta() -> int?Returns the current OHLCV buy-sell trade-count delta.
Calculates buyCount - sellCount for this subscription’s current confirmed bar.
Returns null if the bar or either field is unavailable.
Returns int?
Available in Handlers and functions called from handlers.
data.oi.change
data.oi.change() -> float?Returns the change from open to close on the confirmed bar.
Calculates close - open for this subscription’s current confirmed bar.
Returns null if the bar or either field is unavailable.
Returns float?
Available in Handlers and functions called from handlers.
data.oi.range
data.oi.range() -> float?Returns the high-to-low range of the confirmed bar.
Calculates high - low for this subscription’s current confirmed bar.
Returns null if the bar or either field is unavailable.
Returns float?
Available in Handlers and functions called from handlers.
data.profile.buckets
data.profile.buckets(count: int, from: number? = null, to: number? = null) -> VolumeBuckets?Groups volume into equal-width price buckets.
count chooses the number of buckets. They span from the lowest selected
price through one binSize above the highest. Each level goes into the bucket
containing its price, so bucket totals add up to the selected range’s totals.
A count below 1 or above 4096 returns null.
from and to select the price range first, including both ends. Null leaves
that end unrestricted. An empty range or reversed bounds returns null.
A window with no snapshots returns null. The profile combines volume at each
price before grouping it.
Read the values you need before calling buckets or bucketsByLevels again
during the same calculation step. A later call replaces the data read through
earlier bucket views, even on another snapshot or profile. Request the buckets
again when you need a fresh view.
| Parameter | Type |
|---|---|
count | int |
from | number? |
to | number? |
Returns VolumeBuckets?
Available in Handlers and functions called from handlers.
data.profile.bucketsByLevels
data.profile.bucketsByLevels(levelsPerBucket: int, from: number? = null, to: number? = null) -> VolumeBuckets?Groups consecutive price levels into volume buckets.
levelsPerBucket chooses how many levels to put in each bucket. The last bucket
can contain fewer levels. Each bucket starts at its first level’s price and
ends one binSize above its last level. A value below 1 returns null. The result cannot exceed 4096 buckets;
exceeding that limit returns null.
from and to select the price range first, including both ends. Null leaves
that end unrestricted. An empty range or reversed bounds returns null.
A window with no snapshots returns null. The profile combines volume at each
price before grouping it.
Read the values you need before calling buckets or bucketsByLevels again
during the same calculation step. A later call replaces the data read through
earlier bucket views, even on another snapshot or profile. Request the buckets
again when you need a fresh view.
| Parameter | Type |
|---|---|
levelsPerBucket | int |
from | number? |
to | number? |
Returns VolumeBuckets?
Available in Handlers and functions called from handlers.
data.profile.delta
data.profile.delta() -> float?Returns the rolling window’s volume delta (buy - sell).
Calculates buy - sell across the rolling profile. This matches
summary().delta when the summary is non-null. A window with no snapshots
returns null.
Returns float?
Available in Handlers and functions called from handlers.
data.profile.poc
data.profile.poc(basis: VolBasis = 0, from: number? = null, to: number? = null) -> VolumeLevel?Returns the point of control: the level with the largest selected volume.
basis chooses which volume to compare, defaulting to volbasis.total.
from and to optionally limit the price range, including both ends; null
leaves that end unrestricted. Ties use the lowest price.
Returns the combined level’s price, buy, sell, total, delta, and ratio. Its
index is -1 because it does not belong to one snapshot. An empty range or
a window with no snapshots returns null.
| Parameter | Type |
|---|---|
basis | VolBasis |
from | number? |
to | number? |
Returns VolumeLevel?
Available in Handlers and functions called from handlers.
data.profile.ratio
data.profile.ratio() -> float?Returns the rolling window’s volume-delta ratio (delta / total).
Calculates delta / total across the rolling profile. This matches
summary().ratio when the summary is non-null. A window with no snapshots
returns null. A zero total volume gives NaN.
Returns float?
Available in Handlers and functions called from handlers.
data.profile.summary
data.profile.summary(from: number? = null, to: number? = null) -> VolumeSummary?Summarizes a rolling profile, optionally within a price range.
from and to select prices, including both ends. Null leaves that end
unrestricted. An empty range, reversed bounds, or a window with no snapshots
returns null.
time is the start time of the newest snapshot period. binSize is the finest
price-bin size in the window. levels counts distinct combined price levels
within the selected range.
| Parameter | Type |
|---|---|
from | number? |
to | number? |
Returns VolumeSummary?
Available in Handlers and functions called from handlers.
data.profile.total
data.profile.total() -> float?Returns the rolling window’s total (buy + sell) volume.
Calculates buy + sell across the rolling profile. This matches
summary().total when the summary is non-null. A window with no snapshots
returns null.
With one snapshot, profile(bars: 1).total() equals vol.total(). Unavailable
profile data also returns null.
Returns float?
Available in Handlers and functions called from handlers.
data.profile.valueArea
data.profile.valueArea(percent: float, basis: VolBasis = 0, from: number? = null, to: number? = null) -> VolumeArea?Returns the low and high prices of a volume value area.
percent sets how much of the selected volume the area should cover. basis
chooses the volume to use, defaulting to volbasis.total. from and to
optionally limit the price range; null leaves that end unrestricted.
Starts at the point of control, then adds the neighboring level with more
selected volume until the target percentage is reached. Ties at the point of
control or during expansion choose the lower price. At percent: 100.0, the
area covers the whole range.
lowPrice and highPrice describe the area. The other fields (buy, sell,
total, delta, ratio, and levels) summarize the entire queried price range.
An empty range or a window with no snapshots returns null.
| Parameter | Type |
|---|---|
percent | float |
basis | VolBasis |
from | number? |
to | number? |
Returns VolumeArea?
Available in Handlers and functions called from handlers.
data.stat.liqDelta
data.stat.liqDelta() -> float?Returns the current buy-sell liquidation delta.
Calculates buyLiq - sellLiq for this subscription’s current confirmed bar.
Returns null if the bar or either field is unavailable.
Returns float?
Available in Handlers and functions called from handlers.
data.stat.liqTotal
data.stat.liqTotal() -> float?Returns the current total liquidation value.
Calculates buyLiq + sellLiq for this subscription’s current confirmed bar.
Returns null if the bar or either field is unavailable.
Returns float?
Available in Handlers and functions called from handlers.
data.vd.change
data.vd.change() -> float?Returns the change from open to close on the confirmed bar.
Calculates close - open for this subscription’s current confirmed bar.
Returns null if the bar or either field is unavailable.
Returns float?
Available in Handlers and functions called from handlers.
data.vd.range
data.vd.range() -> float?Returns the high-to-low range of the confirmed bar.
Calculates high - low for this subscription’s current confirmed bar.
Returns null if the bar or either field is unavailable.
Returns float?
Available in Handlers and functions called from handlers.
data.volume.binSize
data.volume.binSize(barsAgo: int = 0) -> float?Returns the width of each price bin.
barsAgo counts periods on this subscription, with 0 selecting the current
snapshot. An invalid position, a position outside available history, or a missing
snapshot returns null.
| Parameter | Type |
|---|---|
barsAgo | int |
Returns float?
Available in Handlers and functions called from handlers.
data.volume.buckets
data.volume.buckets(count: int, from: number? = null, to: number? = null, barsAgo: int = 0) -> VolumeBuckets?Groups volume into equal-width price buckets.
count chooses the number of buckets. They span from the lowest selected
price through one binSize above the highest. Each level goes into the bucket
containing its price, so bucket totals add up to the selected range’s totals.
A count below 1 or above 4096 returns null.
from and to select the price range first, including both ends. Null leaves
that end unrestricted. An empty range or reversed bounds returns null.
barsAgo chooses the snapshot; a missing snapshot returns null.
Read the values you need before calling buckets or bucketsByLevels again
during the same calculation step. A later call replaces the data read through
earlier bucket views, even on another snapshot or profile. Request the buckets
again when you need a fresh view.
| Parameter | Type |
|---|---|
count | int |
from | number? |
to | number? |
barsAgo | int |
Returns VolumeBuckets?
Available in Handlers and functions called from handlers.
data.volume.bucketsByLevels
data.volume.bucketsByLevels(levelsPerBucket: int, from: number? = null, to: number? = null, barsAgo: int = 0) -> VolumeBuckets?Groups consecutive price levels into volume buckets.
levelsPerBucket chooses how many levels to put in each bucket. The last bucket
can contain fewer levels. Each bucket starts at its first level’s price and
ends one binSize above its last level. A value below 1 returns null.
from and to select the price range first, including both ends. Null leaves
that end unrestricted. An empty range or reversed bounds returns null.
barsAgo chooses the snapshot; a missing snapshot returns null.
Read the values you need before calling buckets or bucketsByLevels again
during the same calculation step. A later call replaces the data read through
earlier bucket views, even on another snapshot or profile. Request the buckets
again when you need a fresh view.
| Parameter | Type |
|---|---|
levelsPerBucket | int |
from | number? |
to | number? |
barsAgo | int |
Returns VolumeBuckets?
Available in Handlers and functions called from handlers.
data.volume.bucketsByStep
data.volume.bucketsByStep(step: float, from: number? = null, to: number? = null, barsAgo: int = 0) -> VolumeBuckets?Groups volume into price buckets of a fixed size on a shared price grid.
step is the height of every bucket. Buckets start at whole multiples of step, so a price falls in the same bucket on every snapshot: rows line up across bars. The first bucket holds the lowest selected price, the last the highest, and empty buckets between them are included with zero volume. A step that is zero, negative or not finite returns null, as does a range that needs more than 4096 buckets.
from and to select the price range first, including both ends. Null leaves that end open. An empty range or reversed bounds return null. barsAgo chooses the snapshot; a missing snapshot returns null.
The view’s time is the start of the snapshot’s period: the time to pass when drawing the buckets as cells on that period’s bar.
| Parameter | Type |
|---|---|
step | float |
from | number? |
to | number? |
barsAgo | int |
Returns VolumeBuckets?
Available in Handlers and functions called from handlers.
data.volume.delta
data.volume.delta(barsAgo: int = 0) -> float?Returns the buy volume minus sell volume.
barsAgo counts periods on this subscription, with 0 selecting the current
snapshot. An invalid position, a position outside available history, or a missing
snapshot returns null.
An empty snapshot returns 0.0. This matches summary(barsAgo).delta when the
summary is non-null.
| Parameter | Type |
|---|---|
barsAgo | int |
Returns float?
Available in Handlers and functions called from handlers.
data.volume.level
data.volume.level(index: int, barsAgo: int = 0) -> VolumeLevel?Reads a volume-profile level by index.
index counts traded price levels from 0, starting with the lowest price.
barsAgo chooses the snapshot. Adjacent levels can be more than one binSize
apart because prices with no stored trades are skipped.
An index beyond the level count, unavailable history, or a missing snapshot
returns null. Read the count with summary(barsAgo).levels.
| Parameter | Type |
|---|---|
index | int |
barsAgo | int |
Returns VolumeLevel?
Available in Handlers and functions called from handlers.
data.volume.levels
data.volume.levels(barsAgo: int = 0) -> VolumeLevels?Returns volume-profile levels from lowest to highest price.
barsAgo counts periods on this subscription, with 0 selecting the current
snapshot. An invalid position, a position outside available history, or a missing
snapshot returns null.
Contains the traded levels, matching level(index, barsAgo:) one by one. A
snapshot with no levels returns an empty view with len == 0. These results
include all profile levels; the order-book depth limit does not apply.
Read the results in a for loop or a local let variable within the handler.
They cannot be saved in state, record fields, or collections, passed to another
function, or returned from one.
| Parameter | Type |
|---|---|
barsAgo | int |
Returns VolumeLevels?
Available in Handlers and functions called from handlers.
data.volume.numLevels
data.volume.numLevels(barsAgo: int = 0) -> int?Returns the number of traded price levels.
barsAgo counts periods on this subscription, with 0 selecting the current
snapshot. An invalid position, a position outside available history, or a missing
snapshot returns null.
An empty snapshot returns 0. This matches summary(barsAgo).levels when the
summary is non-null.
| Parameter | Type |
|---|---|
barsAgo | int |
Returns int?
Available in Handlers and functions called from handlers.
data.volume.poc
data.volume.poc(basis: VolBasis = 0, from: number? = null, to: number? = null, barsAgo: int = 0) -> VolumeLevel?Returns the point of control: the level with the largest selected volume.
basis chooses which volume to compare, defaulting to volbasis.total.
from and to optionally limit the price range, including both ends; null
leaves that end unrestricted. Ties use the lowest price.
barsAgo chooses the snapshot. An empty range, reversed bounds, or a missing
snapshot returns null.
| Parameter | Type |
|---|---|
basis | VolBasis |
from | number? |
to | number? |
barsAgo | int |
Returns VolumeLevel?
Available in Handlers and functions called from handlers.
data.volume.profile
data.volume.profile(bars: int) -> ProfileCreates a rolling volume profile over the last bars confirmed snapshots.
Returns a Profile combining the last bars completed volume snapshots
available at the time the handler runs. The profile itself is never null, but
its query results can be null. It has no barsAgo: parameter.
Keep the profile in a let variable or call its methods directly. It cannot
be saved in state, record fields, or collections, passed to a function, or
returned from one.
bars must be known before the script runs: use a literal, input, or
setup value. Invalid bars values are rejected before the script runs.
Each profile supports up to 65,536 distinct price levels and is also subject to the script’s resource limits. If either limit is exceeded, its
queries return null without stopping the script. Later queries can remain null
even if the window becomes smaller. Refreshing the data or restarting the
script allows another attempt; reduce bars if the limit keeps being reached.
If fewer than bars completed snapshots are available, the profile uses those
that exist. With no snapshots, all query methods return null.
| Parameter | Type |
|---|---|
bars | int |
Returns Profile
Available in Handlers and functions called from handlers.
data.volume.ratio
data.volume.ratio(barsAgo: int = 0) -> float?Returns the volume delta divided by total volume.
barsAgo counts periods on this subscription, with 0 selecting the current
snapshot. An invalid position, a position outside available history, or a missing
snapshot returns null.
Returns NaN if total volume is zero. This matches summary(barsAgo).ratio
when the summary is non-null.
| Parameter | Type |
|---|---|
barsAgo | int |
Returns float?
Available in Handlers and functions called from handlers.
data.volume.summary
data.volume.summary(barsAgo: int = 0, from: number? = null, to: number? = null) -> VolumeSummary?Summarizes a volume profile, optionally within a price range.
barsAgo counts periods on this subscription, with 0 selecting the current
snapshot. An invalid position, a position outside available history, or a missing
snapshot returns null.
from and to select prices, including both ends. Null leaves that end
unrestricted, so summary(0) reads the whole current profile. Reversed bounds
or a range with no levels returns null.
Read this from another subscription’s handler. Volume profiles have no forming view.
| Parameter | Type |
|---|---|
barsAgo | int |
from | number? |
to | number? |
Returns VolumeSummary?
Available in Handlers and functions called from handlers.
data.volume.time
data.volume.time(barsAgo: int = 0) -> time?Returns the start time of the snapshot period.
barsAgo counts periods on this subscription, with 0 selecting the current
snapshot. An invalid position, a position outside available history, or a missing
snapshot returns null.
| Parameter | Type |
|---|---|
barsAgo | int |
Returns time?
Available in Handlers and functions called from handlers.
data.volume.total
data.volume.total(barsAgo: int = 0) -> float?Returns the total buy and sell volume.
barsAgo counts periods on this subscription, with 0 selecting the current
snapshot. An invalid position, a position outside available history, or a missing
snapshot returns null.
An empty snapshot returns 0.0. This matches summary(barsAgo).total when the
summary is non-null.
| Parameter | Type |
|---|---|
barsAgo | int |
Returns float?
Available in Handlers and functions called from handlers.
data.volume.valueArea
data.volume.valueArea(percent: float, basis: VolBasis = 0, from: number? = null, to: number? = null, barsAgo: int = 0) -> VolumeArea?Returns the low and high prices of a volume value area.
percent sets how much of the selected volume the area should cover. basis
chooses the volume to use, defaulting to volbasis.total. from and to
optionally limit the price range; null leaves that end unrestricted.
Starts at the point of control, then adds the neighboring level with more
selected volume until the target percentage is reached. Ties at the point of
control or during expansion choose the lower price. At percent: 100.0, the
area covers the whole range.
lowPrice and highPrice describe the area. The other fields (buy, sell,
total, delta, ratio, and levels) summarize the entire queried price range.
barsAgo chooses the snapshot. An empty range, reversed bounds, or a missing
snapshot returns null.
| Parameter | Type |
|---|---|
percent | float |
basis | VolBasis |
from | number? |
to | number? |
barsAgo | int |
Returns VolumeArea?
Available in Handlers and functions called from handlers.
data.volumeBuckets.get
data.volumeBuckets.get(index: int) -> FootprintBucket?Reads a volume bucket by index.
index counts from 0, starting with the lowest price range. A negative index
or one at or beyond len returns null. view[i] is equivalent to view.get(i).
total is buy + sell; delta is buy - sell.
A later buckets or bucketsByLevels call during the same calculation step
replaces the data read through this view, even if it uses another snapshot
or profile.
| Parameter | Type |
|---|---|
index | int |
Returns FootprintBucket?
Available in Handlers and functions called from handlers.
data.volumeLevels.get
data.volumeLevels.get(index: int) -> VolumeLevel?Reads a volume-profile level by index.
index counts from 0, starting with the lowest price. A negative index or one
at or beyond len returns null. view[i] is equivalent to view.get(i).
The fields match level(index, barsAgo:) for the same snapshot. The level’s
ratio is NaN when its total volume is zero.
| Parameter | Type |
|---|---|
index | int |
Returns VolumeLevel?
Available in Handlers and functions called from handlers.
Constants
| Constant | Type | Value | Description |
|---|---|---|---|
bookunit.base | BookUnit | 1 | Selects base quantity for book imbalance calculations. |
bookunit.quote | BookUnit | 2 | Selects quote value for book imbalance calculations. |
volbasis.buy | VolBasis | 1 | Ranks profile levels by buy volume. |
volbasis.deltaAbs | VolBasis | 3 | Ranks profile levels by |buy - sell| (absolute per-level delta). |
volbasis.sell | VolBasis | 2 | Ranks profile levels by sell volume. |
volbasis.total | VolBasis | 0 | Ranks profile levels by total (buy + sell) volume. |