Flow marks

View as MarkdownOpen the editor

Flow Marks draws big option trades as marks on price, bigger for more premium (the money paid for an option).

Up-colour marks lean bullish, calls (bets on a rise) bought or puts (bets on a fall) sold. Down-colour marks lean bearish, soft dots lean less, and muted ones barely lean. A column under the chart shows each bar's bullish minus bearish premium. Use it on a US stock, coin or CME (Chicago futures exchange) future to see where big bets landed.

Under the hood: a celled option_prints.cells input is cut by the data plane to each bar's largest prints at the smallest premium (Data sources). It holds the types kept and is read through its present mask (The present mask and partial bars). Beside it, five scalar options_flow inputs of scope prints carry the data plane's per-bar sums of every print at that premium (Data sources). Three plot.marks sections with a size law bound to a setting draw the contracts, a crypto chain's coins and the soft dots (Marks). Each mark is toned by its flow score from the options kit's flowSideCode, flowScore and optionsTradeDay (Flow score). It takes the full tone from 60 either way, a soft dot from 20 to 60, and the muted ink under 20. A histogram is coloured per bar by a data-only ladder output (Plotting). A render.bgcolor wash covers the bars the chart served in part (tints). This is also the flow-marks template: the Flow Marks card under Order flow in the editor's starter list, and it compiles as written.

The wrun indicator

