Flow tape
Flow Tape groups this symbol's option trades into the orders they likely came from, newest first.
A sweep is one order split across exchanges to get done fast, and a block is one large trade. Tags flag orders that open new positions, beat open interest (contracts still held open), repeat, or look unusual. Scores run from -100 to 100, above 0 for a bet on a rise, further out when urgent or large. Use it on a US stock, coin or CME (Chicago futures exchange) future to spot urgent bets as they happen.
Under the hood: a celled option_prints.cells input (Data sources) feeds a list of open orders that the prints merge into. A celled option_contract_state.cells input carries the open interest and the volume today (Data sources). Both are read through their present masks (The present mask and partial bars). An order is a SWEEP on two venues or more, a SPLIT on one, and a BLOCK at the block size. Tags read OPEN, OPEN+, VOL>OI, REPEAT and UNUSUAL. A ring keeps the closed rows, and its frame feeds a panel.table under the chart (Table). Its rows name their contracts in markets with fb_contract (Rows that open a market). The options kit's optionsTradeDay gives the trade dates (Options kit). Its flowSideCode and flowScore give each row's score (Flow score). fbExpiryLabel names each contract's expiry (Panel frames). This is also the flow-tape template: the Flow Tape card under Order flow in the editor's starter list, and it compiles as written.
The wrun indicator
// Flow Tape: this symbol's option trades, grouped into the orders they likely came from, newest first. A print is one
// option trade, and each line of the table under the chart is one order. A sweep is one order split across exchanges to
// get done fast, and a block is one large trade. Tags flag orders that open new positions, beat open interest
// (contracts still held open), repeat or look unusual. Scores run from -100 to 100. A call (a bet on a rise) bought or
// a put (a bet on a fall) sold scores above 0. Urgent or large orders score further from 0. Use it to spot urgent,
// unusual bets as they happen.
//
// Under the hood: the option prints of the chart's underlying, merged into the orders they most likely
// came from and tagged, newest first, in a table under the chart. Prints of one contract on one side of the quote within
// a short window of the first are one row: a SWEEP when they printed on two venues or more (an order that took the best
// price on each venue in turn, inferred from the prints since the trade conditions are not served), a SPLIT when they
// printed on one venue, and a BLOCK when one print alone holds at least the block size (contracts, or coins on a crypto
// chart). A crypto or CME chain trades on one venue, so there no order sweeps and the sweep readings read NaN. A row
// also reads OPEN when its size exceeds the contract's open interest before the day (a print that size cannot all be
// closing), OPEN+ when an OPEN row holds at least the large premium (a large opening order), VOL>OI when the
// contract's volume today has passed that open interest, REPEAT when the contract printed on the row's side of the
// quote in 3 bursts or more within the last 5 sessions the tape has seen (a burst ends once 60 s pass without a print of
// it, and counts while it holds at least half the premium of the contract's largest; a contract whose bursts the tape
// cannot all keep reads no REPEAT until the lost ones leave the window), and UNUSUAL (this tape's own rule) when a row
// of today was bought at the ask, out of the money, within 60 days of expiry, with VOL>OI and at least the unusual
// premium. Open interest and volume come from the chain summary, so those tags read for today's prints, and
// OPEN for the prior day's too; a crypto chain's open interest is live, so there the prior UTC day's stands for it
// before today and the day before reads none. A row reads the time (on the market's clock), the contract, the days to
// expiry, the kind, the side (AA above the ask, A at the ask, M the mid, B at the bid, BB below the bid; the taker's
// side on crypto and CME, A bought and B sold), the size, the average price, the premium, the underlying's price, the
// prints and venues, the tags and the score: the options kit's flowScore, -100 bearish to 100 bullish, from the side as
// the row reads it (flowSideCode), call or put, the moneyness against the row's underlying (at the money within 0.5%; the
// chart's close where no print carried one), the days to expiry, the size over that open interest (past it where the
// summary holds none) and the repeat hits. The score's sign is the row's lean (a call bought or a put sold bullish, a
// call sold or a put bought bearish, the mid neutral), in the up colour, the down colour or the muted ink. Smallest
// score keeps the rows by their score. A US listed row (OPRA) names its contract so the chart can open it. The chart
// serves the window's 2,000 newest prints of 5,000 and up (three days), and every print up to 1 s before the oldest of
// them so an order keeps its legs: a leg under 5,000 is not seen, and an older bar's sweep readings read 0.
section("Orders");
param.int("window_ms", 1000, { min: 50, max: 10000, label: "Merge window, ms", description: "Trades in one contract on one side, within this many milliseconds of the first, count as one order." });
param.int("block_size", 500, { min: 10, max: 100000, label: "Block size", description: "A single trade of at least this many contracts reads BLOCK (one big trade). This applies on US stocks and CME.", visible_by: { size_unit: [0, 2, 3] } });
param.number("block_coins", 25, { min: 0.01, max: 100000, step: 1, label: "Block size, coins", description: "A single trade of at least this many coins reads BLOCK (one big trade) on a crypto chart.", visible_by: { size_unit: [1] } });
param.number("unusual_premium", 100000, { min: 5000, max: 1000000000, step: 5000, label: "Unusual premium, USD", description: "The smallest premium (the money paid) an order needs to read UNUSUAL." });
param.number("large_premium", 100000, { min: 5000, max: 1000000000, step: 5000, label: "Large opening premium, USD", description: "An OPEN order with at least this premium (the money paid) also reads OPEN+, a large new position." });
section("Table");
param.number("min_premium", 50000, { min: 5000, max: 1000000000, step: 5000, label: "Smallest premium, USD", description: "Hides orders with less premium (the money paid) than this. The chart loads trades from $5,000 up." });
param.choice("show", ["every order", "sweeps, splits and blocks", "sweeps only"], "every order", { label: "Show", description: "A sweep (one order split across exchanges to get done fast) needs two exchanges or more. A split is several trades on one exchange. Crypto and CME trade on one, so sweeps only lists none there." });
param.int("rows", 30, { min: 5, max: 100, label: "Orders listed", description: "How many of the newest orders the table shows." });
param.number("min_score", -100, { min: -100, max: 100, step: 5, label: "Smallest score", description: "Scores run from -100 (bearish) to 100 (bullish). -100 or 0 lists every order. Above 0 lists orders at least that far from 0, either way. Below 0 lists orders at or below it." });
input("close", ohlcv.close); // the chart's own candles: the grid the prints line up on, and the price a row's moneyness falls back to
input("prints", option_prints.cells, { max_cells: 5000, min_premium: 5000, history: "3d", newest: 2000, newest_tail_ms: 1000, description: "This symbol's option trades of $5,000 and up: the 2,000 newest of three days. It adds every trade up to 1 second before the oldest, so an order keeps all its trades. It updates live on a real-time chart." }); // [offset_ms, print_key, root_code, expiry_ms, side_cp, strike, price, size, premium, aggressor, outside, underlying, iv, delta, venue, present] per print
input("state", option_contract_state.cells, { max_cells: 16000, expiries: "nearest:12", strike_window_pct: 25, description: "This symbol's options summary on the newest bar: each contract's open interest (contracts still held open), the prior day's, and its volume today. It covers the twelve nearest expiries and strikes within 25% of the price." }); // [root_code, expiry_ms, side_cp, strike, bid, ask, last, prev_close, theta, volume_day, oi, oi_prev, present] per contract
market.size_unit(); // the market's facts: its clock (a row's time, its trade date and days to go, whether it names a US listed contract) and its size unit (the block size read)
// The readings, data-only: rows that closed on the bar (an order closes once its window has passed).
output("sweeps", none, overlay, { description: "Sweeps (orders split across exchanges) that closed in this bar, at or above the smallest premium (the money paid). Blank on crypto and CME, which trade on one exchange." });
output("sweep_lean", none, overlay, { format: "usd", description: "Premium (the money paid) of this bar's bullish sweeps (orders split across exchanges) minus its bearish sweeps, in USD. Blank on crypto and CME." });
output("partial", none, overlay, { description: "1 on a bar older than the trade history OpenMarket keeps. Orders there may lack some trades." });
const tape_rows = frame("tape_rows", { max_bytes: 65536 }); // the table, rewritten on the live bar
panel.table({
name: "tape",
title: "Flow tape",
x: "category",
place: "below",
frame: tape_rows,
height_frac: 0.35,
font_size: 10,
cell_padding: 3,
valign: "middle",
header_text_color: "theme.muted",
grid_color: "theme.grid",
grid_width: 1,
grid_lines: "rows",
border_width: 0,
series: [
{ name: "Time" },
{ name: "Contract" },
{ name: "Days left", align: "right", format: "int" },
{ name: "Kind" },
{ name: "Side", align: "center" },
{ name: "Size", align: "right", format: "auto" },
{ name: "Price", align: "right", format: "0.00" },
{ name: "Premium", align: "right", format: "usd" },
{ name: "Spot", align: "right", format: "0.00" },
{ name: "Prints" },
{ name: "Tags" },
{ name: "Score", align: "right", format: "0.0", signed: true },
],
});
const PRINT = 16; // f64s per print: OPTION_PRINTS_TUPLE
const STATE = 13; // OPTION_CONTRACT_STATE_TUPLE
const OPEN = 64; // orders still open to more prints
const VENUES = 8; // distinct venues an order counts
const ROW = 19; // f64s a closed row holds (the R_ offsets below)
const MAX_ROWS = 100; // the rows setting's largest value: the ring of closed rows, which Smallest score lists from
// A row: its first print's time, the contract, the side of the quote, size, premium, price times size, prints, venues,
// whether a leg printed above the ask (1) or below the bid (2), the last underlying and IV seen, which of those two it
// holds (bit 2 the underlying, bit 0 the IV), its bar's open, whether a leg came from a bar served in part, the
// contract's repeat hits on its side after its last leg, and the close of the bar it opened on.
const R_TIME = 0;
const R_ROOT = 1;
const R_EXPIRY = 2;
const R_SIDE = 3;
const R_STRIKE = 4;
const R_AGGRESSOR = 5;
const R_SIZE = 6;
const R_PREMIUM = 7;
const R_PX_SIZE = 8;
const R_LEGS = 9;
const R_VENUES = 10;
const R_OUTSIDE = 11;
const R_UNDERLYING = 12;
const R_IV = 13;
const R_HELD = 14;
const R_BAR = 15;
const R_PARTIAL = 16;
const R_REPEAT = 17;
const R_CLOSE = 18;
// Repeat hits: each contract's bursts on each side of the quote (the ask family, a taker's buy on crypto and CME, or the
// bid family) for up to 512 contracts and sides (what the 4 MB of module memory holds beside the inputs' buffers), kept
// as each trade date's three largest: the window's largest burst and whether three bursts reach half of it read exactly
// from them, however many bursts a date holds. A contract and side keeps its place while it holds a burst inside the
// window. One that finds no place, or a date that finds none, reads no repeat hits until the lost bursts leave the
// window: never a count the kept bursts alone would make up.
const KEYS = 512;
const DATES = 6; // the trade dates a contract's bursts are kept by: the window's 5 sessions and one past the newest
const BURST_GAP_MS = 60000.0; // a print 60 s or more after the one before starts a new burst
const SESSIONS = 5; // the sessions a burst counts within
const REPEAT_SHARE = 0.5; // a burst counts at this share of the contract's largest burst's premium or more
const REPEAT_HITS = 3; // the bursts a REPEAT row needs
const MONTHS: StaticArray<string> = ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"];
// A symbol code's characters (0-9 are 1 to 10, A-Z 11 to 36, the dot 37), written one by one so no row allocates.
const CODE_CHARS: StaticArray<string> = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "."];
const rootDigits = new StaticArray<i32>(10);
const orders = new StaticArray<f64>(OPEN * ROW); // the open orders, built like rows
const orderVenues = new StaticArray<f64>(OPEN * VENUES); // each open order's distinct venues
const orderUsed = new StaticArray<bool>(OPEN);
const tape = new StaticArray<f64>(MAX_ROWS * ROW); // the newest rows, a ring
const listedAt = new StaticArray<i32>(MAX_ROWS); // the rows the table lists on the live bar: each one's ring offset,
const listedScore = new StaticArray<f64>(MAX_ROWS); // its score,
const listedOi = new StaticArray<f64>(MAX_ROWS); // the open interest before its day
const listedVolume = new StaticArray<f64>(MAX_ROWS); // and the contract's volume today (NaN where none reads)
const keyRoot = new StaticArray<f64>(KEYS); // the repeat hits' contracts and sides
const keyExpiry = new StaticArray<f64>(KEYS);
const keySide = new StaticArray<f64>(KEYS);
const keyStrike = new StaticArray<f64>(KEYS);
const keyFamily = new StaticArray<f64>(KEYS); // +1 the ask family, -1 the bid family
const keyUsed = new StaticArray<bool>(KEYS);
const burstMs = new StaticArray<f64>(KEYS); // the burst each contract and side prints now: its newest print,
const burstPremium = new StaticArray<f64>(KEYS); // its premium so far
const burstDay = new StaticArray<f64>(KEYS); // and its first print's trade date, NaN before any burst
const keyBlind = new StaticArray<f64>(KEYS); // the newest trade date whose bursts the contract and side lost
const dateDay = new StaticArray<f64>(KEYS * DATES); // each kept trade date, NaN for a free place,
const dateTop = new StaticArray<f64>(KEYS * DATES * 3); // and its three largest finished bursts, largest first, 0 for none
const sessionDays = new StaticArray<f64>(SESSIONS); // the newest trade dates the bars opened on, a ring
burstDay.fill(NaN);
keyBlind.fill(-Infinity);
dateDay.fill(NaN);
let clock = new Clock("UTC"); // a row's time of day on the market's own clock, set in onStart()
let windowMs = 1000.0; // settings, read in onStart()
let blockSize = 500.0;
let unusualPremium = 100000.0;
let largePremium = 100000.0;
let minPremium = 50000.0;
let show = 0;
let rows = 30;
let minScore = -100.0;
let zone = 0; // the market's clock, read in onStart()
let head = 0; // the ring's next slot, and how many slots hold a row
let stored = 0;
let sessionHead = 0; // the session ring's next slot, and how many it holds
let sessionsHeld = 0;
let barSweeps = 0; // this bar's sweeps and their lean, for the outputs
let barSweepLean = 0.0;
let lastPartialMs: f64 = NaN; // the open of the newest bar served in part
let lastDay: f64 = NaN; // the newest bar's trade date on the market's clock, and the one before it
let priorDay: f64 = NaN;
let tableBlind: f64 = -Infinity; // the newest trade date a print found no place for its contract and side
let rowPriorOi: f64 = NaN; // what readOi() read for a row: the open interest before its day,
let rowVolumeToday: f64 = NaN; // and the contract's volume today
function onStart(): void {
windowMs = f64(p_window_ms());
zone = i32(p_market_zone());
blockSize = sizeUnit(i32(p_market_kind()), p_market_point_value(), zone) == 1 ? p_block_coins() : f64(p_block_size()); // coins on a crypto chart
unusualPremium = p_unusual_premium();
largePremium = p_large_premium();
minPremium = p_min_premium();
show = i32(p_show());
rows = i32(p_rows());
minScore = p_min_score();
clock = new Clock(SESSION_TZ_IDS[zone]);
}
// +1 bullish, -1 bearish, 0 neutral, from the contract's side (+1 call, -1 put) and the side of the quote.
function leanOf(sideCp: f64, aggressor: f64): i32 {
if (aggressor == 1.0) return sideCp > 0.0 ? 1 : -1;
if (aggressor == -1.0) return sideCp > 0.0 ? -1 : 1;
return 0;
}
// 2 a sweep (two venues or more), 1 a split (one venue), 3 a block (one print of the block size), 0 one print.
function kindOf(row: StaticArray<f64>, at: i32): i32 {
if (row[at + R_LEGS] >= 2.0) return row[at + R_VENUES] >= 2.0 ? 2 : 1;
return row[at + R_SIZE] >= blockSize ? 3 : 0;
}
// ── Repeat hits ──
// A trade date into the session ring, and the oldest one it holds: a burst counts from that date on.
function pushSession(day: f64): void {
sessionDays[sessionHead] = day;
sessionHead = (sessionHead + 1) % SESSIONS;
if (sessionsHeld < SESSIONS) sessionsHeld += 1;
}
function oldestSession(): f64 {
if (sessionsHeld == 0) return -Infinity;
return sessionsHeld < SESSIONS ? sessionDays[0] : sessionDays[sessionHead];
}
// Whether a contract and side's place holds nothing inside the window (a trade date from `from` on): free to take.
function keyFree(k: i32, from: f64): bool {
if (!keyUsed[k]) return true;
if (burstDay[k] >= from || keyBlind[k] >= from) return false;
for (let j = 0; j < DATES; j += 1) if (dateDay[k * DATES + j] >= from) return false;
return true;
}
// A finished burst of `premium` from trade date `day` into its date's three largest. A date with no place left (every
// place holds a date inside the window) takes the oldest date's place, and the contract and side reads no repeat hits
// until that date leaves the window.
function keepBurst(k: i32, day: f64, premium: f64, from: f64): void {
const base = k * DATES;
let at = -1;
let open = -1;
let oldest = -1;
for (let j = 0; j < DATES && at < 0; j += 1) {
const held = dateDay[base + j];
if (held == day) at = j;
else if (!(held >= from)) {
if (open < 0) open = j;
} else if (oldest < 0 || held < dateDay[base + oldest]) oldest = j;
}
if (at < 0) {
at = open >= 0 ? open : oldest;
if (open < 0 && dateDay[base + at] > keyBlind[k]) keyBlind[k] = dateDay[base + at]; // a date inside the window lost
dateDay[base + at] = day;
for (let t = 0; t < 3; t += 1) dateTop[(base + at) * 3 + t] = 0.0;
}
const top = (base + at) * 3;
if (premium > dateTop[top]) {
dateTop[top + 2] = dateTop[top + 1];
dateTop[top + 1] = dateTop[top];
dateTop[top] = premium;
} else if (premium > dateTop[top + 1]) {
dateTop[top + 2] = dateTop[top + 1];
dateTop[top + 1] = premium;
} else if (premium > dateTop[top + 2]) dateTop[top + 2] = premium;
}
// A print of `premium` at `ms` into its contract's bursts on its side (`family`), and the contract's repeat hits after
// it, counted to three: its bursts within the last 5 sessions that hold at least half the premium of the largest of
// them. The burst it prints now and each kept date's three largest hold the largest and, while fewer than three reach
// half of it, every one that does; 0 while the contract and side has lost a burst inside the window.
function repeatHits(root: f64, expiry: f64, sideCp: f64, strike: f64, family: f64, ms: f64, premium: f64): i32 {
const from = oldestSession();
const day = optionsTradeDay(ms, zone);
let k = -1;
for (let i = 0; i < KEYS && k < 0; i += 1) {
if (keyUsed[i] && keyStrike[i] == strike && keyExpiry[i] == expiry && keySide[i] == sideCp && keyRoot[i] == root && keyFamily[i] == family) k = i;
}
if (k < 0) { // a contract and side not held: the first place that holds nothing inside the window
for (let i = 0; i < KEYS && k < 0; i += 1) if (keyFree(i, from)) k = i;
if (k < 0) { // none: this one is not kept, and a contract and side taken on later may have printed before
if (day > tableBlind) tableBlind = day;
return 0;
}
keyUsed[k] = true;
keyRoot[k] = root;
keyExpiry[k] = expiry;
keySide[k] = sideCp;
keyStrike[k] = strike;
keyFamily[k] = family;
burstDay[k] = NaN;
keyBlind[k] = tableBlind >= from ? tableBlind : -Infinity;
for (let j = 0; j < DATES; j += 1) dateDay[k * DATES + j] = NaN;
}
if (!isNaN(burstDay[k]) && ms - burstMs[k] < BURST_GAP_MS) { // within 60 s of its last print: the same burst
burstMs[k] = ms;
burstPremium[k] += premium;
} else {
if (burstDay[k] >= from) keepBurst(k, burstDay[k], burstPremium[k], from);
burstMs[k] = ms;
burstPremium[k] = premium;
burstDay[k] = day;
}
if (keyBlind[k] >= from) return 0;
const now = burstDay[k] >= from ? burstPremium[k] : 0.0;
let largest = now;
for (let j = 0; j < DATES; j += 1) {
if (!(dateDay[k * DATES + j] >= from)) continue;
const top = dateTop[(k * DATES + j) * 3];
if (top > largest) largest = top;
}
let hits = now > 0.0 && now >= largest * REPEAT_SHARE ? 1 : 0;
for (let j = 0; j < DATES; j += 1) {
if (!(dateDay[k * DATES + j] >= from)) continue;
for (let t = 0; t < 3; t += 1) {
const held = dateTop[(k * DATES + j) * 3 + t];
if (held > 0.0 && held >= largest * REPEAT_SHARE) hits += 1;
}
}
return hits < REPEAT_HITS ? hits : REPEAT_HITS;
}
// ── Merging prints into orders ──
// An order leaves the open list: into the tape when it passes the table's filters.
function closeOrder(o: i32): void {
orderUsed[o] = false;
const at = o * ROW;
if (!(orders[at + R_PREMIUM] >= minPremium)) return;
const kind = kindOf(orders, at);
if ((show == 1 && kind == 0) || (show == 2 && kind != 2)) return;
if (kind == 2) {
barSweeps += 1;
const lean = leanOf(orders[at + R_SIDE], orders[at + R_AGGRESSOR]);
if (lean > 0) barSweepLean += orders[at + R_PREMIUM];
else if (lean < 0) barSweepLean -= orders[at + R_PREMIUM];
}
const base = head * ROW;
for (let f = 0; f < ROW; f += 1) tape[base + f] = orders[at + f];
head = (head + 1) % MAX_ROWS;
if (stored < MAX_ROWS) stored += 1;
}
// Every order whose window has passed by `nowMs` closes, oldest first; with `all`, every order closes.
function closeDue(nowMs: f64, all: bool): void {
for (;;) {
let oldest = -1;
for (let o = 0; o < OPEN; o += 1) {
if (orderUsed[o] && (oldest < 0 || orders[o * ROW + R_TIME] < orders[oldest * ROW + R_TIME])) oldest = o;
}
if (oldest < 0 || (!all && orders[oldest * ROW + R_TIME] + windowMs >= nowMs)) return;
closeOrder(oldest);
}
}
// The print at offset `at` of the block joins its open order, or opens one; it also runs into its contract's bursts.
function take(cells: StaticArray<f64>, at: i32, barMs: f64, partial: bool, close: f64): void {
const ms = barMs + cells[at];
closeDue(ms, false);
const root = cells[at + 2];
const expiry = cells[at + 3];
const sideCp = cells[at + 4];
const strike = cells[at + 5];
const aggressor = cells[at + 9];
let o = -1;
for (let k = 0; k < OPEN; k += 1) {
const kb = k * ROW;
if (orderUsed[k] && orders[kb + R_STRIKE] == strike && orders[kb + R_EXPIRY] == expiry && orders[kb + R_SIDE] == sideCp && orders[kb + R_ROOT] == root && orders[kb + R_AGGRESSOR] == aggressor) {
o = k;
break;
}
}
if (o < 0) {
for (let k = 0; k < OPEN && o < 0; k += 1) if (!orderUsed[k]) o = k;
if (o < 0) { // every slot is open: the oldest order closes first
let oldest = 0;
for (let k = 1; k < OPEN; k += 1) if (orders[k * ROW + R_TIME] < orders[oldest * ROW + R_TIME]) oldest = k;
closeOrder(oldest);
o = oldest;
}
const fresh = o * ROW;
for (let f = 0; f < ROW; f += 1) orders[fresh + f] = 0.0;
orders[fresh + R_TIME] = ms;
orders[fresh + R_ROOT] = root;
orders[fresh + R_EXPIRY] = expiry;
orders[fresh + R_SIDE] = sideCp;
orders[fresh + R_STRIKE] = strike;
orders[fresh + R_AGGRESSOR] = aggressor;
orders[fresh + R_BAR] = barMs;
orders[fresh + R_CLOSE] = close;
orderUsed[o] = true;
}
const b = o * ROW;
const size = cells[at + 7];
const present = cells[at + 15];
orders[b + R_SIZE] += size;
orders[b + R_PREMIUM] += cells[at + 8];
orders[b + R_PX_SIZE] += cells[at + 6] * size;
orders[b + R_LEGS] += 1.0;
if (partial) orders[b + R_PARTIAL] = 1.0;
if (hasBit(present, 3)) { // bit 3: the quote was valid, so outside says where the leg printed
const outside = cells[at + 10];
const flags = i32(orders[b + R_OUTSIDE]);
if (outside > 0.0) orders[b + R_OUTSIDE] = f64(flags | 1);
else if (outside < 0.0) orders[b + R_OUTSIDE] = f64(flags | 2);
}
const held = i32(orders[b + R_HELD]);
if (hasBit(present, 2)) { // bit 2: the underlying
orders[b + R_UNDERLYING] = cells[at + 11];
orders[b + R_HELD] = f64(held | 4);
}
if (hasBit(present, 0)) { // bit 0: the IV, percent
orders[b + R_IV] = cells[at + 12];
orders[b + R_HELD] = f64(i32(orders[b + R_HELD]) | 1);
}
const venue = cells[at + 14];
const seen = i32(orders[b + R_VENUES]);
let known = false;
for (let v = 0; v < seen; v += 1) if (orderVenues[o * VENUES + v] == venue) known = true;
if (!known && seen < VENUES) {
orderVenues[o * VENUES + seen] = venue;
orders[b + R_VENUES] = f64(seen + 1);
}
// The ask family (a taker's buy) or the bid family (a taker's sale); the mid and an unquoted print count no hit.
const family = aggressor == 1.0 ? 1.0 : aggressor == -1.0 ? -1.0 : 0.0;
if (family != 0.0) orders[b + R_REPEAT] = f64(repeatHits(root, expiry, sideCp, strike, family, ms, cells[at + 8]));
}
// ── The table ──
// The characters of a symbol code into rootDigits, last first, and their count; 0 for anything no symbol encodes to.
function rootLength(code: f64): i32 {
if (!(code >= 1.0) || code > 6278211847988223.0 || code != Math.floor(code)) return 0;
let rest = u64(code);
let count = 0;
while (rest > 0) {
const value = i32(rest % 38);
if (value == 0 || count == 10) return 0;
rootDigits[count] = value;
count += 1;
rest = rest / 38;
}
return count;
}
function fbRoot(code: f64): void { // the option root as listed, or ? when the code names none
const count = rootLength(code);
if (count == 0) fb_text("?");
for (let i = count - 1; i >= 0; i -= 1) fb_text(CODE_CHARS[rootDigits[i] - 1]);
}
function fbPad(value: i32): void { // two digits, zero first
if (value < 10) fb_text("0");
fb_int(value);
}
function fbStrike(strike: f64): void { // 450, 452.5, 1.25: the strike as listed
fb_f64(strike, strike == Math.floor(strike) ? 0 : strike * 10.0 == Math.floor(strike * 10.0) ? 1 : 2);
}
function fbContract(base: i32, nowMs: f64): void { // "SPY 450C 21 Nov": the root, the strike, call or put, the expiry's date (15 Jan '27 in another year)
fb_text("\"");
fbRoot(tape[base + R_ROOT]);
fb_text(" ");
fbStrike(tape[base + R_STRIKE]);
fb_text(tape[base + R_SIDE] > 0.0 ? "C " : "P ");
fbExpiryLabel(tape[base + R_EXPIRY], nowMs, zone);
fb_text("\"");
}
function fbTime(ms: f64, todayKey: i32): void { // 15:59:58 today, 16OCT 15:59 on an earlier day, on the market's clock
clock.update(Math.floor(ms / 1000.0));
const today = clock.dayKey() == todayKey;
fb_text("\"");
if (!today) {
fbPad(clock.dayOfMonth());
fb_text(MONTHS[clock.month() - 1]);
fb_text(" ");
}
fbPad(clock.hour());
fb_text(":");
fbPad(clock.minute());
if (today) {
fb_text(":");
fbPad(clock.second());
}
fb_text("\"");
}
// The chain summary's row for a contract: its offset into the block, or -1 when the summary does not hold it.
function stateOf(cells: StaticArray<f64>, n: i32, base: i32): i32 {
const strike = tape[base + R_STRIKE];
const expiry = tape[base + R_EXPIRY];
const sideCp = tape[base + R_SIDE];
const root = tape[base + R_ROOT];
for (let i = 0; i + STATE - 1 < n; i += STATE) {
if (cells[i + 3] == strike && cells[i + 1] == expiry && cells[i + 2] == sideCp && cells[i] == root) return i;
}
return -1;
}
// A row's open interest before its day and the contract's volume today, into rowPriorOi and rowVolumeToday (NaN where
// none reads): the summary's open interest for today's rows, the prior day's for the trade date before; volume today
// for today's rows only. A crypto chain's open interest is live: there the prior UTC day's stands for today's rows and
// the day before has none.
function readOi(base: i32, state: StaticArray<f64>, n: i32, today: f64): void {
const day = optionsTradeDay(tape[base + R_TIME], zone);
const at = n > 0 && (day == today || day == priorDay) ? stateOf(state, n, base) : -1;
rowPriorOi = NaN;
rowVolumeToday = NaN;
if (at < 0) return;
const present = state[at + 12];
const before = zone == 0 ? 11 : 10; // bit 10 the open interest, bit 11 the prior day's: each its column's index
if (day == today) {
if (hasBit(present, before)) rowPriorOi = state[at + before];
if (hasBit(present, 9)) rowVolumeToday = state[at + 9]; // bit 9: contracts today
} else if (zone != 0 && hasBit(present, 11)) rowPriorOi = state[at + 11]; // bit 11: the prior day's, for the trade date before
}
// 0 out of the money, 1 at the money (the strike within 0.5% of the underlying), 2 in the money; out without a price.
function moneynessOf(sideCp: f64, strike: f64, spot: f64): i32 {
if (!(spot > 0.0)) return 0;
if (Math.abs(strike - spot) <= spot * 0.005) return 1;
return (sideCp > 0.0 ? strike > spot : strike < spot) ? 0 : 2;
}
// A row's score: the side as the Side cell reads it (AA +2, A +1, M and a dash 0, B -1, BB -2), call or put, the
// moneyness against its underlying (the close of the bar it opened on where no leg carried one), its days to expiry,
// its size over the open interest before its day (NaN, read as past it, where none reads) and its repeat hits.
function scoreOf(base: i32, priorOi: f64): f64 {
const aggressor = tape[base + R_AGGRESSOR];
const flags = i32(tape[base + R_OUTSIDE]);
const outside = aggressor == 1.0 && (flags & 1) != 0 ? 1.0 : aggressor == -1.0 && (flags & 2) != 0 ? -1.0 : 0.0;
const sideCp = tape[base + R_SIDE];
const spot = (i32(tape[base + R_HELD]) & 4) != 0 ? tape[base + R_UNDERLYING] : tape[base + R_CLOSE];
const dte = optionsTradeDay(tape[base + R_EXPIRY], zone) - optionsTradeDay(tape[base + R_TIME], zone);
const sizeVsOi = isNaN(priorOi) ? NaN : tape[base + R_SIZE] / priorOi;
return flowScore(flowSideCode(aggressor, outside), sideCp, moneynessOf(sideCp, tape[base + R_STRIKE], spot), dte, sizeVsOi, i32(tape[base + R_REPEAT]));
}
// Whether Smallest score lists a row: -100 or 0 every row; above 0 a score at least that far from 0 either way; below 0
// a score at or below it.
function scoreKept(score: f64): bool {
if (minScore <= -100.0 || minScore == 0.0) return true;
return minScore > 0.0 ? Math.abs(score) >= minScore : score <= minScore;
}
// The row's tags into the frame, and whether it reads UNUSUAL, from the open interest before its day and the
// contract's volume today (readOi).
function fbTags(base: i32, priorOi: f64, volumeToday: f64, today: f64): bool {
const day = optionsTradeDay(tape[base + R_TIME], zone);
const opening = !isNaN(priorOi) && tape[base + R_SIZE] > priorOi;
const large = opening && tape[base + R_PREMIUM] >= largePremium;
const volOverOi = !isNaN(priorOi) && !isNaN(volumeToday) && volumeToday > priorOi;
const repeat = tape[base + R_REPEAT] >= f64(REPEAT_HITS);
const spot = tape[base + R_UNDERLYING];
const strike = tape[base + R_STRIKE];
const sideCp = tape[base + R_SIDE];
const otm = (i32(tape[base + R_HELD]) & 4) != 0 && spot > 0.0 && (sideCp > 0.0 ? strike >= spot * 0.995 : strike <= spot * 1.005);
const dte = optionsTradeDay(tape[base + R_EXPIRY], zone) - day;
const unusual = day == today && volOverOi && otm && dte <= 60.0 && tape[base + R_AGGRESSOR] == 1.0 && tape[base + R_PREMIUM] >= unusualPremium;
fb_text(unusual ? "{\"text\":\"" : "\"");
let words = 0;
if (opening) {
fb_text("OPEN");
words += 1;
}
if (large) {
fb_text(" OPEN+"); // an OPEN row: never the first word
words += 1;
}
if (volOverOi) {
fb_text(words > 0 ? " VOL>OI" : "VOL>OI");
words += 1;
}
if (repeat) {
fb_text(words > 0 ? " REPEAT" : "REPEAT");
words += 1;
}
if (unusual) {
fb_text(words > 0 ? " UNUSUAL" : "UNUSUAL");
fb_text("\",\"font_weight\":\"bold\"}");
} else fb_text("\"");
return unusual;
}
// The score cell, the row's lean by its sign: the number in the up colour above 0 (bullish), the down colour below
// (bearish), muted at 0 (neutral), bold from 60 either way.
function fbScore(score: f64): void {
fb_text("{\"value\":");
fb_num(score);
fb_text(score > 0.0 ? ",\"text_color\":\"theme.up\"" : score < 0.0 ? ",\"text_color\":\"theme.down\"" : ",\"text_color\":\"theme.muted\"");
fb_text(Math.abs(score) >= 60.0 ? ",\"font_weight\":\"bold\"}" : "}");
}
// The contract a row names so the chart can open it: a US listed contract (OPRA, on the New York zone's charts) with a
// root of 1 to 6 characters, an expiry, a call or a put and a strike below 100,000; any other row names no market.
function fbMarket(base: i32): void {
const count = rootLength(tape[base + R_ROOT]);
const strike = tape[base + R_STRIKE];
if (zone != 1 || count < 1 || count > 6 || !(tape[base + R_EXPIRY] > 0.0) || !(strike > 0.0) || strike >= 100000.0) fb_text("null");
else fb_contract(tape[base + R_ROOT], tape[base + R_EXPIRY], tape[base + R_SIDE] > 0.0 ? 1.0 : -1.0, strike);
}
function slotOf(k: i32): i32 { // the ring slot of the k-th newest row
return ((head - 1 - k + MAX_ROWS * 2) % MAX_ROWS) * ROW;
}
function writeTable(nowMs: f64): void {
clock.update(Math.floor(nowMs / 1000.0));
const todayKey = clock.dayKey();
const today = optionsTradeDay(nowMs, zone);
const n = in_state_cells();
const state = in_state_view();
// The rows listed: the newest that Smallest score keeps, up to Table rows.
let filled = 0;
for (let k = 0; k < stored && filled < rows; k += 1) {
const base = slotOf(k);
readOi(base, state, n, today);
const score = scoreOf(base, rowPriorOi);
if (!scoreKept(score)) continue;
listedAt[filled] = base;
listedScore[filled] = score;
listedOi[filled] = rowPriorOi;
listedVolume[filled] = rowVolumeToday;
filled += 1;
}
const oldestBarMs = filled > 0 ? tape[listedAt[filled - 1] + R_BAR] : NaN;
let unusualRows = 0;
fb_clear();
fb_text("{\"rows\":[");
for (let k = 0; k < filled; k += 1) {
const base = listedAt[k];
const sideCp = tape[base + R_SIDE];
const aggressor = tape[base + R_AGGRESSOR];
const lean = leanOf(sideCp, aggressor);
const kind = kindOf(tape, base);
const outside = i32(tape[base + R_OUTSIDE]);
if (k > 0) fb_text(",");
fb_text("[");
fbTime(tape[base + R_TIME], todayKey);
fb_text(",");
fbContract(base, nowMs);
fb_text(",");
fb_f64(optionsTradeDay(tape[base + R_EXPIRY], zone) - optionsTradeDay(tape[base + R_TIME], zone), 0);
fb_text(kind == 2 ? ",{\"text\":\"SWEEP\",\"font_weight\":\"bold\"}," : kind == 1 ? ",\"SPLIT\"," : kind == 3 ? ",{\"text\":\"BLOCK\",\"font_weight\":\"bold\"}," : ",\"-\",");
fb_text("{\"text\":\"");
if (aggressor == 1.0) fb_text((outside & 1) != 0 ? "AA" : "A");
else if (aggressor == -1.0) fb_text((outside & 2) != 0 ? "BB" : "B");
else if (aggressor == 0.0) fb_text("M");
else fb_text("-");
fb_text(lean > 0 ? "\",\"text_color\":\"theme.up\"}," : lean < 0 ? "\",\"text_color\":\"theme.down\"}," : "\",\"text_color\":\"theme.muted\"},");
fb_f64(tape[base + R_SIZE], tape[base + R_SIZE] == Math.floor(tape[base + R_SIZE]) ? 0 : 4); // whole contracts bare, a coin size to four decimals
fb_text(",");
fb_num(tape[base + R_SIZE] > 0.0 ? tape[base + R_PX_SIZE] / tape[base + R_SIZE] : NaN);
fb_text(tape[base + R_PREMIUM] >= unusualPremium ? ",{\"value\":" : ","); // bold from the unusual premium up, so a big order stands out
fb_f64(tape[base + R_PREMIUM], 0);
fb_text(tape[base + R_PREMIUM] >= unusualPremium ? ",\"font_weight\":\"bold\"}," : ",");
if ((i32(tape[base + R_HELD]) & 4) != 0) fb_num(tape[base + R_UNDERLYING]);
else fb_text("\"\"");
fb_text(",\"");
fb_int(i64(tape[base + R_LEGS]));
if (tape[base + R_LEGS] >= 2.0) {
fb_text(" on ");
fb_int(i64(tape[base + R_VENUES]));
fb_text(tape[base + R_VENUES] >= 2.0 ? " exchanges" : " exchange");
}
if (tape[base + R_PARTIAL] > 0.0) fb_text(", in part");
fb_text("\",");
if (fbTags(base, listedOi[k], listedVolume[k], today)) unusualRows += 1;
fb_text(",");
fbScore(listedScore[k]);
fb_text("]");
}
fb_text("],\"markets\":[");
for (let k = 0; k < filled; k += 1) {
if (k > 0) fb_text(",");
fbMarket(listedAt[k]);
}
fb_text("],\"title\":\"Flow tape, ");
fb_int(filled);
fb_text(filled == 1 ? " order" : " orders");
if (unusualRows > 0) {
fb_text(", ");
fb_int(unusualRows);
fb_text(" unusual");
}
fb_text("\",\"caption\":\"");
if (filled == 0) fb_text("No order passes the filters yet");
else if (lastPartialMs >= oldestBarMs) fb_text("Some bars here are incomplete: orders may lack trades");
else {
fb_text("Newest first, ");
fb_text(SESSION_TZ_LABELS[zone]); // New York, Chicago or UTC
fb_text(zone == 0 ? "" : " time");
fb_text(zone == 1 ? ", sweeps estimated" : ", one exchange, no sweeps"); // a crypto or CME chain trades on one venue
}
fb_text("\"}");
writeFrameBuffer(tape_rows);
}
// onBar() runs once per bar: the orders whose window passed before the bar opened close; the bar's prints merge into
// orders in time order; the outputs on every bar; on the live bar every open order closes into the table (the chart
// restores the state before the next tick, so an order still open keeps merging).
function onBar(): void {
const barMs = bar.time() * 1000.0;
const day = optionsTradeDay(barMs, zone);
if (day != lastDay) {
if (!isNaN(lastDay)) priorDay = lastDay;
lastDay = day;
pushSession(day);
}
barSweeps = 0;
barSweepLean = 0.0;
closeDue(barMs, false);
const n = in_prints_cells();
let partial = false;
if (n > 0) {
const cells = in_prints_view();
const close = bar.close();
for (let i = 0; i + PRINT - 1 < n; i += PRINT) if (isPartial(cells[i + 15])) partial = true;
for (let i = 0; i + PRINT - 1 < n; i += PRINT) {
if (!(cells[i + 7] > 0.0) || !(cells[i + 8] > 0.0)) continue; // the chart's marker for a bar served in part, never a print
take(cells, i, barMs, partial, close);
}
}
if (partial) lastPartialMs = barMs;
if (bar.isLast()) {
closeDue(barMs, true);
writeTable(barMs);
}
out_sweeps(n < 0 || zone != 1 ? NaN : f64(barSweeps)); // one venue (crypto, CME): no sweep to count
out_sweep_lean(n < 0 || zone != 1 ? NaN : barSweepLean);
out_partial(n < 0 ? NaN : partial ? 1.0 : 0.0);
}How it works
The kinds are inferred. The data does not carry the exchanges' trade conditions (the code an exchange stamps on an intermarket sweep, a floor trade or a cross), so the tape infers each order's kind from the prints themselves: the same contract, the same side of the quote, and how many prints and venues an order took. A sweep here is an order that took the best price on two venues or more within the window; a split took several prints on one venue; a block is one print of at least Block size (500 contracts, on a US stock and on CME) or, on a crypto chart, Block size, coins (25); each setting shows only on the charts whose size unit it counts (visible_by), and the package picks one through sizeUnit over market.size_unit(). The caption says so, naming the market's clock: "Newest first, New York time, sweeps estimated" on a US stock. A crypto or CME chain trades on one venue (its prints carry venue 0), so no order there can sweep: an order of several prints is a split, sweeps and sweep_lean read NaN rather than 0, and the caption reads "Newest first, Chicago time, one exchange, no sweeps" on CME and "Newest first, UTC, one exchange, no sweeps" on crypto.
Prints merge into orders. A print joins the open order with the same contract (root, expiry, call or put, strike) and the same side of the quote (aggressor) whose first print is within Merge window, ms (1,000) of it; otherwise it opens a new order. An order closes once a print, or a bar's open, comes later than its window: the oldest order first, and the oldest when a 65th order would open. An order sums its contracts and its premium, counts its prints and up to eight distinct venues, keeps the volume-weighted average price of its legs, and keeps the last underlying and IV a leg carried. On the live bar every open order closes into the table; the chart restores the state before the next tick, so an order still inside its window keeps merging.
The side of an order. The data plane judges each print against the national best bid and offer just before it, by the midpoint: above the mid it is at the ask, below it at the bid, exactly on it at the mid, and with no valid quote it has no side. An order's side cell reads A, B, M or a dash, and AA when one of its legs printed above the ask or BB when one printed below the bid (judged only where the quote was valid, bit 3). On a crypto or CME chain the venue names the taker instead: A the taker bought, B it sold. The lean reads the side against the contract: a call at the ask or a put at the bid leans bullish, a call at the bid or a put at the ask bearish, the mid and no side neutral; the side cell and the score take the chart's up colour, its down colour or the muted ink by it.
The open interest tags. The chain summary on the newest bar carries each contract's open interest (oi, bit 10), the prior observation (oi_prev, bit 11) and its contracts today (volume_day, bit 9). The open interest before an order's day is the summary's oi for an order of the newest bar's trade date, and its oi_prev for an order of the trade date before it; older orders read no open interest tag. A crypto chain's oi is live, so there the prior UTC day's (oi_prev) stands for today's orders, and an order of the trade date before reads no open interest tag. OPEN: the order's size exceeds that open interest, so not all of it can be closing. VOL>OI, for today's orders: the contract's volume today has passed its open interest. A contract the summary does not hold (an expiry past the twelve nearest, or a strike more than 25% from the underlying: expiries: "nearest:12", strike_window_pct: 25) reads neither tag.
OPEN+, a large opening order. A row reads OPEN+ beside OPEN when it is an OPEN row (its size past the open interest before its day) whose premium is at least Large opening premium, USD (100,000). A row that is not OPEN never reads OPEN+, however large.
REPEAT, the same contract hit again and again. Every print of 5,000 and up runs into its contract's bursts on its side of the quote: the ask family (A and AA, or a taker's buy on crypto and CME) or the bid family (B and BB, or a taker's sale); a print at the mid or with no quote counts in neither. A print 60 seconds or more after the contract's last one on that side starts a new burst, and one sooner joins it. A row reads REPEAT when, after its last leg, the contract holds three bursts or more on the row's side within the last five sessions (the five newest trade dates the chart's bars opened on), each counted burst holding at least half the premium of the largest of them. The tape keeps each trade date's three largest bursts of a contract on each side, which is all the rule needs: the window's largest burst is among them, and so is every burst that reaches half of it while fewer than three do, however many bursts the contract printed. It keeps up to 512 contracts and sides, each holding its place while it holds a burst inside the window. A contract that finds every place taken, or a seventh trade date inside the window for one contract, reads no REPEAT until the bursts it could not keep leave the window, rather than counting from part of them. The tape sees only the prints the chart serves (three days of them).
The score. The last column is the row's flow score, the options kit's flowScore (Flow score), from -100 to 100: flowSideCode of the side as the Side cell reads it (AA +2, A +1, M and a dash 0, B -1, BB -2), call or put, the moneyness against the row's last underlying (at the money within 0.5%; the close of the bar the order opened on when no leg carried one), its days to expiry, its size over the open interest before its day (read as past it when the summary holds none) and its repeat hits (three or more add 10). Its sign is the lean: a bought call or a sold put scores above 0 in the up colour, a sold call or a bought put below 0 in the down colour, the mid 0 in the muted ink, and the cell turns bold from 60 either way. The Score column prints one decimal with its sign (+80.0, -68.8 for -68.85). Smallest score (-100 to 100) picks the rows: -100, the default, or 0 lists every row; a value above 0 lists the rows scoring at least that far from 0 either way (60 lists the rows of 60 and up and of -60 and below); a value below 0 lists only the rows scoring at or below it (-40 lists the bearish rows of -40 and below).
UNUSUAL, this tape's own rule. An order reads UNUSUAL when all of these hold: it is from today, its contract reads VOL>OI, it printed on the ask side (A or AA), it is out of the money against its last underlying (a call struck at or above 99.5% of it, a put at or below 100.5%), its expiry is within 60 days of the order's trade date, and its premium is at least Unusual premium, USD (100,000). The tags cell then turns bold, and the title counts the unusual rows (Flow tape, 30 orders, 2 unusual).
The table. Closed orders at or above Smallest premium, USD (50,000) enter a ring of the 100 newest; Show keeps every order, only sweeps, splits and blocks, or only sweeps (none on a crypto or CME chain). The table is rewritten on the live bar, newest first, with the newest Orders listed (30, up to 100) that Smallest score keeps: the first print's time on the market's clock (market.zone(): New York on a US stock, Chicago on a CME future, UTC on crypto; hours, minutes and seconds on the newest bar's trade date, the day, the month, hours and minutes before it), the contract (SPY 450C 21 Nov; an expiry in another year reads its year, SPY 450C 15 Jan '27), its days to expiry on the same clock, the kind (SWEEP and BLOCK in bold, SPLIT, or a dash for one print), the side, the size (whole contracts bare, a fractional size, a coin's, to four decimals), the average price, the premium, the underlying's price (empty without one), the prints and venues (4 on 3 exchanges, with , in part when a leg came from a bar served in part), the tags and the score. A table holds at most twelve columns, so the score stands where a lean word would: its sign and its ink are the lean.
Rows that name their contract. The frame's markets list holds one entry per row, in the rows' order, the order's contract written with fb_contract(root_code, expiry_ms, side_cp, strike). A row whose root does not decode to 1 to 6 characters, or whose strike is not above 0 and below 100,000, names no market (null) and reads ? where the root would be. A row names a market on a US stock chart only (market.zone() 1, New York): a row's market is a US listed (OSI) contract and one bad entry fails the whole frame, so on any other market every row names no market.
The readings. Three data-only outputs on every bar: sweeps (the sweep rows at or above the smallest premium that closed on the bar), sweep_lean (their bullish premium minus their bearish premium, USD) and partial (1 on a bar the chart served in part). Each reads NaN on a bar the chart served no block for, and the two sweep readings read NaN on a crypto or CME chart, where no order sweeps.
What the settings do
- Merge window, ms: Trades in one contract and side within this many milliseconds count as one order.
- Block size: One trade of at least this many contracts reads BLOCK on US stocks and CME.
- Block size, coins: One trade of at least this many coins reads BLOCK on a crypto chart.
- Unusual premium, USD: The smallest premium (the money paid) an order needs to read UNUSUAL.
- Large opening premium, USD: An OPEN order with at least this premium also reads OPEN+, a large new position.
- Smallest premium, USD: Hides orders with less premium (the money paid) than this, from $5,000 up.
- Show: Lists every order, only sweeps, splits (several trades on one exchange) and blocks, or only sweeps.
- Orders listed: How many of the newest orders the table shows, from 5 to 100.
- Smallest score: At -100 or 0 it keeps every order. At 40 it keeps scores of 40 and above or -40 and below, at -40 only -40 and below.
Where it runs
On crypto, it reads each coin's own listed options, with sizes in coins. A copy you run from the editor (where you write and run indicators) reads them too (Data sources). On a US stock or ETF with listed options, every indicator in your browser can read them. They are real time if you have real-time US options data, and 15 minutes behind otherwise. On a CME futures chart, every indicator in your browser can read them too, once you accept the CME market data terms (Limitations). It also reads the options summary, each contract's open interest (contracts still held open) and volume today. Alerts and Protected indicators (published ones that run on OpenMarket's servers) cannot read these trades or that summary. On an option contract's own chart, it reads the symbol behind that contract, so the tape matches the stock's chart. The indicator stops if the options summary holds over 16,000 contracts, rather than read only part of them. CME prints are 10 minutes behind unless you have real-time CME data, and crypto has no delay. The legend shows which delay applies.
When data is missing
- No data yet. A bar older than the three days the chart loads has no data. In the Console (the editor's prompt that shows a reading by its name), its three readings stay blank. They are the sweep count (
sweeps), the sweeps' lean (sweep_lean) and the incomplete-bar flag (partial). - A quiet bar. A bar with no trade of $5,000 or more adds nothing. Orders whose window has passed still close on it. The chart loads the 2,000 newest trades of $5,000 and up. It adds every trade up to 1 second before the oldest of them, which keeps each order's trades together. An older bar arrives empty, so there the Console reads 0 for
sweepsandsweep_lean. - A bar older than the stored history. OpenMarket keeps a limited trade history, and it flags older bars. An empty one arrives as a single empty marker, which never joins an order. In the Console,
partialreads 1 there. An order with a trade from that bar ends its Prints column with "in part". The caption reads "Some bars here are incomplete: orders may lack trades". It shows while such a bar sits among the listed orders. A trade under $5,000 of premium (the money paid) never arrives. So a sweep of smaller trades shows only its larger ones. - No options summary. Without the summary on the newest bar, no order reads OPEN, OPEN+, VOL>OI or UNUSUAL. Each score then counts the order's size as larger than the open interest (contracts still held open). The kinds, REPEAT and the rest of each order stay the same.
- Nothing passes the filters. The table lists no order, and its caption reads "No order passes the filters yet".
Customize it
- A tighter merge. Lower Merge window to 250 ms: only legs that printed together merge, which is how a sweep across venues usually prints.
- The sweep tape. On a US stock chart, set Show to sweeps only and Smallest premium to 100,000: the urgent orders that went venue to venue.
- Bigger blocks. Raise Block size to 2,000 on an index or a large ETF, where 500 contracts is an ordinary print; on a crypto chart, raise Block size, coins on ETH, where 25 coins is a small print.
- The strong flow only. Set Smallest score to 60: the rows that bought or sold with conviction either way, the bold scores. Set it to -60 for the bearish ones alone.
- Larger opening orders. Raise Large opening premium to 500,000 on SPY, where an opening order of 100,000 is common.
Run it
- In the editor's Explorer, press the Templates icon ("Browse starter templates") and pick Flow Tape under Order flow.
- Press Run on a chart whose underlying lists options, a US stock such as SPY, ES1! or a BTC chart: the copy stands the tape under the chart, newest order first. On ES1! the copy reads the prints once you accept the CME market data terms, at your own tier, and the legend names the tier.
- At the editor's Console prompt, type
sweepsandsweep_leanto read the sweeps that closed on the newest bar.
Concepts used
- Data sources for
option_printsandoption_contract_state, their tuples and their knobs, and The present mask and partial bars forhasBit,isPartialand bit 14 - Table and Rows that open a market for
panel.tableover a frame, styled cells andmarkets - Options kit for
optionsTradeDay - Panel frames for
fbExpiryLabel