Order-book data
The order book ChartDeck records, the biggest size per price bucket in each bar, as heatmap columns (book.heat) or levels (book.depth).
ChartDeck records the order books of the main markets once a minute: within 10% of the price, the buckets that stand out (at least 1.5 times the side's typical size). The built-in Order Book Heatmap draws that history. A script reads the same recording, bar by bar.
#As a heatmap column
book.heat(side) gives a heatmap.column for the bar: one cell per price bucket from the lowest to the highest recorded one, each holding the largest size seen there during the bar (in the base coin; empty where nothing rested). side is "bid", "ask" or "both". A bid bucket ix covers the prices from ix × g to (ix + 1) × g, an ask bucket from (ix − 1) × g to ix × g, where g is book.bucket(), about 0.05% of the price.
//@chartscript 1
indicator("Book heat", { overlay: true, behind_chart: true })
state bids = heatmap.new({ palette: heatmap.palette_bid, floor: 0.08 })
state asks = heatmap.new({ palette: heatmap.palette_ask, floor: 0.08 })
const b = book.heat("bid")
const a = book.heat("ask")
if (!na(b)) {
bids.add(b)
}
if (!na(a)) {
asks.add(a)
}See Heatmaps for the colors and the automatic reference.
#As levels
book.depth(side) gives the same buckets as book.level values: bids from the best price down, then asks from the best price up.
| Field | Type | Meaning |
|---|---|---|
price | float | the bucket's middle |
low, high | float | the bucket's edges |
size | float | the largest size seen there during the bar (base coin) |
notional | float | price × size |
side | string | "bid" or "ask" |
//@chartscript 1
indicator("Biggest wall", { overlay: true })
let best = 0.0
let at: float = na
for (const lv of book.depth()) {
if (lv.notional > best) {
best = lv.notional
at = lv.price
}
}
plot(at, "Wall", color.amber, 2, { style: plot.style_circles })#How far back it goes
| Plan | Book history |
|---|---|
| Beginner, Plus | none (the built-in study shows the live book only) |
| Pro | 7 days |
| Elite | 180 days (minute detail for the last 30 days, 15-minute columns before) |
Only recorded markets have a history: the main Binance, Bybit, OKX and Hyperliquid markets. Elsewhere book.heat is na and book.depth empty, and book.since() is na. The newest column is at most about a minute old; it is refreshed every minute. The built-in study adds the browser's live book (several frames a second) and a projection of the current book onto the bars with no history yet; a script reads the recorded columns only.
On a chart of seconds the minute columns are read; on weekly and monthly charts the daily ones (each bar takes the largest size of each bucket over its columns).