// Flow Marks: the large option trades on this symbol, drawn as marks on the price where they traded. A print is one
// option trade, and a bigger mark means more premium (the money paid for an option). A big print at the ask (the
// seller's price) means someone paid up for that bet. The up colour means bullish: calls (bets on a rise) bought, puts
// (bets on a fall) sold. The down colour means bearish: calls sold, puts bought. A soft dot leans less, and a muted
// mark barely leans. A column under the chart shows each bar's bullish minus bearish premium. Use it to see which
// prices drew large bets.
//
// Under the hood: the large option prints of the chart's underlying, drawn on price. Each print of at least the
// smallest premium you set is a mark at the underlying's price when it printed, at its own time inside the bar, toned
// by its score, the options kit's flowScore from -100 bearish to 100 bullish: the side of the quote (flowSideCode:
// above the ask, at it, the mid, at the bid, below it; on crypto and CME the taker's side), call or put, the moneyness
// against the price the mark sits at, the days to expiry (no open interest and no repeat count: the size reads as past
// the open interest). The up colour when it scores 60 or more (a call bought, a put sold), the down colour at -60 or
// below (a call sold, a put bought), a soft dot of the same colour from 20 to 60 either way, muted under 20 (the mid,
// no quote). A mark's area grows with the premium, the largest of each bar prints it, and its hover reads the score's
// size. Marks by score draws only the bullish prints (40 and up) or only the bearish ones (-40 and below). Under the
// chart, each bar's bullish minus bearish premium as a column. The chart serves each bar's 24 largest prints at the
// smallest premium, of the types kept, up to 90 days of them, and the data plane sums every such print per bar for the
// column and the readings. A bar past the history the data plane keeps is served in part: a faint wash covers it and
// partial reads 1. It reads the chart's own underlying, so it belongs on the underlying's chart; on an option
// contract's chart the price axis is the contract's own, so the marks stay off and the columns still draw.
section("Prints");
param.number("min_premium", 100000, { min: 25000, max: 1000000000, step: 5000, label: "Smallest premium, USD", description: "Trades with less premium (the money paid) than this draw no mark and count in no column. The chart loads trades from $25,000 up." });
param.choice("types", ["both", "calls", "puts"], "both", { label: "Calls or puts" });
param.int("max_marks", 12, { min: 1, max: 24, label: "Marks per bar", description: "How many of each bar's largest trades draw a mark, biggest first." });
param.number("mark_unit", 100000, { min: 1000, max: 1000000000, step: 1000, label: "Mark unit, USD", description: "A trade with this premium (the money paid) or less draws the smallest mark. Bigger trades draw bigger marks." });
param.choice("score_filter", ["all", "bullish", "bearish"], "all", { label: "Marks by score", description: "Each trade scores how strongly it leans, from -100 (bearish) to 100 (bullish). bullish marks scores of 40 and up, bearish -40 and below. The columns and the readings keep every trade." });
input("close", ohlcv.close); // the chart's own close: where a print without its underlying is marked, and the check that the chart is the underlying's
input("prints", option_prints.cells, { max_cells: 24, min_premium: "@min_premium", types: "@types", history: "90d", overflow: "largest", description: "This symbol's option trades at your smallest premium, of the types kept. It loads each bar's 24 largest, up to 90 days back, 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("call_ask", options_flow.call_prem_ask, { scope: "prints", min_premium: "@min_premium", missing: "nan" }); // the data plane's per-bar sums of every print at the smallest premium, calls and puts by side: the column and the readings
input("call_bid", options_flow.call_prem_bid, { scope: "prints", min_premium: "@min_premium", missing: "nan" });
input("put_ask", options_flow.put_prem_ask, { scope: "prints", min_premium: "@min_premium", missing: "nan" });
input("put_bid", options_flow.put_prem_bid, { scope: "prints", min_premium: "@min_premium", missing: "nan" });
input("printed", options_flow.prints, { scope: "prints", min_premium: "@min_premium", missing: "nan" }); // the count of those prints, calls and puts together
market.zone(); // the market's clock zone: 0 on crypto, whose sizes are coins, so its marks ride their own section; a print's days to expiry read on its calendar
// The readings, data-only: the Console reads them. NaN on a bar the chart served no block for.
output("bull_premium", none, overlay, { format: "usd", description: "Premium (the money paid) of this bar's bullish trades at or above the smallest premium, in USD. Bullish means calls (bets on a rise) bought and puts (bets on a fall) sold." });
output("bear_premium", none, overlay, { format: "usd", description: "Premium (the money paid) of this bar's bearish trades, in USD. Bearish means calls (bets on a rise) sold and puts (bets on a fall) bought." });
output("marked", none, overlay, { description: "Trades in this bar at or above the smallest premium (the money paid), of the types kept. Blank with one type kept on a bar of more than 24 such trades." });
output("partial", none, overlay, { description: "1 on a bar older than the trade history OpenMarket keeps. Its trades can be incomplete." });
output("net_premium", histogram, lower, { color_by: "net_tone", colors: ["theme.down", "theme.up", "theme.muted"], label: "Bullish minus bearish premium", format: "usd", hint: "Includes cross and late trades", description: "This bar's bullish premium (the money paid) minus its bearish premium, in USD. Above 0 means more money bet on a rise. Includes cross and late trades." });
output("net_tone", none, lower, { description: "The column's colour: 0 bearish, 1 bullish, 2 a bar older than the trade history OpenMarket keeps." });
// The marks: side 0 bearish (down colour), 1 bullish (up colour), 2 muted; the hover reads premium, price and the
// score's size (fills, 0 to 100). A print scoring 60 or more either way, or under 20, rides its chain's section.
plot.marks({ name: "large_prints", slots: 24, size: { law: "sqrt", unit: "@mark_unit" }, opacity_pct: 35, x: 1, text: { mode: 1, field: "qty", format: "compact", min_px: 24 }, colors: ["theme.down", "theme.up", "theme.muted"], tooltip: "{{qty}} premium at {{price}}, score {{fills}}" });
plot.marks({ name: "coin_prints", slots: 24, size: { law: "sqrt", unit: "@mark_unit" }, opacity_pct: 35, x: 1, text: { mode: 1, field: "qty", format: "compact", min_px: 24 }, colors: ["theme.down", "theme.up", "theme.muted"], tooltip: "{{qty}} premium at {{price}}, score {{fills}}" }); // the same marks on a crypto chain (zone 0)
plot.marks({ name: "soft_prints", slots: 24, size: { law: "sqrt", unit: "@mark_unit" }, opacity_pct: 10, look: 1, x: 1, text: { mode: 1, field: "qty", format: "compact", min_px: 24 }, colors: ["theme.down", "theme.up"], tooltip: "{{qty}} premium at {{price}}, score {{fills}}" }); // the prints scoring 20 to 60 either way, on every chain: a soft dot, no edge
render.bgcolor("served_in_part", { where: "partial", color: "#64748b14" }); // a faint wash over a bar served in part

const PRINT = 16; // f64s per print: OPTION_PRINTS_TUPLE
const MAX_MARKS = 24; // the marks section's slots
const NEAR_SPOT = 0.2; // a print's underlying within 20% of the close: the chart is the underlying's
const largest = new StaticArray<i32>(MAX_MARKS); // the bar's largest kept prints, as offsets into the block, biggest first

let minPremium = 100000.0; // settings, read in onStart()
let types = 0;
let maxMarks = 12;
let scoreFilter = 0; // 0 every mark, 1 the bullish ones, 2 the bearish ones
let zone = 0; // the market's clock zone, read in onStart(): 0 is a crypto chain

function onStart(): void {
  minPremium = p_min_premium();
  types = i32(p_types());
  maxMarks = i32(p_max_marks());
  scoreFilter = i32(p_score_filter());
  zone = i32(p_market_zone());
}

// 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;
}

// Where the print's mark sits: its underlying when it carries one above 0 (bit 2), else the close.
function markPrice(cells: StaticArray<f64>, at: i32, close: f64): f64 {
  return hasBit(cells[at + 15], 2) && cells[at + 11] > 0.0 ? cells[at + 11] : close;
}

// The print's score, -100 to 100 (flowScore): the side of the quote (flowSideCode, `outside` read under a valid quote
// only), call or put, the moneyness against `spot` (where its mark sits) and its days to expiry on the market's
// calendar. No open interest and no repeat count: the size reads as past the open interest and no hit adds.
function scoreOf(cells: StaticArray<f64>, at: i32, barMs: f64, spot: f64): f64 {
  const outside = hasBit(cells[at + 15], 3) ? cells[at + 10] : 0.0;
  const sideCp = cells[at + 4];
  const dte = optionsTradeDay(cells[at + 3], zone) - optionsTradeDay(barMs + cells[at], zone);
  return flowScore(flowSideCode(cells[at + 9], outside), sideCp, moneynessOf(sideCp, cells[at + 5], spot), dte, NaN, 0);
}

// Whether Marks by score draws the print at offset `at`: every print, the bullish ones (40 and up) or the bearish ones
// (-40 and below).
function scoreDraws(cells: StaticArray<f64>, at: i32, barMs: f64, close: f64): bool {
  if (scoreFilter == 0) return true;
  const score = scoreOf(cells, at, barMs, markPrice(cells, at, close));
  return scoreFilter == 1 ? score >= 40.0 : score <= -40.0;
}

// Slides the print at offset `at` into the list of the bar's largest, biggest first; returns the list's new length.
function offer(cells: StaticArray<f64>, at: i32, kept: i32): i32 {
  const premium = cells[at + 8];
  if (kept == maxMarks && premium <= cells[largest[kept - 1] + 8]) return kept; // smaller than every print kept
  let i = kept < maxMarks ? kept : kept - 1; // the slot that opens: the end, or the smallest kept
  for (; i > 0 && cells[largest[i - 1] + 8] < premium; i -= 1) largest[i] = largest[i - 1];
  largest[i] = at;
  return kept < maxMarks ? kept + 1 : kept;
}

// A sum the data plane left unset (no print of that kind in the bar) reads 0.
function orZero(value: f64): f64 {
  return isNaN(value) ? 0.0 : value;
}

// The bar's readings and its column.
function readings(bull: f64, bear: f64, marked: f64, partial: f64, net: f64, tone: f64): void {
  out_bull_premium(bull);
  out_bear_premium(bear);
  out_marked(marked);
  out_partial(partial);
  out_net_premium(net);
  out_net_tone(tone);
}

// onBar() runs once per bar: the block's prints at or above the smallest premium of the kept types, the largest kept
// for the marks; the data plane's sums for the readings and the column; then the marks. A tuple whose size is 0 is the
// chart's marker for a bar served in part, never a print.
function onBar(): void {
  const close = bar.close();
  const barMs = bar.time() * 1000.0; // a print's own time: its bar's open plus its offset
  const n = in_prints_cells();
  if (n < 0) { // no block on this bar: before the history the chart serves
    readings(NaN, NaN, NaN, NaN, NaN, NaN);
    return;
  }
  const cells = in_prints_view();
  if (n == PRINT && !(cells[7] > 0.0) && isPartial(cells[15])) { // the marker alone: past the history the data plane keeps
    readings(0.0, 0.0, 0.0, 1.0, NaN, 2.0);
    return;
  }
  let count = 0;
  let kept = 0;
  let cut = false; // bit 14: the bar held more prints than its 24 largest
  for (let i = 0; i + PRINT - 1 < n; i += PRINT) {
    if (isPartial(cells[i + 15])) cut = true;
    const premium = cells[i + 8];
    if (!(cells[i + 7] > 0.0) || !(premium >= minPremium)) continue; // the marker tuple, or under the smallest premium
    const sideCp = cells[i + 4];
    if ((types == 1 && sideCp < 0.0) || (types == 2 && sideCp > 0.0)) continue;
    count += 1;
    if (scoreDraws(cells, i, barMs, close)) kept = offer(cells, i, kept); // Marks by score keeps it among the marks
  }
  const callAsk = in_call_ask();
  const callBid = in_call_bid();
  const putAsk = in_put_ask();
  const putBid = in_put_bid();
  const printed = in_printed();
  if (count > 0 && isNaN(callAsk) && isNaN(callBid) && isNaN(putAsk) && isNaN(putBid) && isNaN(printed)) {
    readings(NaN, NaN, NaN, 0.0, NaN, NaN); // prints but no sums: the chart did not serve them (its chip says why)
  } else {
    const bull = (types != 2 ? orZero(callAsk) : 0.0) + (types != 1 ? orZero(putBid) : 0.0); // calls at the ask, puts at the bid
    const bear = (types != 2 ? orZero(callBid) : 0.0) + (types != 1 ? orZero(putAsk) : 0.0); // calls at the bid, puts at the ask
    const marked = types == 0 ? orZero(printed) : cut ? NaN : f64(count); // the sums count both types: one type counts its block, whole unless cut
    readings(bull, bear, marked, 0.0, count > 0 ? bull - bear : NaN, bull >= bear ? 1.0 : 0.0); // no kept print: no column
  }
  for (let k = 0; k < kept; k += 1) {
    const at = largest[k];
    const price = markPrice(cells, at, close);
    if (!(close > 0.0) || !(price > 0.0) || Math.abs(price / close - 1.0) > NEAR_SPOT) continue; // not the underlying's chart: no mark
    const score = scoreOf(cells, at, barMs, price);
    const strength = Math.abs(score);
    const offset = cells[at];
    const fills = i32(Math.floor(strength + 0.5)); // the hover's score, 0 to 100
    const tone = strength < 20.0 ? 2 : score > 0.0 ? 1 : 0; // muted under 20, else the up or down colour
    const offsetMs = !(offset > 0.0) ? 0 : offset >= 1073741824.0 ? 1073741824 : i32(offset);
    if (strength >= 20.0 && strength < 60.0) out_soft_prints_mark(k, price, cells[at + 8], tone, fills, offsetMs); // 20 to 60: the soft tone
    else if (zone == 0) out_coin_prints_mark(k, price, cells[at + 8], tone, fills, offsetMs); // a coin size: the coin section
    else out_large_prints_mark(k, price, cells[at + 8], tone, fills, offsetMs);
  }
}

How it works

The large prints. The prints input asks the data plane for each bar's 24 largest prints by premium (overflow: "largest", max_cells: 24, the most marks a bar draws) at the Smallest premium setting (min_premium: "@min_premium") and of the types Calls or puts keeps (types: "@types"), with up to 90 days of history (history: "90d"), and on a real-time chart the live prints as they print. Every print of 25,000 and up is a large print the data plane keeps 90 days, so the history this indicator reads is whole wherever the chart reaches. A bar with more prints than its 24 largest carries bit 14 on its first print, which the marks do not need: they are the bar's largest anyway. A change of either setting fetches again, with no rebuild.

The sums. Five options_flow inputs of scope prints read the data plane's own sums of every print of the bar at the same smallest premium (min_premium: "@min_premium"), whichever prints the cut kept: the premium of the calls at the ask and at the bid, of the puts at the ask and at the bid, and the count of those prints (printed). They read NaN on a bar with no such print (missing: "nan"), which the package reads as 0.

What a bar keeps. Smallest premium (100,000 by default, 25,000 at least) drops the smaller prints, and Calls or puts (both by default) keeps one type. bull_premium is the premium of the calls at the ask plus the puts at the bid, bear_premium the calls at the bid plus the puts at the ask, each of the types kept; a print at the mid or with no quote counts but leans neither way. marked counts the prints at the smallest premium: from the sums with both types kept, and from the bar's own prints with one type kept, which reads NaN on a bar of more than 24 such prints (the sums count calls and puts together).

The side and the lean. 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. A call at the ask or a put at the bid leans bullish; a call at the bid or a put at the ask leans bearish. On a crypto or CME chain the venue names the taker instead: a call the taker bought or a put it sold leans bullish, the other two bearish, and no print there sits at the mid.

The marks. The bar's largest prints by premium, up to Marks per bar (12, at most 24), are marks at the print's own time inside the bar (x: 1): at the underlying's price when the print carries it (bit 2), at the bar's close when it does not. The area grows with the premium from Mark unit (100,000), which draws the smallest mark, and the largest mark of each bar prints its premium where it is wide enough. On a crypto chain (market.zone() 0) the size is coins: the marks ride a second section, coin_prints, the same look and caption. A print whose underlying sits more than 20% from the bar's close draws no mark, since the chart is not the underlying's.

The score on the marks. Each mark's colour follows the print's flow score, the options kit's flowScore (Flow score): flowSideCode of its side of the quote (outside read only under a valid quote, bit 3), call or put, the moneyness against the price the mark sits at (at the money within 0.5%) and its days to expiry from its own time (the bar's open plus its offset, which is why the package reads bar.time()) on the market's clock. These marks read no open interest and count no repeat hits, so the size factor reads as past the open interest. From 60 either way a mark takes the full tone in its chain's section; from 20 to 60 it is a soft dot of the same colour with no edge, in a third section, soft_prints, on every chain; under 20 it takes the muted ink. The hover reads the premium, the price and the score's size (score 80; the colour says which way), carried in fills. Marks by score (all by default) keeps the bullish prints, scoring 40 and up, or the bearish ones, -40 and below, among the marks before they rank; the column and the readings keep every print.

