Options Dashboard

View as MarkdownOpen the editor

Nine tiles under the chart sum up this symbol's options right now. Dealer regime says if dealers (the market makers who hedge options) calm price moves or push them.

The right-hand chart of the options desk. At the top sit the BTCUSDT 1h candles, then the Options tiles. Below them, the gamma curve has a dashed Spot marker. Callouts mark the gamma flip, the peak and the trough. At the bottom, a rolling histogram of buys minus sells sits in its own pane

Below sit a curve of dealer hedging up to 15% away and cumulative volume delta (buys minus sells, summed). The curve crosses zero at the gamma flip, the price where dealers switch from calming price to pushing it. Use it on any chart with options to see if the next move may run or stall.

Under the hood: it reads one options_chain.cells request naming three book folds (numbers, strike_profile and vol_term) (Chain page views). The answer arrives as one block on the live bar, beside two sided trades.volume reads (Data sources). So every options number is the fold the built-in Options Dashboard draws. It writes two frames into a panel.tiles and a panel.line below the chart (Frames, panels and compact widgets). The fold readers BookStamp, OptionNumbers, StrikeProfile and VolTerm read the block (Book folds). dealerRegime and oneSigmaMove give the regime and Sigma (The canonical numbers). optionsTradeDay finds the session (The market's own date). A named pane holds the histogram (Panes), and a ladder colours a legend entry (Styling). This is also the options-dashboard template: the Options Dashboard card under Beyond the time axis in the editor's starter list. It compiles as written. It is the right-hand chart of the options desk that Style anything walks through part by part, beside the Strike Matrix.

The wrun indicator

// Options Dashboard: nine number tiles under the chart that sum up this symbol's options right now. Each tile reads
// every expiry date (the date an option ends) unless it says otherwise. Dealers are the market makers who hedge
// options. Live net GEX is the dollars dealers must trade to hedge each 1% move. The gamma flip is the price where
// dealers switch from calming price to pushing it. Max pain is the strike (the option's price level) where option
// holders collect the least at expiry. Dealer regime says whether dealers tend to calm moves or feed them right now.
// Sigma today measures today's move against the day's expected move (how far option prices say it can move). The
// put/call ratio compares open puts (bets on a fall) with open calls (bets on a rise). 25D skew shows whether traders
// pay more for downside or upside protection. Net VEX is how much dealers gain or lose when option prices rise. Net DEX
// is how much of the asset they must hold to hedge. Under the tiles, a curve shows dealer hedging at prices up to 15%
// either side of now. Its zero crossing is the gamma flip. At the bottom, a rolling cumulative volume delta (buys minus
// sells, summed) histogram tracks buying against selling. Use it for a quick read on whether dealers will dampen or
// amplify the next move.
//
// Under the hood: nine stat tiles over the chart's own option book (net GEX, the gamma flip and the dealer regime over
// every live expiry, max pain, today's move in 1σ moves, the put/call ratio, the 25-delta risk reversal, net vega
// exposure, net delta exposure), the net gamma exposure curve over hypothetical spots with a signed fill and marked
// spot, flip, peak and trough, and a rolling cumulative volume delta histogram in a pane of its own. Every options
// number is the data plane's own fold of the chain page's whole book, the numbers the chart's built-in Options
// Dashboard and GEX Curve draw, read through ONE options_chain input naming three book folds: numbers (net GEX at S0,
// the flip and the next 24 hours' ATM IV, every live expiry), strike_profile with no strike rows (max pain, the
// put/call ratio of open interest, net VEX and net DEX, and the curve over S0 ± 15% in 61 points) and vol_term (the
// front expiry's 25-delta risk reversal, call minus put). A tile maps its fold field the way the built-in does: net GEX
// the scope row's (the levels row's without one), the regime its sign, the risk reversal the front row's while the book
// has a spot and the vol term's front is the nearest live expiry. Sigma is this package's own: the close's move from
// the session's open (the open of the trade day's first bar on the market's clock: the UTC day on crypto, the CME trade
// date, the New York date) over the day's 1σ move, the open x the next 24 hours' ATM IV x sqrt(1/252) (oneSigmaMove).
// The book is live only: the tiles and the curve are rewritten on the last bar, the CVD on every bar. An empty book (no
// contract) blanks every tile and the curve; a number the fold has no reading for reads n/a, never a stale value.
param.int("cvd_bars", 96, { min: 2, max: 500, label: "CVD window, bars", description: "How many bars the rolling cumulative volume delta (buys minus sells, summed) covers. Buys and sells are aggressive trades, which took the other side's price." });
input("close", ohlcv.close); // the chart's close: max pain's distance from spot and Sigma's move
input("buy", trades.volume, { side: "BUY", missing: "zero", description: "Aggressive buy volume" });
input("sell", trades.volume, { side: "SELL", missing: "zero", description: "Aggressive sell volume" });
// The book's block: rows of 16 f64s, [layout, ...fields] (the book stamp, the numbers rows, the levels row and the
// curve's points, the term structure's rows); max_cells counts rows, the stamp's included: 400 holds the stamp, the
// scope row, 264 expiry rows and the eight horizons, vol_term's 64 rows, the levels row and the 61 points.
input("chain", options_chain.cells, { max_cells: 400, venue: "auto", page_views: ["numbers", "strike_profile", "vol_term"], strikes: 0, points: 61, half_pct: 15, description: "This chart's own options, summed up by OpenMarket. Venue auto reads US listed options (OPRA) on a US stock or ETF, CME on a futures chart, else Deribit." });
market.zone(); // the market's clock: Sigma's trade day
chart.interval_sec(); // the bar's length: Sigma reads a daily or finer chart
output("net_gex", none, overlay, { description: "Dealers' net gamma exposure in USD per 1% move, over every live expiry date. Gamma is how fast dealers must hedge as price moves. Newest bar only." });
output("gamma_flip", none, overlay, { description: "The gamma flip, where dealers switch from calming moves to feeding them, over every live expiry date. Empty when none lies within 50% of the price. Newest bar only." });
output("max_pain", none, overlay, { description: "Max pain: the strike (option price level) where option holders collect the least, over every live expiry date. Newest bar only." });
output("regime_sign", none, overlay, { description: "0 when dealers' net gamma is negative, 1 when positive or zero, empty with no reading. It picks the legend's colour." });
output("cvd_sign", none, lower, { description: "0 while the rolling CVD is negative, 1 while positive. It picks the histogram's colour." });
output("cvd", histogram, lower, { pane: "cvd", color_by: "cvd_sign", colors: ["theme.down", "theme.up"], width: 0.7, label: "Agg. Rolling CVD", format: "si", description: "Rolling CVD (cumulative volume delta): aggressive buy volume minus sell volume over the window. Above zero, buyers led." });
pane("cvd", { height_frac: 0.12, format: "si" }); // the Indicator's home pane: it carries the Indicator's name, so no title here
output("sigma", none, overlay, { description: "Today's move from the open, counted in 1σ moves (one standard deviation). A 1σ move is the open times the next day's implied volatility (IV) times √(1/252). Newest bar only." });
output("sigma_left", none, overlay, { description: "How much of today's 1σ move is left: 1 minus the size of sigma, never below 0. Newest bar only." });
string("regime_text", { max_bytes: 64 }); // the legend entry: "Neg Gamma (OI) | Flip · all expiries $85,722"
render.legend("regime_entry", { text: "regime_text", color: "theme.muted", color_by: "regime_sign", colors: ["theme.down", "theme.up"] });
const tileRows = frame("tile_rows", { max_bytes: 4096 });
const gexCurve = frame("curve_rows", { max_bytes: 16384 });
// Nine tiles in two rows, five and four: signed dollars, unless a tile's own format word, text or colour wins.
panel.tiles({ name: "tiles", title: "Options", x: "category", place: "below", frame: tileRows, columns: 5, positive_color: "theme.up", negative_color: "theme.down", format: "usd", signed: true, hover_card: true, height_frac: 0.18 });
// The gamma curve: a smooth line in the chart's text ink over hypothetical spot, filled up above zero and down below,
// both axes in dollars; the spot marker and the flip, peak and trough callouts are written per run into the frame, and
// the title names the one series, so it needs no legend chip.
panel.line({ name: "gex_curve", title: "Net GEX (hypothetical spot)", x: "number", place: "below", frame: gexCurve, series: [{ name: "Net GEX", color: "theme.text", width: 2 }], smooth: true, fill_mode: "signed", fill_positive_color: "theme.up", fill_negative_color: "theme.down", fill_fade: true, x_format: "usd", x_decimals: 1, format: "usd", signed: true, decimals: 0, x_title: "Spot", y_zero: true, legend_style: "none", hover_card: true, height_frac: 0.25, maximize: true, stats_row: true });

const POINTS: i32 = 61; // the curve's points over S0 ± 15%: the chain input's points and half_pct
const MAX_CVD = 500; // the ring the rolling CVD reads
const SIGMA_YEARS: f64 = 1.0 / 252.0; // one trading day: the day's 1σ move is the open x the 1-day IV x sqrt(1/252)
const NEXT_DAY_YEARS: f64 = 1.0 / 365.0; // the numbers fold's next 24 hours, the horizon Sigma's IV is read at
const DAY_MS: f64 = 86400000.0;
const gridSpot = new StaticArray<f64>(POINTS); // the curve's points over spot, read off the fold
const gridGex = new StaticArray<f64>(POINTS);
const deltas = new StaticArray<f64>(MAX_CVD); // buy minus sell per bar, the rolling window
const stamp = new BookStamp(); // the book every fold read: its spot and whether it holds a contract
const numbers = new OptionNumbers(1); // the scope rows, the horizons and the front expiry's row (the nearest kept)
const profile = new StrikeProfile(1, POINTS); // the levels row and the curve's points (strikes 0: no strike row)
const term = new VolTerm(1); // the term structure's front row (the nearest kept): its 25-delta risk reversal
let cvdBars = 96; // settings, read in onStart()
let zone = 0;
let intervalMs = 0.0; // the bar's length in milliseconds; 0 where the host writes none
let coarse = false; // a chart coarser than a day: a bar is no session, so Sigma reads none
let close: f64 = NaN; // this bar
let t: f64 = NaN;
let cvd: f64 = 0.0; // the rolling CVD and its ring
let cvdHead = 0;
let cvdCount = 0;
let haveAnswer = false; // the live bar's block carried a book stamp
let haveBook = false; // ... of a book holding contracts
let s0: f64 = NaN; // the readings, measured on the live bar: the book's spot
let netGex: f64 = NaN;
let regime: f64 = NaN; // the sign of net GEX: 1, -1 or 0; NaN without a reading
let flip: f64 = NaN; // the gamma flip: the curve's zero nearest S0
let pain: f64 = NaN;
let pcr: f64 = NaN;
let rr25: f64 = NaN; // the front expiry's 25-delta risk reversal, call minus put, vol points
let vex: f64 = NaN;
let dex: f64 = NaN;
let points = 0; // the curve's points read
let peakIdx = 0;
let troughIdx = 0;
let sessionDay: f64 = NaN; // the trade day the newest bar sits in, on the market's clock
let sessionOpen: f64 = NaN; // the open of that trade day's first bar; NaN while the run opened inside it
let sigma: f64 = NaN; // today's move in 1σ moves, the budget left and the IV it read (a decimal), live bar only
let sigmaLeft: f64 = NaN;
let sigmaIv: f64 = NaN;

function onStart(): void {
  cvdBars = i32(p_cvd_bars());
  if (cvdBars > MAX_CVD) cvdBars = MAX_CVD;
  zone = i32(p_market_zone());
  intervalMs = p_chart_interval_sec() * 1000.0;
  coarse = intervalMs > DAY_MS;
}

// A missing number reads NaN: a tile shows n/a, never a stale value.
function finite(v: f64): f64 {
  return isFinite(v) ? v : NaN;
}

// ── The book on the live bar: the data plane's folds, each tile's field the built-in Dashboard's ──
function measureBook(n: i32): void { // n = f64 cells in the live block
  const cells = in_chain_view(); // the live block in place: the first n values of the build's own buffer
  haveAnswer = stamp.load(cells, n, OPTION_VIEW_ROW_VOL_TERM); // every reader at the input's row width: its widest word's, vol_term's 16
  haveBook = haveAnswer && !stamp.empty(); // the empty book (no contract) answers its stamp alone
  s0 = NaN;
  netGex = NaN;
  regime = NaN;
  flip = NaN;
  pain = NaN;
  pcr = NaN;
  rr25 = NaN;
  vex = NaN;
  dex = NaN;
  points = 0;
  if (!haveBook) return;
  numbers.load(cells, n, OPTION_VIEW_ROW_VOL_TERM);
  profile.load(cells, n, OPTION_VIEW_ROW_VOL_TERM);
  term.load(cells, n, OPTION_VIEW_ROW_VOL_TERM);
  s0 = stamp.spot(); // NaN when no expiry of the book has an anchor: its rows still read
  const whole = numbers.scopeIndex(0.0); // every live expiry's scope row
  netGex = finite(whole >= 0 ? numbers.netGex(whole) : profile.totalNetGex());
  regime = dealerRegime(netGex); // the kit's one rule: the sign of net GEX, NaN without a reading
  flip = finite(numbers.flip(whole));
  pain = finite(profile.maxPain());
  pcr = finite(profile.putCallRatio());
  vex = finite(profile.totalNetVex());
  dex = finite(profile.totalNetDex());
  // The front expiry's risk reversal: the vol term's first row while it is the nearest live expiry (numbers' first
  // expiry row) and the book has a spot; an expiry quoting no IV and holding no open interest has no vol term row.
  if (s0 > 0.0 && term.expiries() > 0) {
    const nearest = numbers.expiryMs(0);
    if (isNaN(nearest) || nearest == term.expiryMs(0)) rr25 = finite(term.rr25(0));
  }
  points = profile.points();
  for (let p = 0; p < points; p += 1) {
    gridSpot[p] = profile.pointX(p);
    gridGex[p] = profile.pointGex(p);
  }
  peakIdx = 0;
  troughIdx = 0;
  for (let p = 1; p < points; p += 1) {
    if (gridGex[p] > gridGex[peakIdx]) peakIdx = p;
    if (gridGex[p] < gridGex[troughIdx]) troughIdx = p;
  }
}

// The numbers fold's ATM IV over the next 24 hours (a decimal): its horizon row at 1/365 of a year, the nearest one.
function nextDayIv(): f64 {
  let iv: f64 = NaN;
  let gap = Infinity;
  for (let h = 0; h < numbers.horizons(); h += 1) {
    const d = Math.abs(numbers.horizonYears(h) - NEXT_DAY_YEARS);
    if (d < gap) {
      gap = d;
      iv = numbers.horizonIv(h);
    }
  }
  return gap < 1.0e-9 ? iv : NaN;
}

// ── Sigma on the live bar: the close's move from the session's open over the day's 1σ move ──
function measureSigma(): void {
  sigmaIv = haveBook ? finite(nextDayIv()) : NaN;
  sigma = finite((close - sessionOpen) / oneSigmaMove(sessionOpen, sigmaIv, SIGMA_YEARS)); // NaN without an open or an IV
  sigmaLeft = isNaN(sigma) ? NaN : Math.max(0.0, 1.0 - Math.abs(sigma));
}

// ── Text and frames, built without allocating ──
function fbUsd(v: f64): void { // "+$34.7M", "-$42.0M", "+$1.23B"
  if (!isFinite(v)) {
    fb_text("n/a");
    return;
  }
  fb_text(v < 0.0 ? "-$" : "+$");
  const a = Math.abs(v);
  if (a >= 1.0e9) {
    fb_f64(a / 1.0e9, 2);
    fb_text("B");
  } else if (a >= 1.0e6) {
    fb_f64(a / 1.0e6, 1);
    fb_text("M");
  } else if (a >= 1.0e3) {
    fb_f64(a / 1.0e3, 1);
    fb_text("K");
  } else fb_f64(a, 0);
}
function fbPctFrom(price: f64, from: f64): void { // "+1.4%": how far a price sits from another
  const pct = (price / from - 1.0) * 100.0;
  if (pct >= 0.0) fb_text("+");
  fb_f64(pct, 1);
  fb_text("%");
}
function fbSigned(v: f64): void { // "+0.99", "-1.19": two decimals, a value that rounds to zero reads +0.00
  if (Math.abs(v) < 0.005) {
    fb_text("+0.00");
    return;
  }
  if (v > 0.0) fb_text("+");
  fb_f64(v, 2);
}
function fbTone(v: f64): void { // the colour word of a signed reading
  fb_text(v < 0.0 ? "\"theme.down\"" : "\"theme.up\"");
}
function fbDollars(v: f64): void { // a dollar tile's value: its whole dollars, or "n/a" (a tile value is never null)
  if (isFinite(v)) fb_f64(v, 0);
  else fb_text("\"n/a\"");
}
function priceDecimals(v: f64): i32 { // decimals follow the price's size, so the tiles read on any coin: $87,526, $150.25, $0.4213
  return v >= 1000.0 ? 0 : v >= 1.0 ? 2 : 4;
}
function fbX(v: f64): void { // a curve price, two decimals finer than a tile's, so 61 points stay apart on any price
  fb_f64(v, priceDecimals(v) + 2);
}
function fbGrouped(n: i64): void { // 85979 -> 85,979
  if (n >= 1000) {
    fbGrouped(n / 1000);
    fb_text(",");
    const r = n % 1000;
    if (r < 100) fb_text("0");
    if (r < 10) fb_text("0");
    fb_int(r);
  } else fb_int(n);
}
function fbPrice(v: f64): void { // "$85,979", "$150.25", "$0.4213"
  fb_text("$");
  if (v >= 1000.0) fbGrouped(i64(Math.round(v)));
  else fb_f64(v, priceDecimals(v));
}
function writeTiles(): void { // [label, value, caption, color, spark, format], null to skip an element
  fb_clear();
  fb_text("{\"rows\":[");
  fb_text("[\"Live net GEX\",");
  fbDollars(netGex);
  fb_text(",\"all expiries · open interest");
  if (s0 > 0.0) {
    fb_text(" @ $");
    if (s0 >= 1000.0) {
      fb_f64(s0 / 1000.0, 1);
      fb_text("K");
    } else fb_f64(s0, priceDecimals(s0));
  }
  fb_text("\",null,null,\"usd\"]");
  if (isFinite(flip)) {
    fb_text(",[\"Gamma flip\",\"");
    fbPrice(flip);
    fb_text("\",\"");
    if (s0 > 0.0) {
      fbPctFrom(flip, s0);
      fb_text(" · ");
    }
    fb_text("all expiries\",\"theme.text\"]");
  } else if (isFinite(netGex)) fb_text(",[\"Gamma flip\",\"None within 50%\",\"all expiries\",\"theme.text\"]"); // the curve has no zero within 50% of S0
  else fb_text(",[\"Gamma flip\",\"n/a\",\"all expiries\",\"theme.muted\"]");
  fb_text(",[\"Max pain\",\"");
  if (isFinite(pain)) {
    fbPrice(pain);
    fb_text("\",\"");
    fbPctFrom(pain, close);
    fb_text(" from spot · all expiries\",\"theme.text\"]");
  } else fb_text("n/a\",\"all expiries\",\"theme.muted\"]");
  // Version 0.4 names the measure, open-interest gamma: "(OI)" on the regime (a tile caption holds 40 characters, which
  // its scope fills) and in the legend entry, "open interest" in net GEX's caption.
  if (regime < 0.0) fb_text(",[\"Dealer regime\",\"Negative Gamma (OI)\",\"Dips sold, rallies bought · all expiries\",\"theme.down\"]");
  else if (regime > 0.0) fb_text(",[\"Dealer regime\",\"Positive Gamma (OI)\",\"Dips bought, rallies sold · all expiries\",\"theme.up\"]");
  else if (regime == 0.0) fb_text(",[\"Dealer regime\",\"Neutral Gamma (OI)\",\"No net gamma at S0 · all expiries\",\"theme.text\"]");
  else fb_text(",[\"Dealer regime\",\"n/a\",\"all expiries\",\"theme.muted\"]");
  // Sigma: the signed move in 1σ moves, the budget left and the IV under it, coloured by |sigma|'s band.
  fb_text(",[\"Sigma today\",\"");
  if (isNaN(sigma)) {
    fb_text("n/a\",\"");
    fb_text(coarse ? "Needs a daily or finer chart" : !(sessionOpen > 0.0) ? "Waiting for today's open" : "No 1-day IV in this symbol's options");
    fb_text("\",\"theme.muted\"]");
  } else {
    fbSigned(sigma);
    fb_text("σ\",\"1σ budget left ");
    fb_f64(sigmaLeft * 100.0, 0);
    fb_text("% · 1d IV ");
    fb_f64(sigmaIv * 100.0, 1);
    fb_text("%\",");
    const a = Math.abs(sigma);
    fb_text(a < 0.5 ? "\"theme.muted\"]" : a < 1.0 ? "\"theme.text\"]" : sigma > 0.0 ? "\"theme.up\"]" : "\"theme.down\"]");
  }
  fb_text(",[\"P/C ratio\",\""); // a ratio of open interest, so text: two decimals and no sign
  if (isFinite(pcr)) {
    fb_f64(pcr, 2);
    fb_text(pcr > 1.0 ? "\",\"Puts favored\",\"theme.down\"]" : "\",\"Calls favored\",\"theme.up\"]");
  } else fb_text("n/a\",\"all expiries\",\"theme.muted\"]");
  fb_text(",[\"25D skew\",\""); // the risk reversal, call minus put: below zero the puts are bid
  if (isFinite(rr25)) {
    if (rr25 >= 0.0) fb_text("+");
    fb_f64(rr25, 1);
    fb_text(rr25 < 0.0 ? "pp\",\"Puts bid (downside)\"," : "pp\",\"Calls bid (upside)\",");
    fbTone(rr25 < 0.0 ? -1.0 : 1.0);
    fb_text("]");
  } else fb_text("n/a\",\"front expiry\",\"theme.muted\"]");
  fb_text(",[\"Net VEX\",");
  fbDollars(vex);
  fb_text(!isFinite(vex) ? ",\"all expiries\",null,null,\"usd\"]" : vex >= 0.0 ? ",\"Dealers long vega\",null,null,\"usd\"]" : ",\"Dealers short vega\",null,null,\"usd\"]");
  fb_text(",[\"Net DEX\","); // USD notional (delta x open interest x multiplier x underlying), the same quantity on a coin, a stock and a future
  fbDollars(dex);
  if (isFinite(dex)) {
    fb_text(dex < 0.0 ? ",\"Net short delta, USD notional\"," : ",\"Net long delta, USD notional\",");
    fbTone(dex);
    fb_text(",null,\"usd\"]");
  } else fb_text(",\"all expiries\",null,null,\"usd\"]");
  fb_text("]}");
  writeFrameBuffer(tileRows);
}
function fbMarker(idx: i32, color: string): void { // a point callout pinned on the curve: "<usd> @ $<spot>" with a leader and a dot
  fb_text(",{\"x\":");
  fbX(gridSpot[idx]);
  fb_text(",\"valign\":\"point\",\"series\":\"Net GEX\",\"label\":\"");
  fbUsd(gridGex[idx]);
  fb_text(" @ $");
  fb_f64(gridSpot[idx], priceDecimals(gridSpot[idx]));
  fb_text("\",\"color\":\"");
  fb_text(color);
  fb_text("\"}");
}
function writeCurve(): void { // the fold's points over S0 ± 15%; none (an empty book, no spot) clears the curve
  fb_clear();
  fb_text("{\"rows\":[");
  for (let p = 0; p < points; p += 1) {
    fb_text(p > 0 ? ",[" : "[");
    fbX(gridSpot[p]);
    fb_text(",");
    fb_f64(gridGex[p], 0);
    fb_text("]");
  }
  fb_text("]");
  if (points > 0) {
    fb_text(",\"markers\":[{\"x\":\"spot\",\"label\":\"Spot\",\"wash\":true}");
    if (flip >= gridSpot[0] && flip <= gridSpot[points - 1]) { // the flip as a point callout on the curve (its value is zero there) when the points reach it
      fb_text(",{\"x\":");
      fbX(flip);
      fb_text(",\"valign\":\"point\",\"series\":\"Net GEX\",\"label\":\"Gamma flip\",\"color\":\"theme.text\",\"show_value\":true}");
    }
    fbMarker(peakIdx, "theme.up");
    fbMarker(troughIdx, "theme.down");
    fb_text("]");
  }
  fb_text(",\"caption\":\"live chain, all expiries\"}");
  writeFrameBuffer(gexCurve);
}
function sbGrouped(n: i64): void { // 85979 -> 85,979
  if (n >= 1000) {
    sbGrouped(n / 1000);
    sb_text(",");
    const r = n % 1000;
    if (r < 100) sb_text("0");
    if (r < 10) sb_text("0");
    sb_int(r);
  } else sb_int(n);
}
function writeLegendText(): void { // only while net GEX has a reading (the regime is known)
  sb_clear();
  sb_text(regime < 0.0 ? "Neg Gamma (OI) | " : regime > 0.0 ? "Pos Gamma (OI) | " : "Neutral Gamma (OI) | ");
  if (isNaN(flip)) sb_text("no flip within 50%");
  else {
    sb_text("Flip · all expiries $");
    if (flip >= 1000.0) sbGrouped(i64(Math.round(flip)));
    else sb_f64(flip, priceDecimals(flip));
  }
  str_regime_text_sb();
}

// onBar(): the session and the rolling CVD on every bar; the live bar reads the book and Sigma and writes the tiles,
// the curve and the legend.
function onBar(): void {
  t = bar.time();
  close = bar.close();
  // The session: the first bar of each trade day opens it; the run's first trade day opened before the run did.
  const day = optionsTradeDay(t * 1000.0, zone);
  if (isFinite(day) && day != sessionDay) {
    sessionOpen = isNaN(sessionDay) ? NaN : bar.open();
    sessionDay = day;
  }
  // The rolling CVD: this bar's delta joins the ring, the bar that falls out of the window leaves it.
  const d = in_buy() - in_sell();
  if (cvdCount == cvdBars) cvd -= deltas[cvdHead];
  else cvdCount += 1;
  deltas[cvdHead] = d;
  cvdHead = (cvdHead + 1) % cvdBars;
  cvd += d;
  out_cvd(cvd);
  out_cvd_sign(cvd >= 0.0 ? 1.0 : 0.0);
  haveAnswer = false;
  haveBook = false;
  sigma = NaN;
  sigmaLeft = NaN;
  if (bar.isLast() && !isNaN(close) && !isNaN(t)) {
    measureBook(in_chain_cells());
    if (!coarse) measureSigma();
  }
  out_net_gex(haveBook ? netGex : NaN);
  out_gamma_flip(haveBook ? flip : NaN);
  out_max_pain(haveBook ? pain : NaN);
  out_regime_sign(haveBook && !isNaN(regime) ? (regime < 0.0 ? 0.0 : 1.0) : NaN);
  out_sigma(sigma);
  out_sigma_left(sigmaLeft);
  if (haveAnswer) { // a read answered: the book's numbers, or the empty book's blank tiles and curve
    if (haveBook && !isNaN(regime)) writeLegendText();
    writeTiles();
    writeCurve();
  }
}

How it works

The book is live only. input("chain", options_chain.cells, { max_cells: 400, venue: "auto", page_views: ["numbers", "strike_profile", "vol_term"], strikes: 0, points: 61, half_pct: 15 }) asks the data plane for three book folds of the chart's own option book: numbers (net GEX, the regime and the gamma flip over every live expiry, a row per live expiry, and the at-the-money IV at eight horizons, the next 24 hours among them), strike_profile with strikes: 0 (no strike rows, only the levels row and the GEX curve: its points, 61, over S0 ± half_pct, 15%) and vol_term (a row per live expiry quoting an IV or holding open interest). The data plane folds them once a chain update over the chain page's whole book, priced at one instant, so the tiles read the numbers the chart's own options panes draw. The answer rides the live row as one block of rows 16 values wide, the widest word's (vol_term), each row [layout, ...fields]: the book stamp, the numbers rows, the levels row and the curve's points, the term rows. max_cells counts rows, the stamp's included: 400 holds the stamp, the scope row, 264 expiry rows, the eight horizons, vol_term's 64 rows, the levels row and the 61 points. History bars carry an empty block, so the tiles and the curve are read on the last bar and rewritten as the book moves. venue: "auto" reads the chart's own market when it lists options, else the coin's Deribit chain.

One block, four readers. On the live bar four kit readers read the block, each at the input's row width (OPTION_VIEW_ROW_VOL_TERM, 16) and each its own layouts. BookStamp says whether an answer arrived and whether the book holds a contract (empty(): the empty book answers its stamp alone), and gives S0, the book's spot (spot(), NaN when no expiry of the book has an anchor; its rows still read). Net GEX is the numbers fold's scope row over every live expiry (scopeIndex(0), netGex(); the levels row's totalNetGex() without one), at S0 in USD per 1% move; the dealer regime is its sign through the kit's dealerRegime(), NaN without a reading, and the gamma flip is that row's flip(), the GEX curve's zero nearest S0, NaN when none lies within 50% of it: the level the tile, the legend entry, the gamma_flip output and the flip callout all read. Max pain, the put/call ratio of open interest (puts over calls), net VEX and net DEX are the strike_profile levels row's (maxPain(), putCallRatio(), totalNetVex(), totalNetDex()), every live expiry pooled. The curve is that fold's 61 points (points(), pointX(), pointGex()), and the pass finds its peak and trough there. Each reader holds only what the tiles read: OptionNumbers(1) and VolTerm(1) keep the nearest expiry's row, StrikeProfile(1, 61) no strike row and the 61 points. A number the fold has no reading for reads NaN, so its tile prints n/a, never a stale value.

