Estimated dealer positioning
Every 10 minutes this card estimates whether dealers (the market makers who hedge options) calm price or push it.
Long gamma (dealers calm price) tends to fade moves, and short gamma (dealers chase price) lets them run. A dashed line marks the gamma flip (the price where dealers switch from calming price to pushing it). Two more lines mark the call and put walls (the strikes with the most dealer hedging). On a 10-minute or finer chart with live options, use it to judge whether a move fades or runs.
Under the hood: the card reads the 10-minute options statistics (option_stats_10m). They carry net gamma per 1% move, charm, vanna, the walls, the gamma flip over all expiries and the magnet. They follow the open-interest model, where dealers are long the calls and short the puts. It also reads today's trades on this symbol (options_flow): delta bought at the ask minus delta sold at the bid. Dealers take the other side, so the book is an estimate and never an observed position (Data sources). It keeps each sample by its 10-minute time in a DayHistory. It reads the point value and clock through market.notional() and the market type through market.kind(). It draws two named panes and a render.hud card. It is the dealer-positioning template: Estimated Dealer Positioning under HUDs in the editor's starter list, and it compiles as written.
The wrun indicator
// Estimated Dealer Positioning: every 10 minutes, will dealers (the market makers who hedge options) calm price or push
// it? Gamma (how fast dealers must hedge as price moves) decides which. Long gamma (dealers calm price): they sell
// rallies and buy dips, so price tends to calm. Short gamma (dealers chase price): they buy rallies and sell dips, so
// price tends to trend. Lines on price mark the call and put walls (the strikes with the most dealer hedging). They
// often act as a ceiling and a floor. A dashed line marks the gamma flip (the price where dealers switch from calming
// price to pushing it). The magnet line marks the strike with the most dealer gamma, which tends to pull price. Two
// panes under the chart track net gamma and the position today's options trades left dealers holding. Use it to judge
// whether a move is likely to fade or run. Dealers' positions are an estimate from open interest (contracts still held
// open) and today's trades, never seen directly.
//
// Under the hood: dealers' positions are not observed. The book is the open-interest model of the 10-minute options
// statistics (option_stats_10m: dealers long the calls and short the puts, net gamma in USD per 1% move, charm in
// dollar delta per day, vanna in dollar delta per volatility point, the walls, the gamma flip and the magnet), and
// today's flow assumes dealers took the other side of every print at the ask or at the bid (options_flow on the
// chart's underlying: the share delta bought at the ask minus the share delta sold at the bid, summed since the
// session's first bar in view). From those the card reads: the gamma regime (the sign of net gamma, the options kit's
// dealerRegime) and the hedge it implies (long gamma sells a rally and buys a drop, short gamma chases both), the
// hedge per 1% move, the charm drift to the close (16:00 New York, the next day's from the evening session of a CME
// index future; no close, so no drift, on any other CME root; on crypto the end of the UTC day), the hedge a
// one-point IV drop calls for through vanna, the dealer delta today's flow left behind (in USD through the market's
// point value), and net gamma against 10, 20 and 30 minutes ago and its percentile among the window's samples. A pane
// under the chart draws net gamma as a step line, in the up colour when dealers are long gamma and the down colour
// when short, and a second pane the dealer delta from today's flow; the walls, the data plane's gamma flip over all
// expiries (the gamma curve's zero nearest spot, the options kit's rule) and the magnet ride the price. The history
// is short today (the 10-minute statistics start when the data plane switches the job on): the percentile needs
// Minimum history (40 samples, about a US session, under seven hours on crypto and CME, which trade around the
// clock), and until then the card says how many there are. Charts of 10 minutes or finer on the underlyings the data
// plane samples every ten minutes (every one whose options quote live, a coin from when its samples start); an
// underlying with daily statistics (option_daily) and no 10-minute rows reads "No live option quotes, daily numbers
// only".
param.int("lookback", 400, { min: 40, max: 2000, label: "Window, samples", description: "How many past 10-minute samples the percentile ranks net gamma against. 400 is about ten US sessions, under three days on crypto and CME." });
param.int("min_samples", 40, { min: 10, max: 2000, label: "Minimum history, samples", description: "How many samples the percentile needs before it shows." });
param.bool("show_levels", true, { label: "Levels", description: "Draw the walls, the gamma flip and the magnet on price. The call and put walls are the strikes with the most dealer hedging. The magnet is the strike with the most dealer gamma, which tends to pull price." });
input("close", ohlcv.close); // the chart's own close: the grid
input("gex", option_stats_10m.net_gex, { missing: "nan", description: "Net gamma: the dollars dealers must trade for each 1% move, from the options statistics every ten minutes." }); // lands on the bar holding the sample, NaN elsewhere
input("charm", option_stats_10m.net_charm, { missing: "nan", description: "Net charm: how far the dealers' hedge drifts each day as time passes, in dollars." });
input("vanna", option_stats_10m.net_vanna, { missing: "nan", description: "Net vanna: how far the dealers' hedge shifts for each point of implied volatility, in dollars." });
input("call_wall", option_stats_10m.call_wall, { missing: "nan", description: "The call wall: the strike with the most call gamma, often a ceiling." });
input("put_wall", option_stats_10m.put_wall, { missing: "nan", description: "The put wall: the strike with the most put gamma, often a floor." });
input("flip", option_stats_10m.gamma_flip, { missing: "nan", description: "The gamma flip over all expiries: the price nearest now where dealer gamma crosses zero." });
input("magnet", option_stats_10m.gamma_magnet, { missing: "nan", description: "The magnet: the strike with the most dealer gamma, which tends to pull price." });
input("spot", option_stats_10m.underlying_price, { missing: "nan", description: "This symbol's price when the sample was taken." });
input("daily_spot", option_daily.underlying_price, { missing: "nan", description: "This symbol's price in the daily options statistics. Daily numbers with no 10-minute ones mean no live option quotes." }); // lands on the first bar of its UTC day, NaN elsewhere
input("delta_ask", options_flow.share_delta_ask, { missing: "zero", description: "Delta bought at the ask (buyers paying the seller's price) in this bar: customers buying." }); // the chart's underlying (scope ticker); a quiet bar reads 0
input("delta_bid", options_flow.share_delta_bid, { missing: "zero", description: "Delta sold at the bid (sellers taking the buyer's price) in this bar: customers selling." });
market.notional(); // the market's point value and clock: the flow delta in USD, the close the charm drifts to, the trade date
market.kind(); // what the market trades: on CME only an index future (5) closes at 16:00 New York
pane("gex", { title: "Dealer gamma, USD per 1% move", height_frac: 0.18, format: "usd" });
pane("flow", { title: "Dealer delta from today's flow, USD", height_frac: 0.14, format: "usd" });
output("call_wall_line", line, overlay, { color: "theme.up", width: 1, step: true, label: "Call wall", format: "price", description: "The call wall, the strike with the most call gamma. It holds until the next sample." });
output("put_wall_line", line, overlay, { color: "theme.down", width: 1, step: true, label: "Put wall", format: "price", description: "The put wall, the strike with the most put gamma." });
output("flip_line", line, overlay, { color: "theme.muted", width: 1, step: true, line_style: "dashed", label: "Gamma flip · all expiries", format: "price", description: "The gamma flip over all expiries: the price nearest now where dealer gamma crosses zero." });
output("magnet_line", line, overlay, { color: "theme.muted", width: 1, step: true, label: "Magnet", format: "price", description: "The magnet, the strike with the most dealer gamma." });
output("net_gex", line, lower, { pane: "gex", width: 2, step: true, color_by: "gamma_code", colors: ["theme.down", "theme.muted", "theme.up"], label: "Net gamma", format: "usd", description: "Net dealer gamma in dollars per 1% move, every ten minutes. It draws in the up colour when dealers are long gamma, down when short." });
output("flow_delta", area, lower, { pane: "flow", color: "theme.text", width: 2, fill_opacity: 0.25, label: "Flow delta", format: "usd", description: "The delta today's options trades left dealers holding, in dollars. Dealers take the other side of what customers buy at the ask and sell at the bid." });
output("gamma_code", none, lower, { description: "The dealer regime as a code: 0 short gamma, 1 neutral (exactly zero), 2 long gamma." });
output("hedge_1pct", none, lower, { format: "usd", description: "What dealers trade if price rises 1%, in dollars. Negative means they sell, positive means they buy." });
output("charm_to_close", none, lower, { format: "usd", description: "What dealers trade by the close as time changes their hedge (charm), in dollars, negative to sell. The close is 16:00 New York, the next day's in a CME index future's evening session. On crypto it is the UTC day's end. Blank on other CME markets." });
output("vanna_iv_down", none, lower, { format: "usd", description: "What dealers trade if implied volatility drops one point, as their hedge changes with option prices (vanna), in dollars. Negative means they sell." });
output("chg_10", none, lower, { format: "usd", description: "Net gamma now minus net gamma 10 minutes ago, in dollars." });
output("chg_20", none, lower, { format: "usd", description: "The same against 20 minutes ago." });
output("chg_30", none, lower, { format: "usd", description: "The same against 30 minutes ago." });
output("gex_pct", none, lower, { description: "The percentile: the share of earlier samples in the window below net gamma now, 0 to 100." });
output("samples", none, lower, { description: "How many 10-minute samples the window holds." });
output("status", none, lower, { description: "0 not enough history for the percentile, 1 it shows, 2 the chart is coarser than 10 minutes." });
string("read", { max_bytes: 64 }); // the headline: the regime and what the hedge does
string("flow_text", { max_bytes: 64 }); // "Flow left dealers short $1.20M since 13:30 UTC"
string("history_text", { max_bytes: 48 });
string("title", { max_bytes: 64 });
render.hud("dealer_card", {
position: "bottom_right",
title: "{{title}}",
columns: 2,
tiles: [
tile.pill("Dealers, estimated", "read", { headline: true }),
tile.pill("Today's flow", "flow_text"),
tile.pill("Gamma vs its history", "history_text"),
tile.rows([
["Net gamma", "net_gex", "usd"],
["Hedge for a 1% rally", "hedge_1pct", "usd"],
["Charm hedge to the close", "charm_to_close", "usd"],
["Hedge if IV drops 1 point", "vanna_iv_down", "usd"],
["Dealer delta from flow", "flow_delta", "usd"],
["Gamma change, 10 min", "chg_10", "usd"],
["Gamma change, 20 min", "chg_20", "usd"],
["Gamma change, 30 min", "chg_30", "usd"],
["Percentile", "gex_pct", "0"],
]),
],
});
const SAMPLE_SEC = 600.0;
const CLOSE_MINUTE = 960.0; // 16:00 on New York's clock: the close of a US stock and of a CME index future's PM expiries
const INDEX = 5; // market.kind() of an index: on CME an index future, the one root that closes at 16:00 New York
const CAPACITY = 2000;
const samples = new DayHistory(CAPACITY); // net gamma per 10-minute sample, keyed by the sample's own 10-minute slot
const newYork = new Clock("America/New_York"); // the close the charm drift runs to, off crypto
const utc = new Clock("UTC");
let lookback = 400; // settings, read in onStart()
let need = 40;
let showLevels = true;
let pointValue = 0.0; // the market facts, read in onStart(): 0 where the host does not know the point value
let zone = 0;
let kind = 0;
let prevT: f64 = NaN; // the bar spacing
let barSec: f64 = NaN;
let lastT: f64 = NaN; // the newest sample, and what it carried, held
let gex: f64 = NaN;
let charm: f64 = NaN;
let vanna: f64 = NaN;
let callWall: f64 = NaN;
let putWall: f64 = NaN;
let flip: f64 = NaN;
let magnet: f64 = NaN;
let spot: f64 = NaN;
let pctNow: f64 = NaN;
let dailyRows = false; // a daily statistics row landed on a loaded bar: the underlying has daily numbers
let flowDay: f64 = NaN; // the session the flow sums, from its first bar in view
let flowFirstT: f64 = NaN;
let customerShares = 0.0;
function onStart(): void {
lookback = i32(p_lookback());
need = i32(p_min_samples());
if (need > lookback) need = lookback;
showLevels = p_show_levels() > 0.5;
pointValue = p_market_point_value();
zone = i32(p_market_zone());
kind = i32(p_market_kind());
}
/** Net gamma's change from the sample minutes before the newest; NaN when the window holds none there. */
function changeFrom(minutes: f64): f64 {
if (samples.count() < 2) return NaN;
const ago = samples.agoOf(samples.day(0) - minutes / 10.0);
return ago < 0 ? NaN : samples.value(0) - samples.value(ago);
}
/** Minutes from the bar to the close: 16:00 New York on a US stock (0 after it) and on a CME index future, whose
* evening session runs to the next day's; NaN on any other CME root, whose close the statistics do not name; on
* crypto, which trades around the clock, the end of the UTC day. */
function minutesToClose(t: f64): f64 {
if (zone == 0) {
utc.update(t);
return 1440.0 - f64(utc.hour() * 60 + utc.minute());
}
if (zone == 2 && kind != INDEX) return NaN;
newYork.update(t);
const now = f64(newYork.hour() * 60 + newYork.minute());
return now < CLOSE_MINUTE ? CLOSE_MINUTE - now : zone == 2 ? CLOSE_MINUTE + 1440.0 - now : 0.0;
}
function sbUsd(v: f64): void { // "$1.20M"
sb_text("$");
const a = Math.abs(v);
if (a >= 1.0e9) {
sb_f64(a / 1.0e9, 2);
sb_text("B");
} else if (a >= 1.0e6) {
sb_f64(a / 1.0e6, 2);
sb_text("M");
} else if (a >= 1.0e3) {
sb_f64(a / 1.0e3, 2);
sb_text("K");
} else sb_f64(a, 0);
}
function sbClock(t: f64): void { // "13:30"
utc.update(t);
if (utc.hour() < 10) sb_text("0");
sb_int(utc.hour());
sb_text(":");
if (utc.minute() < 10) sb_text("0");
sb_int(utc.minute());
}
function writeWords(coarse: bool): void {
sb_clear();
if (coarse) sb_text("Needs a 10-minute or finer chart");
else if (isNaN(gex) && dailyRows) sb_text("No live option quotes, daily numbers only"); // daily rows, no 10-minute row loaded
else if (isNaN(gex)) sb_text("Waiting for the 10-minute options statistics");
else {
const regime = dealerRegime(gex);
sb_text(regime > 0.0 ? "Long gamma: dealers calm price, " : regime < 0.0 ? "Short gamma: dealers chase price, " : "Neutral gamma: no dealer hedging, ");
sbUsd(gex);
sb_text(" per 1% move");
}
str_read_sb();
sb_clear();
if (coarse || isNaN(flowFirstT)) sb_text("No options trades yet");
else {
const dealerUsd = -notional(customerShares, spot > 0.0 ? spot : bar.close(), pointValue, zone);
sb_text(dealerUsd >= 0.0 ? "Flow left dealers long " : "Flow left dealers short ");
sbUsd(dealerUsd);
sb_text(" since ");
sbClock(flowFirstT);
sb_text(" UTC");
}
str_flow_text_sb();
sb_clear();
const held = samples.span(lookback);
if (coarse || samples.count() == 0) sb_text("No history");
else if (held < need) {
sb_text("Not enough history yet: ");
sb_int(held);
sb_text(" of ");
sb_int(need);
sb_text(" samples");
} else {
sb_text("Above ");
sb_f64(pctNow, 0);
sb_text("% of the last ");
sb_int(held);
sb_text(" samples");
}
str_history_text_sb();
sb_clear();
sb_text("Estimated dealer positioning");
if (!coarse && !isNaN(lastT)) {
sb_text(", ");
sbClock(lastT);
sb_text(" UTC");
}
str_title_sb();
}
// onBar() runs once per bar: the spacing; the bar's flow into the session's sum (a new trade date on the market's own
// clock starts a new sum); a daily row when one lands; the 10-minute sample when it lands (its readings kept, net gamma
// into the window); every bar writes the held readings.
function onBar(): void {
const t = bar.time();
if (!isNaN(prevT) && t > prevT && (isNaN(barSec) || t - prevT < barSec)) barSec = t - prevT;
prevT = t;
const coarse = !isNaN(barSec) && barSec > SAMPLE_SEC + 1.0;
const day = sessionTradeDate(t, zone, zone == 2 ? 1020.0 : 0.0); // CME's trade day opens at 17:00 Chicago
if (day != flowDay) {
flowDay = day;
flowFirstT = NaN;
customerShares = 0.0;
}
const ask = in_delta_ask();
const bid = in_delta_bid();
if (!isNaN(ask) && !isNaN(bid)) {
if (isNaN(flowFirstT)) flowFirstT = t;
customerShares += ask - bid;
}
if (!isNaN(in_daily_spot())) dailyRows = true;
const g = in_gex();
if (!coarse && !isNaN(g)) {
lastT = t;
gex = g;
charm = in_charm();
vanna = in_vanna();
callWall = in_call_wall();
putWall = in_put_wall();
flip = in_flip();
magnet = in_magnet();
spot = in_spot();
samples.push(Math.floor(t / SAMPLE_SEC), g); // each sample's 10-minute slot: a gap of slots is a gap of time
pctNow = samples.span(lookback) >= need ? samples.percentile(lookback) : NaN;
}
const levels = showLevels && !coarse;
out_call_wall_line(levels ? callWall : NaN);
out_put_wall_line(levels ? putWall : NaN);
out_flip_line(levels ? flip : NaN);
out_magnet_line(levels ? magnet : NaN);
out_net_gex(coarse ? NaN : gex);
out_gamma_code(coarse || isNaN(gex) ? NaN : 1.0 + dealerRegime(gex));
const price = spot > 0.0 ? spot : bar.close();
out_flow_delta(coarse || isNaN(flowFirstT) ? NaN : -notional(customerShares, price, pointValue, zone));
out_hedge_1pct(coarse ? NaN : -gex);
out_charm_to_close(coarse || isNaN(charm) ? NaN : (-charm * minutesToClose(t)) / 1440.0);
out_vanna_iv_down(coarse ? NaN : vanna);
out_chg_10(coarse ? NaN : changeFrom(10.0));
out_chg_20(coarse ? NaN : changeFrom(20.0));
out_chg_30(coarse ? NaN : changeFrom(30.0));
out_gex_pct(coarse ? NaN : pctNow);
out_samples(coarse ? NaN : f64(samples.span(lookback)));
out_status(coarse ? 2.0 : samples.span(lookback) >= need ? 1.0 : 0.0);
if (bar.isLast()) writeWords(coarse);
}How it works
The hedges, signed as trades. Negative sells, positive buys. A 1% rally moves dealer delta by net gamma, so dealers trade minus net gamma. Charm moves dealer delta by net charm a day, so over the minutes left to the close dealers trade minus net charm times that fraction of a day. On a CME index future (market.kind() 5, as on ES and NQ) the evening session from 17:00 Chicago belongs to the next trade date, so its close is the next day's 16:00 New York. Any other CME root closes on its own clock, which the 10-minute statistics do not name, so there the charm row reads -. A one-point IV drop moves dealer delta by minus net vanna, so dealers trade plus net vanna.
The flow. Each bar's share delta at the ask minus at the bid is what customers bought; the sum since the session's first bar in view is their net, and dealers hold the opposite, in USD through notional(): the newest sample's price times the market's point value (50 on ES), and no reading on a CME chart whose point value the host does not hold. A bar with no prints reads 0 (missing: "zero"); a new trade date on the market's own clock starts a new sum (sessionTradeDate(): the New York date on a US stock, the UTC day on crypto, the CME trade date that opens at 17:00 Chicago).
The lookbacks. Each sample joins a DayHistory under its 10-minute slot, so "10 minutes ago" is the slot before, and a gap in the samples is a gap, never a neighbour.
What the settings do
- Window, samples: how many past 10-minute samples the percentile ranks net gamma against, 400 by default (about ten US sessions).
- Minimum history, samples: how many samples the percentile waits for before it shows, 40 by default.
- Levels: draws the call and put walls (the strikes with the most dealer hedging) and the gamma flip on price. It also draws the magnet, the strike with the most dealer gamma, which tends to pull price.
- Dealers, estimated: whether dealers calm price (long gamma) or chase it (short gamma), with the dollars they trade for each 1% move.
- Today's flow: the position today's options trades left dealers holding, and the time it counts from.
- Gamma vs its history: where net gamma ranks among past samples, or how many samples it still needs.
- Net gamma: the dollars dealers must trade for each 1% move, above zero when their hedging calms price.
- Hedge for a 1% rally: what dealers sell (negative) or buy (positive) if price rises 1%.
- Charm hedge to the close: what dealers trade from now to the close as time alone changes their hedge (charm), if price stays put.
- Hedge if IV drops 1 point: what dealers trade if implied volatility (how big a move option prices expect) falls one point. Their hedge changes with option prices (vanna).
- Dealer delta from flow: what today's options trades left dealers holding, in dollars of delta (how much stock dealers must hold to hedge).
- Gamma change, 10 min: how much net gamma moved in the last 10 minutes.
- Gamma change, 20 min: how much net gamma moved in the last 20 minutes.
- Gamma change, 30 min: how much net gamma moved in the last 30 minutes.
- Percentile: the share of past samples below net gamma now, from 0 to 100.
Where it runs
It needs a chart of 10 minutes or finer. The 10-minute options statistics cover every symbol whose options quote live. For a coin they start on the day OpenMarket began recording them. On CME (Chicago futures exchange) they cover each futures contract whose options quote live. Other contracts have daily numbers only. Any other symbol has no 10-minute numbers, and the indicator's legend on the chart says so. On a coin with listed options the chart reads the coin's own options. So does a copy you run from the editor (where you write and run your own indicators). On a US stock every indicator in the browser can read them. They run 15 minutes behind unless you have real-time US options data. On a CME futures chart every indicator in the browser can read them too, once you accept the CME market data terms (Limitations). They run 10 minutes behind unless you have real-time CME data. On a US stock the statistics come from delayed quotes. So the newest sample trails the market by about 15 minutes.
When data is missing
The 10-minute statistics start on the day OpenMarket began recording them. The numbers show from the first sample. The percentile waits for Minimum history: 40 samples, about one US session, or under seven hours on crypto and CME. Until then the card's Gamma vs its history line reads "Not enough history yet: 12 of 40 samples". The flow adds up from the session's first bar on screen, and the card's Today's flow line names that time. Before the first sample the card reads "Waiting for the 10-minute options statistics". It reads "No live option quotes, daily numbers only" when the symbol has daily statistics but no 10-minute ones. That means its options do not quote live. A chart coarser than 10 minutes reads "Needs a 10-minute or finer chart". Older 10-minute statistics follow an earlier gamma flip rule and often have no flip. The gamma flip line stays empty there. That covers US listed options before 2026-10-20, CME before 2026-10-21 12:10 UTC and a few coins' options (Data sources).
Customize it
- Another window.
lookbacksets the samples the percentile reads (400 is about ten US sessions, under three days on crypto and CME, which trade around the clock). - A clean price pane. Turn Levels off.
Run it
- In the editor's Explorer, press the Templates icon and pick Estimated Dealer Positioning under HUDs.
- Press Run on SPY's 5-minute chart: the levels and the card draw at your own tier, and the legend names the tier.
- At the editor's Console prompt, type
net_gex,hedge_1pctandflow_delta.
Concepts used
- Data sources for
option_stats_10mandoptions_flow - Options kit for
DayHistory - The market's facts for
market.kind(), which tells a CME index future from the other roots - Panes for the two panes
- HUD cards for the card