The column. net_premium is the bar's bullish premium minus its bearish premium from the sums, a histogram in its own pane under the chart, in the up colour at or above zero and the down colour below (net_tone picks the colour); a bar with no kept print draws no column.

The readings. Data-only outputs on every bar: bull_premium, bear_premium (USD), marked (the prints kept) and partial (1 on a bar the chart served in part, past the history the data plane keeps). Each reads NaN on a bar the chart served no block for.

Cross and late trades. The data plane sides every print by the quote, cross trades and late or out-of-sequence prints included, because the feed carries no sale conditions, so a source that leaves those prints unsided shows a different net premium. The package says so where its net premium shows: the column's hover and the description of net_premium.

What the settings do

  • Smallest premium, USD: Hides trades with less premium (the money paid) than this, from $25,000 up.
  • Calls or puts: Keeps calls (bets on a rise), puts (bets on a fall) or both.
  • Marks per bar: How many of each bar's largest trades draw a mark, from 1 to 24.
  • Mark unit, USD: The premium that draws the smallest mark, so bigger trades draw bigger marks.
  • Marks by score: Marks all trades, or only strong leans: scores of 40 to 100 (bullish) or -40 to -100 (bearish).

Where it runs

On crypto, it reads each coin's own listed options, with sizes in coins and premium (the money paid) in USD. A copy you run from the editor (where you write and run indicators) reads them too (Data sources). Take a 1-minute Deribit BTC chart with Smallest premium, USD at 25,000. On 17 October 2026 at 11:28 UTC, an 84000 put sold in RFQ 58101 (a trade priced privately on request). A put is a bet on a fall, and it sold at the bid (the buyer's price). That draws one soft dot in the up colour at the index price (Deribit's bitcoin reference price), 81,457.69. Its column reads +32,990.36. The put's strike (the option's price level) sits above the price, so it is in the money. With 13 days to expiry (the day the option ends), it scores 40.8 out of 100. A score from 20 to 60 either way draws a soft dot. An exchange can list a coin's options in two sets, such as Deribit's BTC and BTC_USDC. On crypto, the column and the readings count every set. The marks read one set, the one named like the coin. 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). Alerts and Protected indicators (published ones that run on OpenMarket's servers) cannot read these trades. On an option contract's own chart, it reads the symbol behind that contract. That chart's price axis is the option's own price, so the marks stay off and the columns still draw. 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 90 days the chart loads has no data. Every reading stays blank, and it draws nothing.
  • A quiet bar. A bar with no trade at your smallest premium, of the types kept, draws no mark and no column. In the Console (the editor's prompt that shows a reading by its name), marked and the premiums read 0.
  • A bar cut to its largest trades. The chart sends each bar's 24 largest trades and flags a bar that held more. Its marks are its largest trades anyway. The column and the readings come from totals of every trade, so the bar still reads whole. In the Console, the count of marked trades (marked) stays blank when only calls or only puts are kept.
  • A bar older than the stored history. OpenMarket keeps a limited trade history. An older bar arrives as one empty marker, which never counts as a trade. A faint shade covers it, and it draws no column. In the Console, partial reads 1, the colour code net_tone reads 2, and the premiums and marked read 0.
  • Trades without their totals. A bar with a kept trade but no totals draws no column, but its marks still draw. In the Console, every reading is blank except partial, which reads 0. A chip on the legend names the data the chart could not load.

Customize it

  • Only the whales. Raise Smallest premium to 1,000,000 and Mark unit to 1,000,000: a few marks a day, each one a large bet.
  • One side of the book. Set Calls or puts to puts to watch the hedges and the downside bets alone.
  • A quieter chart. Lower Marks per bar to 3 on a short timeframe: only the largest prints of each bar draw.
  • The bearish flow alone. Set Marks by score to bearish: only the sold calls and the bought puts scoring -40 and below draw, while the column still nets every print.

Run it

  1. In the editor's Explorer, press the Templates icon ("Browse starter templates") and pick Flow Marks under Order flow.
  2. Press Run on a chart whose underlying lists options, a US stock such as SPY, ES1! or a BTC chart: once the chart serves its option prints the marks sit on the candles and the columns stand under the chart; until then the legend's chip names the source the chart does not serve yet.
  3. At the editor's Console prompt, type bull_premium and bear_premium to read the newest bar's large-print premium by lean.

Concepts used