The other tiles. The 25D skew tile is the front expiry's 25-delta risk reversal, the vol term's first row (rr25(): the 25-delta call's IV minus the 25-delta put's, in vol points, so below zero the puts are bid). It reads only while the book has a spot and that row is the nearest live expiry, the numbers fold's first expiry row: an expiry quoting no IV and holding no open interest has no vol term row, so the tile never prints a later expiry's skew as the front one's. Net VEX is the levels row's net vega exposure, captioned Dealers long vega from zero up and Dealers short vega below. Net DEX is its net delta exposure in USD notional (delta times open interest times the multiplier times the underlying), the one unit that reads the same on every venue (delta times open interest is coins on Deribit, where the multiplier is 1, but shares on OPRA, where it is 100, and dollars per point on CME, where it is the point value), so the tile prints through the usd format with a USD notional caption. The tiles frame is { rows: [[label, value, caption, color, spark, format], ...] }, null skipping an element: a number prints through the panel's format: "usd" with signed: true unless the row carries its own format word, a text value prints as written ($85,722, 0.56 for the ratio, -1.4pp; prices carry thousands separators and their decimals follow the coin's price size; the flip's caption names its scope, +1.4% · all expiries, and with no zero within 50% of S0 the tile reads None within 50%; the regime's value names its measure, Negative Gamma (OI), and its caption its scope, Dips sold, rallies bought · all expiries (a tile's caption holds at most 40 characters, which the scope fills, so the measure rides the value); net GEX's caption names both, all expiries · open interest @ $85.7K, and max pain's its distance from the chart's close and its scope, -2.1% from spot · all expiries), a dollar tile with no reading prints the text n/a (a tile's value is never null), and a row's own colour wins: the regime, the ratio, the skew and net DEX carry theme.up or theme.down by the side they read, the flip and max pain theme.text, a tile with no reading theme.muted, and net GEX and net VEX carry none (nor does net DEX without a reading).

Sigma. Every bar notes its trade day on the market's clock (optionsTradeDay(): the UTC day on crypto, the CME trade date that opens at 17:00 Chicago, the New York date), and the first bar of each trade day opens its session at its open; the run's first trade day opened before the run did, so it has none. On the live bar the numbers fold's horizon row at 1/365 of a year, the next 24 hours, gives the at-the-money IV (horizonYears(), horizonIv(), a decimal). Sigma is the live close minus the session's open over oneSigmaMove(open, iv, 1 / 252), the open times that IV times the square root of one trading day, and the budget left is 1 minus its size, floored at 0. The tile sits after the dealer regime: its value is the signed reading (+0.99σ), its caption the budget left and the IV (1σ budget left 1% · 1d IV 16.0%), and its colour the band: muted under 0.5, the text ink under 1, the up or down colour from 1 on. The sigma and sigma_left outputs carry the two numbers on the live bar.

The curve frame. { rows: [[spot, gex], ...], markers, caption }: the rows are the fold's 61 points, each spot written two decimals finer than a tile's price so the points stay apart on any price, and markers carry the Spot marker (x: "spot", with a wash), the flip as a point callout when the points reach it (valign: "point" and series: "Net GEX" pin it on the line, show_value prints the spot in its label) and the peak and trough callouts with their readings. With no points (an empty book, a book with no spot) the frame carries no rows and no markers, so the curve clears. panel.line draws it with x: "number" over the spots (x_format: "usd") and no chrome, so the pane draws horizontal value hairlines only (The default look), smooth on the line (its series colour theme.text, the chart's text ink), fill_mode: "signed" with fill_positive_color: "theme.up", fill_negative_color: "theme.down" and fill_fade, y_zero so the zero line always shows, legend_style: "none" (the one series needs no legend entry: the title names it and the hover card reads it), a stats_row, hover_card and maximize; height_frac: 0.25 gives it the larger share of the space below the chart, the tiles 0.18, so with the CVD pane's 0.12 the three take 0.55 of the chart and the candles keep the rest.

The CVD pane. Each bar's aggressive buy volume minus its sell volume joins a ring of cvd_bars (96) deltas and the bar that falls out of the window leaves it; the sum is the cvd histogram. output("cvd", histogram, lower, { pane: "cvd", color_by: "cvd_sign", colors }) colours each bar from the cvd_sign ladder, theme.down while the sum is negative and theme.up while positive, and pane("cvd", { height_frac: 0.12, format: "si" }) sizes the pane and formats its axis; the pane carries the indicator's name, so it declares no title.

The legend entry. render.legend("regime_entry", { text: "regime_text", color: "theme.muted", color_by: "regime_sign", colors }) reads the string slot written on the live bar while net GEX has a reading (Neg Gamma (OI) | Flip · all expiries $85,722, or Pos Gamma (OI) | no flip within 50%) and colours it from the regime ladder; without a reading regime_sign is NaN and the muted color holds the dot.

What the settings do

  • CVD window, bars: How many bars the rolling cumulative volume delta (buys minus sells, summed) adds up.
  • Live net GEX: Net gamma exposure (GEX): the dollars dealers (options market makers) must trade per 1% move, over every expiry date.
  • Gamma flip: The price where dealers switch from calming price to pushing it, and its distance from the price.
  • Max pain: The strike (the option's price level) where option holders collect the least at expiry, and its distance from the price.
  • Dealer regime: Whether dealers calm moves (dips bought, rallies sold) or feed them (dips sold, rallies bought).
  • Sigma today: Today's move from the open in 1σ units, the day's expected move (how far option prices say it can move). Its caption shows how much of that move is left.
  • P/C ratio: Open puts (bets on a fall) per open call (bets on a rise), above 1 meaning puts favored.
  • 25D skew: Call minus put implied volatility (how big a move option prices expect), below zero when puts cost more. It reads options a fair way from the price (25 delta) on the nearest expiry date.
  • Net VEX: Net vega exposure (VEX): how much dealers gain or lose in dollars when option prices rise.
  • Net DEX: Net delta exposure (DEX): how much of the asset dealers must hold to hedge, in dollars, long or short.

Where it runs

It works on any chart with listed options. On crypto, that is any coin Deribit lists options for, such as BTC, ETH and SOL, on any exchange. For example, Binance Futures BTCUSDT and Binance spot ETHUSDT both work. On a US stock or ETF chart, every indicator can read that symbol's US listed options. On a futures chart from CME, the Chicago exchange, it reads that future's own options. US options data is 15 minutes behind unless you have real-time US options data. CME data is 10 minutes behind unless you have real-time CME data. A copy you run from the editor (where you write and run indicators) reads crypto, US stock and CME options. On a CME chart, accept the CME market data terms first. The chart in your browser reads these numbers ready-made by OpenMarket. Run on Cloud (the choice that runs it on OpenMarket's servers instead of your browser) cannot read them yet. Protected copies (published ones that run on OpenMarket's servers) cannot read them either. Both stop with an error that names each one. A chart in local mode (chart-local) cannot read them, because its options data comes from your own source. The chart sends the newest numbers on the live bar only, about every 30 seconds. Older bars get no options data. The cumulative volume delta reads the chart market's own buy and sell trades. Run it beside the Strike Matrix on a second chart for the whole desk. On a short timeframe, drag that chart's price axis to zoom out and see more strikes.

When data is missing

On a market with no listed options, it stops before loading anything. The error names the problem and the way out. On HYPERLIQUID_FUTURES/PURR, for example, it says PURR is not listed on Deribit. It then suggests a CME futures chart or a coin Deribit lists, such as BTC, ETH or SOL. Until the options numbers arrive, the tiles and the curve stay empty. The cumulative volume delta pane runs on its own meanwhile. A bar without buy and sell trades adds zero to it. With no open contracts at all, every tile prints n/a and the curve clears. A number with no reading prints n/a in its tile, never an old value. Without a current price for the options, the tiles still read. The Live net GEX tile's caption then drops the price, and the flip drops its distance from the price. The 25D skew reads n/a, and the curve has no points. With no gamma flip within 50% of the price, the curve shows no flip marker. Its tile then reads None within 50%. In the Console (the editor's prompt that shows a reading by its name), gamma_flip stays empty. A flip beyond the curve's 15% shows on its tile and in the legend, but not on the curve. The 25D skew also reads n/a when its first expiry date is not the nearest live one. Its caption then says front expiry. Sigma's tile reads n/a and gives the reason in its caption. Waiting for today's open means the chart has no first bar of today yet. No 1-day IV in this symbol's options means options price no implied volatility for the next 24 hours. Needs a daily or finer chart means each bar spans more than a day. In the Console, sigma and sigma_left then stay empty.

Customize it

  • A wider or narrower curve. The input's half_pct (15, above 0 and up to 50) is the curve's reach, percent of S0 each side, and points (61, 2 to 1000) its points. Set POINTS to the same count, since StrikeProfile(1, POINTS) holds that many and refuses a block that carries more, and add the new points to max_cells, which counts rows. Past about 650 points raise the curve frame's max_bytes too (16384): a point takes 19 to 22 bytes on the recorded books (24 at most) and the markers and caption about 420, so the frame passes 16384 near 665 to 840 points, where the run refuses it whole (wrun_frame_too_large; a frame is never truncated). The curve only draws: the flip tile reads the numbers fold's flip at any reach, and the callout shows once the points reach the flip.
  • A longer CVD window. cvd_bars up to 500.
  • Fewer tiles. Delete a row in writeTiles() and set columns on panel.tiles to the new row length; the panel lays the rest out.
  • A calendar day on crypto. Sigma prices one trading day as 1/252 of a year on every venue; on a coin that trades every day, set SIGMA_YEARS to 1.0 / 365.0.
  • Pin the venue. Change venue: "auto" to "deribit" and Run again to read the coin's Deribit chain even where the chart's market lists options of its own; "cme" reads a CME futures chart's chain.
  • The colours. Every colour on the desk is a theme word (theme.up, theme.down, theme.text) in the two panel.* declarations, the ladders and the frames (the callouts' colours are written in writeCurve(), the tiles' in writeTiles()), so it follows the chart's theme; a hex word in any of those places fixes a colour instead (Style anything).

Run it

  1. In the editor's Explorer, press the Templates icon ("Browse starter templates") and pick Options Dashboard under Beyond the time axis.
  2. Press Run on a BTC or ETH chart: the tiles and the curve appear below the chart once the chain arrives, the CVD pane at the bottom from the first bar.
  3. Hover a tile or the curve for its card; at the editor's Console prompt, type net_gex to read live net GEX, sigma for today's move in 1σ moves, or last 20 cvd for the rolling delta over the last 20 bars.

Concepts used