Option stance
Not a mood score: one card rates five common options trades With, Neutral or Against.
The trades are selling options, betting option prices fall, buying for a move, buying long-dated and buying cheap far-out options. Stances weigh how pricey options are this past year and if dealers (the market makers who hedge options) calm price. Use it as a backdrop check before you trade options, not as a trade signal. It needs 60 trading days of data on a coin, a US stock or a CME (Chicago futures exchange) future.
Under the hood: the volatility regime is the IV rank and percentile of the session's 30-day IV over the window. The positioning is dealer gamma on the open-interest basis, through the options kit's dealerRegime. Long gamma dampens moves, short gamma amplifies them, and exactly zero is neutral. It also reads spot against the data plane's gamma flip over all expiries, the gamma curve's zero nearest spot by the options kit's rule. The rest are the call and put walls, the put/call volume and open-interest ratios, the 25 delta risk reversal and the front expiry's implied move. It reads scalar option_daily inputs and the market.earnings_next_ms() fact through earningsMs() (Earnings dates). It keeps the IV history in the options kit's DayHistory (Options kit). It draws a render.hud card of pill tiles, one per stance, in the chart's default look (HUD cards, The default look). It is also the option-stance template, the Option Stance card under HUDs in the editor's starter list, which compiles as written.
The wrun indicator
// Option Stance: not a mood score. One card rates five common options trades With, Neutral or Against. The trades are
// selling options, betting option prices fall, buying for a move, buying long-dated and buying cheap far-out options.
// Implied volatility (how big a move option prices expect) sets how pricey options are. The card's IV rank says if it
// is high or low against the past year. Dealers (the market makers who hedge options) can calm price or push it, and
// the card says which. It also shows the call and put walls (the strikes with the most dealer hedging) and the put/call
// ratios. Use it as a quick check of the backdrop before you trade options, not as a trade signal.
//
// Technical notes: one card over the daily options statistics (option_daily) and the issuer's next earnings date,
// and which of five trade-idea stances that picture runs with. The volatility regime is the IV rank (where the
// session's 30-day IV sits between the window's low and
// high) and percentile; the positioning is dealer gamma on the open-interest basis (the regime the sign of net gamma,
// the options kit's dealerRegime: long gamma dampens moves, short gamma amplifies them), spot against the data plane's
// gamma flip over all expiries (the gamma curve's zero nearest spot, the options kit's rule), the call and put walls,
// the put/call volume and open-interest
// ratios, the 25 delta risk reversal and the front expiry's implied move. Each stance reads plain rules over those, and
// the card says With, Neutral or Against for each: selling premium runs with a high IV rank, long dealer gamma and no
// earnings report inside the earnings window, and against a low rank or a report inside it; selling vega with a high
// rank and the term in contango, against a low rank; directional buying with short dealer gamma below a high rank,
// against long gamma at a high rank; long-dated buying with a low rank, against a high one; cheap out-of-the-money
// buying with a low rank and short gamma, against a high rank. The rules describe the regime, not a trade. The
// statistics are short today (they start when the data plane switches the daily job on): the positioning reads from the
// first session, but the IV rank, and with it every stance, needs Minimum history (60 sessions); until then the stances
// read Needs history and the card says how many sessions there are. Crypto, CME and US stock charts, daily or finer.
param.int("lookback", 252, { min: 20, max: 520, label: "Window, sessions", description: "How many past sessions (trading days) the IV rank and percentile compare today against. 252 is about a year." });
param.int("min_sessions", 60, { min: 10, max: 520, label: "Minimum history, sessions", description: "How many sessions of daily data the IV rank needs before it shows. The five stances wait for it too." });
param.number("high_rank", 50, { min: 0, max: 100, step: 1, label: "High IV rank", description: "An IV rank (where IV sits in its past-year range) at or above this counts as high. Options are expensive then, which favors selling them." });
param.number("low_rank", 30, { min: 0, max: 100, step: 1, label: "Low IV rank", description: "An IV rank (where IV sits in its past-year range) at or below this counts as low. Options are cheap then, which favors buying them." });
param.int("earnings_days", 30, { min: 0, max: 120, label: "Earnings window, days", description: "An earnings report within this many days counts against selling premium (the money paid for an option). Earnings can jump the price." });
input("close", ohlcv.close); // the chart's own close: the grid
input("iv30", option_daily.atm_iv_30d, { missing: "nan", description: "The 30-day implied volatility (IV) of options at today's price, in percent, once per session (trading day)." }); // every daily input lands on the first bar of its day, NaN elsewhere
input("iv90", option_daily.atm_iv_90d, { missing: "nan", description: "The 90-day IV (implied volatility) of options at today's price, in percent." });
input("rr25", option_daily.rr25_30d, { missing: "nan", description: "The 30-day risk reversal: the 25 delta call IV minus the 25 delta put IV, in volatility points. Positive means calls cost more." });
input("gex", option_daily.net_gex, { missing: "nan", description: "Dealers' net gamma over all expiries, in USD per 1% move. Gamma is how fast dealers (the market makers who hedge options) must hedge as price moves." });
input("flip", option_daily.gamma_flip, { missing: "nan", description: "The gamma flip over all expiries: the price nearest today's where dealer hedging turns from calming moves to pushing them." });
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("call_vol", option_daily.call_volume, { missing: "nan", description: "Calls traded per session (bets on a rise): contracts on US options and CME, coins on a crypto chain." });
input("put_vol", option_daily.put_volume, { missing: "nan", description: "Puts traded per session (bets on a fall): contracts on US options and CME, coins on a crypto chain." });
input("call_oi", option_daily.call_oi, { missing: "nan", description: "Call open interest (calls still open): contracts on US options and CME, coins on a crypto chain." });
input("put_oi", option_daily.put_oi, { missing: "nan", description: "Put open interest (puts still open): contracts on US options and CME, coins on a crypto chain." });
input("move", option_daily.implied_move_front, { missing: "nan", description: "The move the options price in for the nearest expiry, as a price distance." });
input("spot", option_daily.underlying_price, { missing: "nan", description: "The price of the stock, coin or future when the statistics were read." });
market.earnings_next_ms(); // the issuer's next earnings report, epoch ms (0 when the chart does not know it)
output("iv_rank", none, overlay, { description: "Where the 30-day IV sits between the window's low (0) and high (100). Empty below Minimum history." });
output("iv_pct", none, overlay, { description: "The share of the window's earlier sessions with a lower 30-day IV, in percent." });
output("gex", none, overlay, { format: "usd", description: "Dealers' net gamma (how fast they must hedge as price moves), in USD per 1% move." });
output("gamma_code", none, overlay, { description: "Dealers' gamma side as a code. 0 short gamma (they push moves), 1 neutral (exactly zero), 2 long gamma (they calm moves)." });
output("flip_dist", none, overlay, { description: "How far today's price sits above (+) or below (-) the gamma flip over all expiries, in percent." });
output("wall_call", none, overlay, { format: "price", description: "The call wall: the call strike with the most dealer hedging." });
output("wall_put", none, overlay, { format: "price", description: "The put wall: the put strike with the most dealer hedging." });
output("pc_volume", none, overlay, { description: "Puts traded for each call traded. Above 1 means more puts." });
output("pc_oi", none, overlay, { description: "Open puts for each open call. Above 1 means more puts." });
output("rr25", none, overlay, { description: "The 30-day risk reversal: the 25 delta call IV minus the 25 delta put IV. Positive means calls cost more." });
output("move_pct", none, overlay, { description: "The move the options price in for the nearest expiry, in percent of the price." });
output("earnings_days", none, overlay, { description: "Days to the next earnings report. Empty when none is known." });
output("sell_premium", none, overlay, { description: "Selling premium (selling options for their price): 0 against, 1 neutral, 2 with. It reads 1 while the IV rank needs history." });
output("sell_vega", none, overlay, { description: "Selling vega (betting that option prices fall): 0 against, 1 neutral, 2 with." });
output("directional", none, overlay, { description: "Buying options for a price move: 0 against, 1 neutral, 2 with." });
output("long_dated", none, overlay, { description: "Buying options with a lot of time left: 0 against, 1 neutral, 2 with." });
output("cheap_options", none, overlay, { description: "Buying cheap options far from today's price: 0 against, 1 neutral, 2 with." });
output("status", none, overlay, { description: "0 the IV rank needs history, 1 every reading shows, 2 a chart coarser than a day. Empty before the first session." });
string("read", { max_bytes: 64 }); // the headline: the volatility regime
string("gamma_text", { max_bytes: 48 }); // "Long gamma": the regime over all expiries, as the tile's label says; spot against the gamma flip has its own tile
string("earnings_text", { max_bytes: 32 }); // "Earnings 28OCT, in 11 days"
string("s_sell_premium", { max_bytes: 16 }); // each stance's word
string("s_sell_vega", { max_bytes: 16 });
string("s_directional", { max_bytes: 16 });
string("s_long_dated", { max_bytes: 16 });
string("s_cheap_options", { max_bytes: 16 });
string("title", { max_bytes: 64 });
render.hud("stance_card", {
position: "bottom_right",
title: "{{title}}",
columns: 2,
tiles: [
tile.pill("Volatility", "read", { headline: true }),
tile.pill("Gamma · all expiries", "gamma_text"),
tile.value("vs gamma flip", "flip_dist", { format: "%" }),
tile.pill("Sell premium", "s_sell_premium"),
tile.pill("Sell vega", "s_sell_vega"),
tile.pill("Directional", "s_directional"),
tile.pill("Long-dated", "s_long_dated"),
tile.pill("Cheap options", "s_cheap_options"),
tile.pill("Earnings", "earnings_text"),
tile.rows([
["IV rank", "iv_rank", "0"],
["IV percentile", "iv_pct", "0"],
["Net gamma", "gex", "usd"],
["Call wall", "wall_call", "price"],
["Put wall", "wall_put", "price"],
["Put/call volume", "pc_volume", "0.00"],
["Put/call OI", "pc_oi", "0.00"],
["Risk reversal, 25 delta", "rr25", "0.00"],
["Next expiry move, %", "move_pct", "0.00"],
]),
],
});
const DAY = 86400.0;
const CAPACITY = 520;
const WORDS: String[] = ["Against", "Neutral", "With"];
const MONTHS: String[] = ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"];
const ivs = new DayHistory(CAPACITY); // one 30-day IV per session
const dateClock = new Clock("UTC");
let lookback = 252; // settings, read in onStart()
let need = 60;
let highRank = 50.0;
let lowRank = 30.0;
let earningsDays = 30.0;
let nextEarningsMs: f64 = NaN;
let prevT: f64 = NaN; // the bar spacing
let barSec: f64 = NaN;
let sessionDay: f64 = NaN; // the newest session, and what it carried, held
let rankNow: f64 = NaN;
let pctNow: f64 = NaN;
let iv30: f64 = NaN;
let iv90: f64 = NaN;
let rr: f64 = NaN;
let gex: f64 = NaN;
let flip: f64 = NaN;
let callWall: f64 = NaN;
let putWall: f64 = NaN;
let callVol: f64 = NaN;
let putVol: f64 = NaN;
let callOi: f64 = NaN;
let putOi: f64 = NaN;
let move: f64 = NaN;
let spot: f64 = NaN;
function onStart(): void {
lookback = i32(p_lookback());
need = i32(p_min_sessions());
if (need > lookback) need = lookback;
highRank = p_high_rank();
lowRank = p_low_rank();
earningsDays = p_earnings_days();
nextEarningsMs = earningsMs(p_market_earnings_next_ms());
}
function land(day: f64): void {
sessionDay = day;
iv30 = in_iv30();
iv90 = in_iv90();
rr = in_rr25();
gex = in_gex();
flip = in_flip();
callWall = in_call_wall();
putWall = in_put_wall();
callVol = in_call_vol();
putVol = in_put_vol();
callOi = in_call_oi();
putOi = in_put_oi();
move = in_move();
spot = in_spot();
if (iv30 > 0.0) ivs.push(day, iv30);
const ready = ivs.span(lookback) >= need;
rankNow = ready ? ivs.rank(lookback) : NaN;
pctNow = ready ? ivs.percentile(lookback) : NaN;
}
function ratio(a: f64, b: f64): f64 {
return b > 0.0 && !isNaN(a) ? a / b : NaN;
}
/** Days from the bar to the next earnings report; NaN when none is known or it has passed. */
function daysToEarnings(t: f64): f64 {
if (isNaN(nextEarningsMs)) return NaN;
const d = (nextEarningsMs - t * 1000.0) / (DAY * 1000.0);
return d >= 0.0 ? d : NaN;
}
// ── The five stances, each 0 against, 1 neutral, 2 with; NaN while the IV rank needs history ──
function sellPremium(t: f64): f64 {
if (isNaN(rankNow)) return NaN;
const e = daysToEarnings(t);
const earningsSoon = !isNaN(e) && e <= earningsDays;
if (rankNow <= lowRank || earningsSoon) return 0.0;
return rankNow >= highRank && dealerRegime(gex) > 0.0 ? 2.0 : 1.0;
}
function sellVega(): f64 {
if (isNaN(rankNow)) return NaN;
if (rankNow <= lowRank) return 0.0;
return rankNow >= highRank && iv90 >= iv30 ? 2.0 : 1.0;
}
function directional(): f64 {
if (isNaN(rankNow) || isNaN(gex)) return NaN;
const regime = dealerRegime(gex);
if (regime > 0.0 && rankNow >= highRank) return 0.0;
return regime < 0.0 && rankNow < highRank ? 2.0 : 1.0;
}
function longDated(): f64 {
if (isNaN(rankNow)) return NaN;
return rankNow <= lowRank ? 2.0 : rankNow >= highRank ? 0.0 : 1.0;
}
function cheapOptions(): f64 {
if (isNaN(rankNow)) return NaN;
if (rankNow >= highRank) return 0.0;
return rankNow <= lowRank && dealerRegime(gex) < 0.0 ? 2.0 : 1.0;
}
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 sbStance(code: f64): void {
sb_clear();
if (isNaN(code)) sb_text("Needs history");
else sb_text(WORDS[i32(code)]);
}
function writeWords(coarse: bool, t: f64): void {
const held = ivs.span(lookback);
sb_clear();
if (coarse) sb_text("Needs a daily or finer chart");
else if (isNaN(sessionDay)) sb_text("Waiting for the daily options statistics");
else if (held < need) {
sb_text("Not enough history yet: ");
sb_int(held);
sb_text(" of ");
sb_int(need);
sb_text(" sessions");
} else if (isNaN(rankNow)) sb_text("No range: the IV has not moved in the window");
else {
sb_text(rankNow >= highRank ? "High IV, rank " : rankNow <= lowRank ? "Low IV, rank " : "Middling IV, rank ");
sb_f64(rankNow, 0);
sb_text(", percentile ");
sb_f64(pctNow, 0);
}
str_read_sb();
sb_clear();
if (coarse || isNaN(gex)) sb_text("No gamma reading");
else {
const regime = dealerRegime(gex);
sb_text(regime > 0.0 ? "Long gamma" : regime < 0.0 ? "Short gamma" : "Neutral gamma");
}
str_gamma_text_sb();
sb_clear();
const e = daysToEarnings(t);
if (isNaN(e)) sb_text("No report known");
else {
sbDay(Math.floor(nextEarningsMs / (DAY * 1000.0)));
sb_text(", in ");
sb_int(i64(Math.floor(e)));
sb_text(Math.floor(e) == 1.0 ? " day" : " days");
}
str_earnings_text_sb();
sbStance(coarse ? NaN : sellPremium(t));
str_s_sell_premium_sb();
sbStance(coarse ? NaN : sellVega());
str_s_sell_vega_sb();
sbStance(coarse ? NaN : directional());
str_s_directional_sb();
sbStance(coarse ? NaN : longDated());
str_s_long_dated_sb();
sbStance(coarse ? NaN : cheapOptions());
str_s_cheap_options_sb();
sb_clear();
sb_text("Option stance");
if (!coarse && !isNaN(sessionDay)) {
sb_text(", as of ");
sbDay(sessionDay);
}
str_title_sb();
}
// onBar() runs once per bar: the spacing, then the session's statistics when they land; every bar writes the held
// readings and the stances, and the live bar the card's words.
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 any = !isNaN(in_iv30()) || !isNaN(in_gex()) || !isNaN(in_spot());
if (any && (isNaN(sessionDay) || day >= sessionDay)) land(day);
}
const has = !coarse && !isNaN(sessionDay);
out_iv_rank(has ? rankNow : NaN);
out_iv_pct(has ? pctNow : NaN);
out_gex(has ? gex : NaN);
out_gamma_code(has && !isNaN(gex) ? 1.0 + dealerRegime(gex) : NaN);
out_flip_dist(has && spot > 0.0 && flip > 0.0 ? (spot / flip - 1.0) * 100.0 : NaN);
out_wall_call(has ? callWall : NaN);
out_wall_put(has ? putWall : NaN);
out_pc_volume(has ? ratio(putVol, callVol) : NaN);
out_pc_oi(has ? ratio(putOi, callOi) : NaN);
out_rr25(has ? rr : NaN);
out_move_pct(has && spot > 0.0 && !isNaN(move) ? (move / spot) * 100.0 : NaN);
out_earnings_days(daysToEarnings(t));
const sp = has ? sellPremium(t) : NaN;
const sv = has ? sellVega() : NaN;
const dr = has ? directional() : NaN;
const ld = has ? longDated() : NaN;
const co = has ? cheapOptions() : NaN;
out_sell_premium(isNaN(sp) ? 1.0 : sp);
out_sell_vega(isNaN(sv) ? 1.0 : sv);
out_directional(isNaN(dr) ? 1.0 : dr);
out_long_dated(isNaN(ld) ? 1.0 : ld);
out_cheap_options(isNaN(co) ? 1.0 : co);
out_status(coarse ? 2.0 : isNaN(sessionDay) ? NaN : ivs.span(lookback) >= need ? 1.0 : 0.0);
if (bar.isLast()) writeWords(coarse, t);
}How it works
The five stances, by rule.
| Stance | With | Against |
|---|---|---|
| Sell premium | IV rank at or over High IV rank, dealers long gamma, no earnings report within Earnings window | IV rank at or under Low IV rank, or a report within the window |
| Sell vega | IV rank high and the 90-day IV at or over the 30-day (contango) | IV rank low |
| Directional | dealers short gamma and the IV rank under high | dealers long gamma at a high IV rank |
| Long-dated | IV rank low | IV rank high |
| Cheap options | IV rank low and dealers short gamma | IV rank high |
Anything else is Neutral. The weights a fit score would need are not public, so the card says which side of each rule the regime sits on instead of scoring contracts.
The positioning. Every reading is the newest session's: net gamma's sign through dealerRegime (gamma_code is it plus 1: 0 short, 1 neutral, 2 long), spot over the gamma flip in percent (the data plane's, over all expiries; its own vs gamma flip tile, beside the Gamma · all expiries regime), the walls, the two put/call ratios, the risk reversal (call IV minus put IV) and the front move over the price.
What the settings do
- Window, sessions: How many past trading days today's implied volatility (how big a move option prices expect) is ranked against. 252 is about a year.
- Minimum history, sessions: The IV rank and the five stances show only after this many trading days of data.
- High IV rank: An IV rank at or above this counts as high, when options are expensive and selling them is favored.
- Low IV rank: An IV rank at or below this counts as low, when options are cheap and buying them is favored.
- Earnings window, days: A report within this many days counts against selling premium (the money paid for an option). Earnings can jump the price.
- Volatility: Whether implied volatility is high, middling or low for the year, with its rank and percentile.
- Gamma · all expiries: Whether dealers are in long gamma (dealers calm price), short gamma (dealers chase price) or neutral.
- vs gamma flip: How far today's price sits from the gamma flip (the price where dealers switch from calming price to pushing it).
- Sell premium: With, Neutral or Against for selling options, which pays when options are pricey and price stays calm.
- Sell vega: Selling vega is a bet that option prices fall. This reads With, Neutral or Against for that bet.
- Directional: With, Neutral or Against for buying options to catch a price move.
- Long-dated: With, Neutral or Against for buying options with a lot of time left before they end.
- Cheap options: With, Neutral or Against for buying cheap options far from today's price.
- Earnings: The next earnings date and the days until it, or No report known.
- IV rank: Where 30-day implied volatility sits between the window's low (0) and high (100).
- IV percentile: The share of past trading days with lower implied volatility.
- Net gamma: Dealers' net gamma in USD per 1% move: positive calms moves, negative pushes them.
- Call wall: The call strike (the option's price level) with the most dealer hedging, often watched as a ceiling.
- Put wall: The put strike with the most dealer hedging, often watched as a floor.
- Put/call volume: Puts traded for each call: above 1 means more puts.
- Put/call OI: Open puts for each open call, from open interest (contracts still held open).
- Risk reversal, 25 delta: Calls' implied volatility minus puts', both a moderate distance (25 delta) from price. Positive means calls cost more.
- Next expiry move, %: The move the options price in for the nearest expiry, in percent.
Where it runs
It works on coins with listed options, on a daily or intraday chart. A copy you run from the editor (where you write and run your own indicators) reads the same data. On a US stock chart, every indicator that runs in your browser reads it. The data is 15 minutes behind unless you have real-time US options data. On a futures chart from CME (Chicago futures exchange), every indicator that runs in your browser reads it too, once you accept the CME market data terms (Limitations). CME data is 10 minutes behind unless you have real-time CME data. The Earnings tile reads the chart's own earnings date for a US stock (Earnings dates). Where the chart knows no date, it reads "No report known".
When data is missing
The daily data starts on the day OpenMarket began recording it. The dealer, wall and put/call readings show from the first trading day. The card's IV rank, and with it every stance, needs Minimum history (60 trading days). Until then each stance on the card reads Needs history. The card's headline reads "Not enough history yet: 12 of 60 sessions". An unknown earnings date reads "No report known" on the Earnings tile and never counts against a stance. Before the first trading day the card reads "Waiting for the daily options statistics". A chart with bars longer than a day reads "Needs a daily or finer chart". US listed options' daily data through 2026-10-20 uses an older gamma flip rule and often has no flip. On those days the card's vs gamma flip tile stays empty (Data sources).
Customize it
- Your own thresholds. Move High IV rank and Low IV rank to where you sell and buy volatility.
- A wider earnings guard. Set Earnings window to the expiries you trade.
- Another year.
lookbacksets the sessions the IV rank reads.
Run it
- In the editor's Explorer, press the Templates icon and pick Option Stance under HUDs.
- Press Run on a US stock's chart.
- At the editor's Console prompt, type
iv_rank,sell_premiumandearnings_days.
Concepts used
- Data sources for
option_daily - Earnings dates for
market.earnings_next_ms() - Options kit for
DayHistory - HUD cards for the card and its pills