> ## Documentation Index
> Fetch the complete documentation index at: https://docs.0xarchive.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Bid share within a band

> The share of resting size on the bid within a band around the mid, from the live book.

<Note>
  This script reads only live data, so it has no history to draw: open it on a chart and watch it fill in.
</Note>

<Card title="Open on a chart" icon="chart-candlestick" href="https://terminal.0xarchive.io/?symbol=BTC&interval=1m&scripts=example%3Abook-imbalance" horizontal>
  Load it on BTC 1m in the terminal, then change its settings or open it in the script editor.
</Card>

The bid's share of the resting size within a band around the mid: above 0.5, more size waits to buy than to sell.

## How it works

`depth()` reads the book the page shows, so it has no history: the line starts when the chart opens and grows live. For the book on every bar of history, from 0xArchive's full-depth archive, use [`orderBook()`](/terminal/reference/streams#orderbook) and its `imbalance(band)`.

## The script

```ts book-imbalance.ts theme={"theme":"github-dark"}
// The bid's share of resting size within a band around the mid.
indicator('Bid share within a band');

// The book the page shows reaches about 0.06% on BTC at its default 20 levels; show more levels for a wider band.
const band = input.float('Band (%)', 0.05, { min: 0.01, max: 10, step: 0.01 });

const chart = bars();
const book = depth({ bandsPct: [band] });
const share = plot.line('Bid share', { range: { min: 0, max: 1 } });
plot.level('Even', 0.5, { style: 'dashed' });

chart.onBar(() => {
  if (!book.available) return;
  const bid = book.bid(band);
  const ask = book.ask(band);
  share.set(bid + ask > 0 ? bid / (bid + ask) : na);
});
```

## Next step

See the next example, [EMA](/terminal/examples/ema).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.