Exposure history
One column per session shows how dealers (the market makers who hedge options) are positioned, on the measure you pick.
On gamma, above zero is long gamma (dealers calm price), and below zero is short gamma (dealers chase price). Lines mark each session's gamma flip (the price where dealers switch from calming price to pushing it). Others mark the call and put walls (the strikes with the most dealer hedging). On a daily or finer chart, the card's rank shows when positioning is unusual for this symbol.
Under the hood: each session's reading is the daily options statistics' close of that session (option_daily). They follow the open-interest model, where dealers are long the calls and short the puts. On an intraday chart each reading holds until the next one lands. The gamma flip covers all expiries, labelled Gamma flip · all expiries (Data sources). It keeps one reading per session in a DayHistory for the change and the percentile. It draws sign-coloured columns and step lines (Plotting) and a render.hud card whose value tile carries its change. It is the exposure-history template: Exposure History under Beyond the time axis in the editor's starter list, and it compiles as written.
The wrun indicator
// Exposure History: one column per session shows how dealers (the market makers who hedge options) are positioned in
// this symbol. Pick the measure in Lens. Columns above zero use the up colour, below zero the down colour. Gamma (how
// fast dealers must hedge as price moves) shows the regime. Above zero is long gamma (dealers calm price): they sell
// rallies and buy dips, so price tends to calm. Below zero is short gamma (dealers chase price): they buy rallies and
// sell dips, so price tends to trend. Lines on price mark each session's call and put walls (the strikes with the most
// dealer hedging). Another marks the gamma flip (the price where dealers switch from calming price to pushing it). A
// third marks max pain, the price where the nearest expiry's options pay out least. A card adds the change from the
// last session and how today ranks against past sessions. Use it to spot unusual dealer positioning.
//
// Under the hood: the readings come from the daily options statistics (option_daily). The Lens setting picks one
// greek's net exposure on the open-interest basis the statistics use (dealers long the calls and short the puts):
// gamma in USD per 1% move, delta in dollar delta (each option's own sign), vega in USD per volatility point, charm
// in dollar delta per day, vanna in dollar delta per volatility point. It is drawn as columns in a pane under the
// chart, in the up colour above zero and the down colour below, with the front expiry's gamma as a step line on the
// gamma lens; the session's call wall, put wall, gamma flip (the data plane's, over all expiries: the gamma curve's
// zero nearest spot, the options kit's rule) and front max pain are drawn on price as step lines when Levels is on. A
// card at the bottom right reads the regime (the sign of net gamma, the options kit's dealerRegime: long gamma
// dampens moves, short gamma amplifies them), the net exposure, its change from the prior session, its percentile
// among the window's earlier sessions, spot against the gamma flip and the levels. Each session's reading is the
// statistics job's close of that session, held on an intraday chart until the next one lands. The statistics are
// short today (they start when the data plane switches the daily job on): the exposure and the levels read from the
// first session, the change from the second, and the percentile needs Minimum history (20 sessions); until then the
// card says how many sessions there are. US stock charts, daily or finer.
param.choice("lens", ["Gamma", "Delta", "Vega", "Charm", "Vanna"], "Gamma", { label: "Lens", description: "Which dealer measure the columns show. Gamma: hedging per 1% move. Delta: stock dealers hold to hedge. Vega: gain as option prices rise. Charm, Vanna: how that hedge changes with time or option prices." });
param.bool("show_levels", true, { label: "Levels", description: "Draw each session's call wall, put wall, gamma flip and front-expiry max pain on the price chart." });
param.int("lookback", 252, { min: 20, max: 520, label: "Window, sessions", description: "How many past sessions the percentile ranks today against. 252 is about a year." });
param.int("min_sessions", 20, { min: 5, max: 520, label: "Minimum history, sessions", description: "How many sessions the percentile needs before it shows." });
input("close", ohlcv.close); // the chart's own close: the grid
input("gex", option_daily.net_gex, { missing: "nan", description: "Net gamma: the dollars dealers must trade for each 1% move, one reading per session from the daily options statistics." }); // every daily input lands on the first bar of its day, NaN elsewhere
input("dex", option_daily.net_dex, { missing: "nan", description: "Net delta: the position dealers hold, in dollars, each option in its own sign." });
input("vex", option_daily.net_vex, { missing: "nan", description: "Net vega: what dealers gain or lose per point of implied volatility, in dollars." });
input("charm", option_daily.net_charm, { missing: "nan", description: "Net charm: how far the dealers' hedge drifts each day as time passes, in dollars." });
input("vanna", option_daily.net_vanna, { missing: "nan", description: "Net vanna: how far the dealers' hedge shifts for each point of implied volatility, in dollars." });
input("front_gex", option_daily.front_net_gex, { missing: "nan", description: "Net gamma of the nearest live expiry, in dollars per 1% move." });
input("call_wall", option_daily.call_wall, { missing: "nan", description: "The call wall: the call strike with the most dealer hedging, often a ceiling." });
input("put_wall", option_daily.put_wall, { missing: "nan", description: "The put wall: the put strike with the most dealer hedging, often a floor." });
input("flip", option_daily.gamma_flip, { missing: "nan", description: "The gamma flip over all expiries: the price nearest now where dealer gamma crosses zero." });
input("max_pain", option_daily.max_pain_front, { missing: "nan", description: "Max pain of the front expiry: the price where its open options would pay out the least." });
input("spot", option_daily.underlying_price, { missing: "nan", description: "This symbol's price when the statistics were taken." });
output("call_wall_line", line, overlay, { color: "theme.up", width: 1, step: true, label: "Call wall", format: "price", description: "The session's call wall, held until the next session" });
output("put_wall_line", line, overlay, { color: "theme.down", width: 1, step: true, label: "Put wall", format: "price", description: "The session's put wall" });
output("flip_line", line, overlay, { color: "theme.muted", width: 1, step: true, line_style: "dashed", label: "Gamma flip · all expiries", format: "price", description: "The session's gamma flip over all expiries: the price nearest now where dealer gamma crosses zero." });
output("max_pain_line", line, overlay, { color: "theme.muted", width: 1, step: true, label: "Max pain", format: "price", description: "The session's max pain for the front expiry: where its open options pay out the least." });
output("exposure", histogram, lower, { color_by: "sign", colors: ["theme.down", "theme.up"], label: "Net exposure", format: "usd", description: "The session's net dealer exposure for the chosen measure, in its unit (see the Lens setting)." });
output("front_line", line, lower, { color: "theme.text", opacity: 0.55, width: 1.5, step: true, label: "Front gamma", format: "usd", description: "Net gamma of the nearest expiry. It shows on the gamma lens only." });
output("sign", none, lower, { description: "1 when the net exposure is at or above zero, 0 below" });
output("change", none, lower, { description: "The net exposure's change from the prior session, same unit" });
output("pctile", none, lower, { description: "The percentile: the share of the window's earlier sessions below today's net exposure, 0 to 100." });
output("flip_dist", none, lower, { description: "How far the price sits from the gamma flip over all expiries, in percent. Above zero means price is above the flip." });
output("regime", none, lower, { description: "The headline's regime as a code: 0 short gamma, 1 neutral, 2 long gamma. Other lenses use the sign of their net the same way." });
output("wall_call", none, lower, { format: "price", description: "The call wall, for the card" });
output("wall_put", none, lower, { format: "price", description: "The put wall, for the card" });
output("pain", none, lower, { format: "price", description: "The front expiry's max pain, for the card." });
output("sessions", none, lower, { description: "How many sessions of statistics the window holds." });
output("status", none, lower, { description: "0 not enough history for the percentile, 1 it shows, 2 the chart is coarser than a day." });
string("read", { max_bytes: 64 }); // the headline
string("title", { max_bytes: 64 });
string("history_text", { max_bytes: 48 }); // "62nd percentile of 120 sessions" or the wait
render.hud("exposure_card", {
position: "bottom_right",
title: "{{title}}",
columns: 2,
tiles: [
tile.pill("Dealers", "read", { headline: true }),
tile.pill("Against past sessions", "history_text"),
tile.value("Net exposure", "exposure", { format: "usd", delta: "change" }),
tile.rows([
["Change from last session", "change", "usd"],
["Percentile", "pctile", "0"],
["Front expiry gamma", "front_line", "usd"],
["Distance to gamma flip, %", "flip_dist", "0.00"],
["Call wall", "wall_call", "price"],
["Put wall", "wall_put", "price"],
["Max pain, front expiry", "pain", "price"],
["Sessions in window", "sessions", "int"],
]),
],
});
const DAY = 86400.0;
const CAPACITY = 520;
const LENS_WORDS: String[] = ["gamma", "delta", "vega", "charm", "vanna"]; // the lens in the card's words
const MONTHS: String[] = ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"];
const history = new DayHistory(CAPACITY); // one net exposure per session, the lens's greek
const dateClock = new Clock("UTC");
let lens = 0; // settings, read in onStart()
let showLevels = true;
let lookback = 252;
let need = 20;
let prevT: f64 = NaN; // the bar spacing
let barSec: f64 = NaN;
let netNow: f64 = NaN; // the session readings, held
let changeNow: f64 = NaN;
let pctNow: f64 = NaN;
let frontNow: f64 = NaN;
let callWall: f64 = NaN;
let putWall: f64 = NaN;
let flip: f64 = NaN;
let pain: f64 = NaN;
let spot: f64 = NaN;
let levelsDay: f64 = NaN;
function onStart(): void {
lens = i32(p_lens());
showLevels = p_show_levels() > 0.5;
lookback = i32(p_lookback());
need = i32(p_min_sessions());
if (need > lookback) need = lookback;
}
function lensInput(): f64 {
if (lens == 1) return in_dex();
if (lens == 2) return in_vex();
if (lens == 3) return in_charm();
if (lens == 4) return in_vanna();
return in_gex();
}
function measure(): void {
netNow = history.value(0);
changeNow = history.count() >= 2 ? netNow - history.value(1) : NaN;
pctNow = history.span(lookback) >= need ? history.percentile(lookback) : NaN;
}
function sbUsd(v: f64): void { // "+$1.20M", "-$350.00K"
sb_text(v < 0.0 ? "-$" : "+$");
const a = Math.abs(v);
if (a >= 1.0e12) {
sb_f64(a / 1.0e12, 2);
sb_text("T");
} else 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, 2);
}
function sbDay(day: f64): void { // "16OCT"
dateClock.update(day * DAY);
if (dateClock.dayOfMonth() < 10) sb_text("0");
sb_int(dateClock.dayOfMonth());
sb_text(MONTHS[dateClock.month() - 1]);
}
function writeWords(coarse: bool): void {
const held = history.span(lookback);
sb_clear();
if (coarse) sb_text("Needs a daily or finer chart");
else if (history.count() == 0) sb_text("Waiting for the daily options statistics");
else if (lens == 0) {
const regime = dealerRegime(netNow);
sb_text(regime > 0.0 ? "Long gamma, dealers calm price: " : regime < 0.0 ? "Short gamma, dealers chase price: " : "Neutral gamma, no dealer hedging: ");
sbUsd(netNow);
} else {
sb_text("Net ");
sb_text(LENS_WORDS[lens]);
sb_text(" ");
sbUsd(netNow);
}
str_read_sb();
sb_clear();
if (coarse || history.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(" sessions");
} else {
sb_text("Above ");
sb_f64(pctNow, 0);
sb_text("% of the last ");
sb_int(held);
sb_text(" sessions");
}
str_history_text_sb();
sb_clear();
sb_text("Exposure history, ");
sb_text(LENS_WORDS[lens]);
if (!coarse && history.count() > 0) {
sb_text(", as of ");
sbDay(history.day(0));
}
str_title_sb();
}
/** The headline's regime: on the gamma lens the dealer regime (the kit's dealerRegime) plus 1, on the other lenses the
* net's sign the same way: 0 below zero, 1 at it, 2 above. */
function regimeCode(): f64 {
if (lens == 0) return 1.0 + dealerRegime(netNow);
return netNow > 0.0 ? 2.0 : netNow < 0.0 ? 0.0 : 1.0;
}
// onBar() runs once per bar: the spacing, then the session's statistics when they land (the lens's exposure measured
// once, the levels kept); every bar writes the held readings, so an intraday chart draws each session as a step.
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 > 1.5 * DAY;
if (!coarse) {
const day = Math.floor(t / DAY);
const v = lensInput();
if (!isNaN(v) && history.push(day, v)) measure();
const landed = !isNaN(in_gex()) || !isNaN(in_call_wall()) || !isNaN(in_spot());
if (landed && day != levelsDay) { // the session's levels, once; a value the session lacks reads NaN
levelsDay = day;
frontNow = in_front_gex();
callWall = in_call_wall();
putWall = in_put_wall();
flip = in_flip();
pain = in_max_pain();
spot = in_spot();
}
}
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_max_pain_line(levels ? pain : NaN);
out_exposure(coarse ? NaN : netNow);
out_front_line(!coarse && lens == 0 ? frontNow : NaN);
out_sign(coarse || isNaN(netNow) ? NaN : netNow >= 0.0 ? 1.0 : 0.0);
out_change(coarse ? NaN : changeNow);
out_pctile(coarse ? NaN : pctNow);
out_flip_dist(!coarse && spot > 0.0 && flip > 0.0 ? (spot / flip - 1.0) * 100.0 : NaN);
out_regime(coarse || isNaN(netNow) ? NaN : regimeCode());
out_wall_call(coarse ? NaN : callWall);
out_wall_put(coarse ? NaN : putWall);
out_pain(coarse ? NaN : pain);
out_sessions(coarse ? NaN : f64(history.span(lookback)));
out_status(coarse ? 2.0 : history.span(lookback) >= need ? 1.0 : 0.0);
if (bar.isLast()) writeWords(coarse);
}How it works
One reading per session. Each field lands on the session's own bar (every bar of a daily chart, the first bar of its day on an intraday chart) and reads NaN elsewhere. The lens's value joins a DayHistory; the levels are taken once per session, and a level the session lacks reads empty rather than the previous session's.
The regime. On the gamma lens the sign of net gamma, through the options kit's dealerRegime, says what dealers' hedging does: positive, they sell rallies and buy drops (moves dampen); negative, they chase both (moves extend); exactly zero reads neutral. The other lenses read their own sign. The level on price is the data plane's gamma flip over all expiries, the gamma curve's zero nearest spot by the options kit's rule (The canonical numbers), labelled Gamma flip · all expiries.
The change and the percentile. The change is the newest session's net exposure minus the one before it; the percentile is the share of the window's earlier sessions below today's.
What the settings do
- Lens: which dealer measure the columns show. Gamma: what dealers trade per 1% move. Delta: how much stock dealers must hold to hedge. Vega: how much dealers gain or lose when option prices rise. Charm, Vanna: how that hedge changes with time (charm) or with option prices (vanna).
- Levels: draws each session's call and put walls, gamma flip and max pain on price. Max pain is the price where the nearest expiry's options pay out least.
- Window, sessions: how many past sessions the percentile ranks today against, 252 by default (about a year).
- Minimum history, sessions: how many sessions the percentile waits for before it shows, 20 by default.
- Dealers: on gamma, whether dealers calm price (long gamma) or chase it (short gamma), with net gamma. On other measures, the net in dollars.
- Against past sessions: where today ranks among past sessions, or how many sessions it still needs.
- Net exposure: the session's net for the chosen measure, with its change from the last session.
- Change from last session: how much the net moved since the session before.
- Percentile: the share of past sessions below today's net, from 0 to 100.
- Front expiry gamma: net gamma of the nearest expiry alone.
- Distance to gamma flip, %: how far the price sits above (positive) or below (negative) the gamma flip.
- Call wall: the call strike (the option's price level) with the most dealer hedging, often a ceiling.
- Put wall: the put strike with the most dealer hedging, often a floor.
- Max pain, front expiry: the price where the front expiry's open options would pay out the least.
- Sessions in window: how many sessions of statistics the window holds.
Where it runs
It needs a daily or finer chart. On a coin with listed options the chart reads the coin's own daily options statistics. So does a copy you run from the editor (where you write and run your own indicators). On a US stock chart every indicator in the browser can read them. They run 15 minutes behind unless you have real-time US options data. On a futures chart from CME (Chicago futures exchange), 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. Crypto trades every day, so the default Window, sessions of 252 is about eight months there. Set it to 365 for a calendar year.
When data is missing
The daily statistics start on the day OpenMarket began recording them. The exposure and the levels show from the first session, and the change from the second. The percentile waits for Minimum history, 20 sessions. Until then the card's Against past sessions line reads "Not enough history yet: 7 of 20 sessions". Before the first session the card reads "Waiting for the daily options statistics". A chart coarser than a day reads "Needs a daily or finer chart". US listed options' daily statistics through 2026-10-20 follow an earlier gamma flip rule and often have no flip. The gamma flip line stays empty on those sessions (Data sources).
Customize it
- Another greek. Switch Lens to Delta, Vega, Charm or Vanna.
- A clean price pane. Turn Levels off.
- Another year.
lookbacksets the sessions the percentile reads.
Run it
- In the editor's Explorer, press the Templates icon and pick Exposure History under Beyond the time axis.
- Press Run on a US stock's daily chart.
- At the editor's Console prompt, type
exposure,changeandpctile.
Concepts used
- Data sources for
option_dailyand its units - Options kit for
DayHistory - Plotting for the columns and the step lines
- HUD cards for the card