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() and liquidations() deliver events to onTrade 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 and liquidations. available says whether the stream covers the current bar completely: older bars than its history have none.

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 October 16, 2026