> ## 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.

# Option sweeps

> Mark the biggest BTC option order each way on every bar, with its premium, strikes and kind.

![Option sweeps on a BTC chart](https://mintcdn.com/0xarchive-e895b8e7/DrnrnwWnW7x-wb89/images/terminal/examples/option-sweeps.webp?fit=max\&auto=format\&n=DrnrnwWnW7x-wb89\&q=85\&s=323d364510aedddd8a9e7c3928d97343)

BTC on 15-minute bars in the 0xArchive Terminal, 2026-10-24.

> **[Open on a chart](https://terminal.0xarchive.io/?symbol=BTC\&interval=15m\&scripts=example%3Aoption-sweeps)**
>
> Load it on BTC 15m in the terminal, then change its settings or open it in the script editor.

Big option orders often lead the spot market. This script reads every BTC option print, joins them into orders, and tags the largest of \$250k premium or more on each bar once it closes: an order that leans up (calls bought, puts sold) under the candle, one that leans down (puts bought, calls sold) above it. Each mark gives the premium, the strike or range of strikes with C for calls or P for puts, and B for a **block** or S for a **sweep**, one taker order that took several strikes or prices in the same millisecond. A screen combo has no letter. It works on any chart; the options are always BTC's.

## How it works

`optionOrders()` delivers each order once all its prints are in, with its sizes split by side and by calls and puts, its premium in USD, and how many strikes it took. A spread, whose legs went both ways, reads `side: 'mixed'` and is left out. The largest order each way lives in [live state](https://docs.0xarchive.io/terminal/guides/state.md) until the bar closes, because an event handler may change only tallies and live state.

Option prints reach back 7 days.

## Try changing

* Turn on **Sweeps only** to keep taker orders that took more than one print, and skip blocks and combos.
* Read each print with `optionTrades()` instead, for its instrument, IV, mark price and the exchange's own ids.

## The script

```ts option-sweeps.ts theme={"theme":"github-dark"}
// Big BTC option orders on the chart, whatever market it shows. On each bar the largest
// order over a premium that leans up (calls bought, puts sold) is marked under the candle, and the
// largest that leans down (puts bought, calls sold) above it, with its premium, strike, calls or puts,
// and an S for a sweep or B for a block.
// A block or a screen combo is one order; so is a sweep, one taker order that took several strikes
// or prices in the same millisecond. Spreads, whose legs went both ways, are left out.
indicator('Option sweeps', { overlay: true, shortName: 'Option orders', maxLabels: 80 });

const minUsd = input.float('Minimum premium ($)', 250_000, { min: 0 });
const sweepsOnly = input.bool('Sweeps only', false);

const chart = bars();
const orders = optionOrders({ minNotional: minUsd });

// This bar's largest order each way: its premium and its words. An event handler may change only tallies and live state.
const upUsd = state.live<number>(0);
const upText = state.live<string>('');
const downUsd = state.live<number>(0);
const downText = state.live<string>('');

const strikeText = (strike: number) => `${Math.round(strike / 1000)}k`;

orders.onOrder((o) => {
  if (o.side === 'mixed') return;
  const sweep = o.kind === 'taker' && o.fills > 1;
  if (sweepsOnly && !sweep) return;
  // Calls more than puts reads as calls: a call bought, or a put sold, leans up.
  const calls = o.callSize >= o.putSize;
  const up = (o.side === 'buy') === calls;
  const kind = o.kind === 'block' ? ' B' : sweep ? ' S' : '';
  const strikes = o.strikes > 1 ? `${strikeText(o.lowStrike)}-${strikeText(o.highStrike)}` : strikeText(o.strike);
  const text = `${fmt.usd(o.premium)} ${strikes}${calls ? 'C' : 'P'}${kind}`;
  const best = up ? upUsd : downUsd;
  if (o.premium <= best.value) return;
  best.value = o.premium;
  (up ? upText : downText).value = text;
});

// Tags pointing at the candle, once its bar closes: up under the low, down over the high. The newest 80 stay.
chart.onClose(() => {
  // `available` is false before the prints' 7 days.
  if (orders.available) {
    if (upUsd.value > 0) draw.label({ at: { bar: chart.index, price: chart.low }, text: upText.value, style: 'up', color: color.up, textColor: color.panel, size: 'small' });
    if (downUsd.value > 0) draw.label({ at: { bar: chart.index, price: chart.high }, text: downText.value, style: 'down', color: color.down, textColor: color.panel, size: 'small' });
  }
  upUsd.value = 0;
  downUsd.value = 0;
});
```

## Next step

See the next example, [Dealer gamma](https://docs.0xarchive.io/terminal/examples/dealer-gamma.md).


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