Skip to main content
Read more than the chart’s own bars. Every kind of data 0xArchive records is a stream a script declares at the top, and every stream reads as of the bar being run, so history never sees the future.

Streams

Anything a stream does not have reads na, null or available: false, never a guess. Each stream’s fields are in the reference.

Other markets and intervals

bars({ market, interval, venue }) reads another market, another interval, or both. Give it a handler of its own when there is something to calculate on its bars:
ema.confirmed is the EMA as of the last closed 4-hour bar, so the line steps once per 4 hours and draws the same on history as it did live. Intervals are 1m to 1w, calendar months 1M to 12M (capital M; 1m is a minute), and bars that close on trades: seconds (s15), trade counts (t500), volume (v1000000), delta, range, renko and reversal. Weeks open on Monday 00:00 UTC.

As of: no lookahead

Inside a handler, every stream other than the handler’s own reads its last confirmed value at or before the current moment: just before the bar’s close in history, and the newest data live. A 4-hour bar that closes with the last 1-hour bar of its span is visible on that 1-hour bar, as Pine’s request.security with lookahead off shows it. The one way to read a bar still forming is to ask for it by name, .forming:
Live, forming is the developing bar, which changes until it closes: it repaints. On history it is the last closed bar, so history still never looks ahead.

The forming bar

The chart’s newest bar runs again on every update, each time from the last commit: confirmed is false, every state.bar value is back where the last closed bar left it, and only the latest run’s output is drawn. When the bar closes, onBar runs once more with confirmed true, then onClose. Do something once per bar in onClose; do something that should follow the price live in onBar.

Events: trades and liquidations

trades(), takerOrders(), liquidations(), optionTrades() and optionOrders() deliver events to onTrade, onOrder and onLiquidation, in execution order, before the onBar of the bar they fall in. Sum them into tallies and read the tallies in the chart’s handlers; see order flow, liquidations and BTC options. available says whether the stream covers the current bar completely: older bars than its history have none.

The live book

book() is the order book as it is now, level by level: bids and asks best first, each with price, size and notional, bestBid, bestAsk, mid, spread, and size(side, price) for one price. It holds the nearest 100 levels a side, ungrouped; book({ levels: 400 }) holds more. onUpdate runs once per book the page receives, about one per block of the venue’s, in time order with trades and before the onBar of the bar it falls in, and changes lists the levels it changed with the size each had before:
Like events, an update’s handler may change only tallies and live state. Read anywhere else, the book is as of that moment: at a bar’s close in history, the newest live. On a chart in the browser the book is live only. 0xArchive’s full-depth archive is served per bar there, as orderBook(), not level by level, so book() starts when the page does: older bars read available false and empty lists. A dropped feed is an update too, with available false until the book is back, and the first book after it replaces the book whole (snapshot). A re-run (new settings, an edit) reads the book from as far back as its changes are kept: the last 200,000 to 400,000 rows, one to two hours of BTC’s 100 levels a side and 20 to 70 minutes of its 400 (measured on 2026-10-16). What was drawn before keeps until then. On a server backtest, book() is the archive’s order book every 5 seconds of block time, for Hyperliquid from 6 September 2026. Days the archive has not built read as unavailable. There is one update per 5-second column whose nearest levels changed, stamped at the column’s last millisecond, so a bar sees the book as of its own close and never later. Sizes are rounded to within about 4%. Where the archive does not know the book, available is false until the next update replaces it whole. A trigger in its handler is replayed against the book: Algos says how it fills. Nothing inside a 5-second column is seen: quotes that came and went, the order of changes, or your place in a queue. A backtest reads at most 31 days of the book, or 14 days at 400 levels; the backtest form says so before it runs a longer span.

Sample streams

orderBook(), openInterest(), funding(), derivatives(), breadth(), depth() and liquidationLevels() have no handlers. Read them in any handler; each gives its value as of that moment, or na with available: false when there is none.

Next step

Read every trade in order flow.
Last modified on November 16, 2026