本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
indicator("VIX Curve Monitor [Shamrock]", shorttitle="VIXCURVE", overlay=false, precision=3)
// ───────────────────────── CHEAT SHEET ─────────────────────────
// Put on a DAILY SPX / SPY chart (signals tested on daily closes, 2013–2026).
// LINE = VIX / VIX3M green < 0.90 calm · gray 0.90–1 stress · red > 1 backwardation (inverted)
// GREEN ▲ big spike over (peak ≥ 1.05, closes back < 1.00) → spike over
// SPY after (n=20): 1wk +2.0% (75% up) · 1mo +3.5% (84% up) · 3mo +6.9% (85% up)
// GRAY ● minor dip: small spike over AND chart within 5% of 1-yr high
// SPY after (n=35): 1mo +3.1% (83% up), typical dip −1.3%. Lowest conviction.
// Small spike with chart 5–10% off high = NO signal (1mo −0.5%, 40% up).
// GRAY ▲ secondary: small spike over AND chart ≥10% below 1-yr high
// SPY after (n=13): 1mo +5.0% (77% up). Caught Feb 2016 + Oct 2022 bottoms.
// BRIGHT ▲ confirmed: ratio closes < 0.90 after an arrow → calm confirmed
// DARK RED ✕ failed: ratio closes back > 1.03 before 0.90 → panic returned; a retest has often followed
// (after fails SPY still up ~60% a month later — not a sell signal). Next close < 1 re-arms.
// While red the spike is still active: after the first close > 1.05, SPY 1wk −0.85% median.
// Status: CALM / STRESS BUILDING / SHORT-TERM PANIC / INVERSION SPREADING (VX2–4 up ≥10% vs 10d)
// / REGIME FEAR (VX5–8 up ≥5% vs 10d — 2008/2020/2022-type)
// VX months 1–8 auto-picked from the date (no roll). VX EXPIRY row = next expiry.
// Symbols missing on your feed are skipped
// (Full table lists them) — fix by changing the prefix in Inputs (CBOE: / CBOE_DLY: / TVC:).
// ───────────────────────────────────────────────────────────────
grpS = "Symbols"
vixSym = input.string("CBOE_DLY:VIX", "VIX", group=grpS)
vix3mSym = input.string("CBOE_DLY:VIX3M", "VIX3M", group=grpS)
vix9dSym = input.string("CBOE_DLY:VIX9D", "VIX9D", group=grpS)
vvixSym = input.string("CBOE_DLY:VVIX", "VVIX", group=grpS)
vix6mSym = input.string("CBOE_DLY:VIX6M", "VIX6M", group=grpS)
grpF = "VX futures"
vxMode = input.string("Auto (by date)", "Contracts", options=["Auto (by date)", "Manual"], group=grpF, tooltip="Auto picks months 1–8 from today's date and rolls itself after each VX expiry. Manual uses the 8 inputs below (roll them yourself). Codes: F Jan G Feb H Mar J Apr K May M Jun N Jul Q Aug U Sep V Oct X Nov Z Dec")
m1Sym = input.string("CBOE:VXX2026", "Manual month 1", group=grpF)
m2Sym = input.string("CBOE:VXZ2026", "Manual month 2", group=grpF)
m3Sym = input.string("CBOE:VXF2027", "Manual month 3", group=grpF)
m4Sym = input.string("CBOE:VXG2027", "Manual month 4", group=grpF)
m5Sym = input.string("CBOE:VXH2027", "Manual month 5", group=grpF)
m6Sym = input.string("CBOE:VXJ2027", "Manual month 6", group=grpF)
m7Sym = input.string("CBOE:VXK2027", "Manual month 7", group=grpF)
m8Sym = input.string("CBOE:VXM2027", "Manual month 8", group=grpF)
grpT = "Thresholds"
stressLevel = input.float(0.90, "Stress level", step=0.01, group=grpT)
confirmLevel = input.float(0.90, "Confirm level", step=0.01, group=grpT)
failLevel = input.float(1.03, "Fail level", step=0.01, group=grpT, tooltip="Signal fails only if the ratio closes back above this. 1.00 = every tiny pop fails (22 fails, very choppy); 1.03 cuts fails to 8 with the same 17 confirms (2013–2026).")
bigSpike = input.float(1.05, "Big spike peak", step=0.01, group=grpT)
secDD = input.float(10.0, "Secondary: % below 1-yr high", step=0.5, group=grpT)
minorDD = input.float(5.0, "Minor dip: within % of 1-yr high", step=0.5, group=grpT, tooltip="Small spike ending with the market this close to its high = minor dip (n=35, 1mo +3.1%, 83% up). Between this and the Secondary % = no signal (n=15, 1mo −0.5%, 40% up).")
backFearLevel = input.float(24.0, "Back months fear level", step=0.5, group=grpT)
backRisePct = input.float(10.0, "Back months rise % vs 10d", step=0.5, group=grpT)
farRisePct = input.float(5.0, "Far months rise % vs 10d", step=0.5, group=grpT)
vvixHigh = input.float(120.0, "VVIX high", step=1.0, group=grpT)
floorLen = input.int(20, "Floor length (bars)", minval=5, group=grpT)
holdBars = input.int(21, "Confirmed / failed display (bars)", minval=1, group=grpT, tooltip="How long CONFIRMED or FAILED stays in the table and shading after it happens. 21 bars ≈ 1 month, the horizon the history was measured on. Confirmed also ends early if the ratio goes back above 1.00.")
grpD = "Display"
fullMode = input.bool(false, "Full table (all details)", group=grpD)
tblPos = input.string("bottom_right", "Table position", options=["top_left", "top_right", "bottom_left", "bottom_right"], group=grpD)
tblSize = input.string("small", "Text size", options=["tiny", "small", "normal", "large"], group=grpD)
tblFont = input.string("Default", "Font", options=["Default", "Monospace"], group=grpD)
txtLbl = input.color(#d1d4dc, "Label text", group=grpD)
txtSub = input.color(#787b86, "Sub-row label text", group=grpD)
txtNote = input.color(#787b86, "Note text", group=grpD)
grpV = "Table value colors"
vRed = input.color(#f23645, "Panic / bearish", group=grpV)
vOrange = input.color(#ff7043, "Short-term panic", group=grpV)
vGray = input.color(#9e9e9e, "Stress / neutral", group=grpV)
vGreen = input.color(#66bb6a, "Calm / confirmed", group=grpV)
vBlue = input.color(#29b6f6, "Watch / signal", group=grpV)
vPurple = input.color(#ab47bc, "Failed / worse", group=grpV)
lowLevel = input.float(0.80, "Calm floor line", step=0.01, group=grpD, tooltip="Ratio rarely goes much below ~0.80 (extreme calm / complacency)")
tblBg = input.color(#000000, "Table background (match chart)", group=grpD)
grpM = "Marker colors"
mkSpike = input.color(#2e7d32, "Spike over ▲", group=grpM)
mkSec = input.color(#d1d4dc, "Secondary ▲", group=grpM)
mkMinor = input.color(#d1d4dc, "Minor dip ●", group=grpM)
mkConf = input.color(#00ff41, "Confirmed ▲", group=grpM)
mkFail = input.color(#801820, "Failed ✕", group=grpM)
grpB = "Background shading"
shadeMode = input.string("Off", "Shade", options=["Off", "Inverted only", "Inverted + stress"], group=grpB, tooltip="Red when VIX/VIX3M > 1, gray when 0.90–1.00")
shadeSig = input.bool(false, "Shade signal phases", group=grpB, tooltip="Green while a signal is CONFIRMED, faint blue while PENDING")
shadeWhere = input.string("Price pane", "Where", options=["Price pane", "Indicator pane", "Both"], group=grpB)
shadeTr = input.int(88, "Transparency", minval=50, maxval=98, group=grpB)
grpL = "Second line (full curve)"
curveSrc = input.string("VIX / VIX6M", "Second line", options=["VIX / VIX6M", "Off"], group=grpL, tooltip="VIX vs 6-month implied vol on the same scale. Above 1.00 = the longer curve is inverted too (deeper fear).")
curveCol = input.color(#b2b5be, "Color", group=grpL)
curveW = input.int(1, "Width", minval=1, maxval=4, group=grpL)
// ── Palette ──
cCalm = #2e7d32 // line: calm
cStress = #9e9e9e // line: stress zone 0.90–1.00 (gray)
cPanic = #b71c1c // line: inverted
cRed = #f23645 // markers / 1.00 line
cRedTxt = vRed
cArrow = #2e7d32 // spike-over arrow
cBright = mkConf // confirmed (shading)
cOrange = vOrange
cSig = vBlue
cConf = vGreen
cFail = vPurple
cCell = #1e222d
cText = #d1d4dc
cMuted = #787b86
// ── Data ──
// lookahead_on: index (4:15pm) and VX bars close AFTER SPY (4:00pm), so with lookahead off every
// historical bar returned the PREVIOUS day. lookahead_on aligns by date (same-day close).
f(s) => request.security(s, "", close, lookahead=barmerge.lookahead_on, ignore_invalid_symbol=true)
vix = f(vixSym)
vix3m = f(vix3mSym)
vix9d = f(vix9dSym)
vvix = f(vvixSym)
vix6m = f(vix6mSym)
// ── VX calendar: expiry = Wednesday 30 days before the 3rd Friday of the following month ──
tz = "America/New_York"
vxCodes = array.from("F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z")
vxExp(int y, int m) =>
ny = m == 12 ? y + 1 : y
nm = m == 12 ? 1 : m + 1
first = timestamp(tz, ny, nm, 1, 0, 0)
fri1 = 1 + (dayofweek.friday - dayofweek(first, tz) + 7) % 7
timestamp(tz, ny, nm, fri1 + 14, 9, 0) - 30 * 86400000
shiftYM(int y, int m, int k) =>
idx = y * 12 + (m - 1) + k
[int(math.floor(idx / 12)), idx % 12 + 1]
vxSym(int y, int m) => "CBOE:VX" + array.get(vxCodes, m - 1) + str.tostring(y)
monNames = array.from("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
symMon(string sym) =>
code = str.substring(sym, str.length(sym) - 5, str.length(sym) - 4)
idx = array.indexof(vxCodes, code)
idx >= 0 ? array.get(monNames, idx) : code
nowY = year(timenow, tz)
nowM = month(timenow, tz)
rolled = timenow >= vxExp(nowY, nowM)
[fY, fM] = shiftYM(nowY, nowM, rolled ? 1 : 0) // front contract (VX1)
nextExp = vxExp(fY, fM)
daysToExp = math.ceil((nextExp - timenow) / 86400000.0)
[y2, m2] = shiftYM(fY, fM, 1)
[y3, m3] = shiftYM(fY, fM, 2)
[y4, m4] = shiftYM(fY, fM, 3)
[y5, m5] = shiftYM(fY, fM, 4)
[y6, m6] = shiftYM(fY, fM, 5)
[y7, m7] = shiftYM(fY, fM, 6)
[y8, m8] = shiftYM(fY, fM, 7)
auto = vxMode == "Auto (by date)"
s1 = auto ? vxSym(fY, fM) : m1Sym
s2 = auto ? vxSym(y2, m2) : m2Sym
s3 = auto ? vxSym(y3, m3) : m3Sym
s4 = auto ? vxSym(y4, m4) : m4Sym
s5 = auto ? vxSym(y5, m5) : m5Sym
s6 = auto ? vxSym(y6, m6) : m6Sym
s7 = auto ? vxSym(y7, m7) : m7Sym
s8 = auto ? vxSym(y8, m8) : m8Sym
t1 = f(s1)
t2 = f(s2)
t3 = f(s3)
t4 = f(s4)
w5 = f(s5)
w6 = f(s6)
w7 = f(s7)
w8 = f(s8)
// average whatever contracts are available (skips symbols missing on your feed)
avg3(a, b, c) =>
n = (na(a) ? 0 : 1) + (na(b) ? 0 : 1) + (na(c) ? 0 : 1)
n > 0 ? (nz(a) + nz(b) + nz(c)) / n : na
avg4(a, b, c, d) =>
n = (na(a) ? 0 : 1) + (na(b) ? 0 : 1) + (na(c) ? 0 : 1) + (na(d) ? 0 : 1)
n > 0 ? (nz(a) + nz(b) + nz(c) + nz(d)) / n : na
rSpot = vix / vix3m
rFut = t1 / t2
backAvg = avg3(t2, t3, t4)
backBase = ta.sma(backAvg, 10)[1]
backRise = backBase > 0 ? (backAvg / backBase - 1) * 100 : na
farFut = avg4(w5, w6, w7, w8)
useVix6m = na(farFut) // no far contracts available → use VIX6M (6-month implied vol, no roll)
farAvg = useVix6m ? vix6m : farFut
farBase = ta.sma(farAvg, 10)[1]
farRise = farBase > 0 ? (farAvg / farBase - 1) * 100 : na
lastV = not na(w8) ? w8 : not na(w7) ? w7 : not na(w6) ? w6 : not na(w5) ? w5 : t4
slope = t1 - lastV
invSpot = rSpot > 1
invFut = rFut > 1
inv = invSpot or invFut
spreading = inv and (backAvg >= backFearLevel or nz(backRise) >= backRisePct)
regime = inv and nz(farRise) >= farRisePct
state = regime ? 4 : spreading ? 3 : inv ? 2 : rSpot >= stressLevel ? 1 : 0
// ── Spike tracking: peak = highest ratio since it was last below confirmLevel (re-arms after a fail) ──
var float peak = 0.0
peak := rSpot < confirmLevel ? 0.0 : invSpot ? math.max(peak, rSpot) : peak
crossDown = rSpot < 1 and rSpot[1] >= 1
spikeOver = crossDown and peak[1] >= bigSpike
offHigh = (close / ta.highest(close, 252) - 1) * 100
smallOver = crossDown and peak[1] < bigSpike and offHigh <= -secDD
minorOver = crossDown and peak[1] < bigSpike and offHigh > -minorDD
// ── Follow-through: 1 pending · 2 confirmed · 3 failed ──
rawSig = spikeOver or smallOver or minorOver
var int lastSig = na
var int sigType = 0
var int phase = 0
var int phaseBar = 0
sigStart = rawSig and phase != 1 // ignore repeat crosses while a signal is already pending
if sigStart
lastSig := bar_index
sigType := spikeOver ? 1 : smallOver ? 2 : 3
sinceSig = na(lastSig) ? 0 : bar_index - lastSig
prevPhase = phase
phase := sigStart ? 1 :
phase == 1 and rSpot < confirmLevel ? 2 :
phase == 1 and rSpot > failLevel ? 3 :
phase >= 2 and bar_index - phaseBar >= holdBars ? 0 :
phase == 2 and invSpot ? 0 : phase
if phase != prevPhase
phaseBar := bar_index
confirmEvt = phase == 2 and prevPhase == 1
failEvt = phase == 3 and prevPhase == 1
// ── Floor ──
floorV = ta.lowest(rSpot, floorLen)
floorRising = floorV > floorV[floorLen] and floorV[floorLen] > floorV[2 * floorLen]
// ── Plots ──
lineCol = rSpot > 1 ? cPanic : rSpot >= stressLevel ? cStress : cCalm
pR = plot(rSpot, "VIX/VIX3M", lineCol, 2)
rCurve = curveSrc == "VIX / VIX6M" ? vix / vix6m : na
plot(rCurve, "Full-curve line", rCurve > 1 ? curveCol : color.new(curveCol, 45), curveW)
pOne = plot(1.0, "1.00 (fill anchor)", color.new(cRed, 100), 1, editable=false)
hline(1.0, "1.00", cRed, hline.style_solid, 1)
hline(stressLevel, "Stress", color.new(color.white, 30), hline.style_dotted)
hline(lowLevel, "Calm floor", color.new(cCalm, 20), hline.style_dotted)
fill(pR, pOne, rSpot > 1 ? color.new(cPanic, 80) : na, "Inverted")
// ── Background shading (optional) ──
stateBg = shadeMode == "Off" ? na : rSpot > 1 ? color.new(cRed, shadeTr) : shadeMode == "Inverted + stress" and rSpot >= stressLevel ? color.new(cStress, shadeTr) : na
sigBg = not shadeSig ? na : phase == 2 ? color.new(cBright, shadeTr) : phase == 1 ? color.new(cSig, math.min(shadeTr + 4, 98)) : na
bgCol = na(sigBg) ? stateBg : sigBg
bgcolor(shadeWhere != "Indicator pane" ? bgCol : na, title="Shade price pane", force_overlay=true)
bgcolor(shadeWhere != "Price pane" ? bgCol : na, title="Shade indicator pane")
plotshape(sigStart and spikeOver ? rSpot : na, "Spike over", shape.triangleup, location.absolute, mkSpike, size=size.small)
plotshape(sigStart and smallOver ? rSpot : na, "Secondary", shape.triangleup, location.absolute, mkSec, size=size.tiny)
plotshape(sigStart and minorOver ? rSpot : na, "Minor dip", shape.circle, location.absolute, mkMinor, size=size.tiny)
plotshape(confirmEvt ? rSpot : na, "Confirmed", shape.triangleup, location.absolute, mkConf, size=size.small)
plotshape(failEvt ? rSpot : na, "Failed", shape.xcross, location.absolute, mkFail, size=size.small)
// ── Table (Intraday Internals style: label · value · note, no cell backgrounds) ──
fmt(x) => na(x) ? "n/a" : str.tostring(x, "0.00")
pct(x) => na(x) ? "n/a" : (x >= 0 ? "+" : "") + str.tostring(x, "0.0") + "%"
pos = switch tblPos
"top_left" => position.top_left
"bottom_left" => position.bottom_left
"bottom_right" => position.bottom_right
=> position.top_right
tsz = tblSize == "tiny" ? size.tiny : tblSize == "normal" ? size.normal : tblSize == "large" ? size.large : size.small
tfont = tblFont == "Monospace" ? font.family_monospace : font.family_default
var table t = table.new(pos, 3, 22, bgcolor=tblBg)
// sub = indented sub-row (lighter label)
row(int r, string lbl, string val, color vc, string note = "", bool sub = false) =>
table.cell(t, 0, r, (sub ? " " : "") + lbl, bgcolor=tblBg, text_color=sub ? txtSub : txtLbl, text_size=tsz, text_halign=text.align_left, text_font_family=tfont)
table.cell(t, 1, r, val, bgcolor=tblBg, text_color=val == "n/a" ? cMuted : vc, text_size=tsz, text_halign=text.align_right, text_font_family=tfont)
table.cell(t, 2, r, note, bgcolor=tblBg, text_color=txtNote, text_size=tsz, text_halign=text.align_left, text_font_family=tfont)
if barstate.islast
table.clear(t, 0, 0, 2, 21)
int r = 0
// STATUS
stTxt = state == 4 ? "REGIME FEAR" : state == 3 ? "INVERSION SPREADING" : state == 2 ? "SHORT-TERM PANIC" : state == 1 ? "STRESS BUILDING" : "CALM"
stNote = state == 4 ? "far months rising — whole curve lifting" : state == 3 ? (rSpot < rSpot[1] ? "back months bid while front eases" : "back months bid") : state == 2 ? "backwardation at the front only" : state == 1 ? "weeks of gray = grind-lower risk" : "normal contango"
stCol = state >= 3 ? cRedTxt : state == 2 ? cOrange : state == 1 ? vGray : cConf
row(r, "STATUS", stTxt, stCol, stNote)
r += 1
// SIGNAL
if phase == 1
row(r, "SIGNAL", (sigType == 1 ? "SPIKE OVER" : sigType == 2 ? "SECONDARY" : "MINOR DIP") + " " + str.tostring(sinceSig) + "d", sigType == 1 ? cSig : cText, "confirms < " + fmt(confirmLevel) + " · fails > " + fmt(failLevel))
r += 1
row(r, "confirm < " + fmt(confirmLevel), pct((confirmLevel / rSpot - 1) * 100), cSig, "away from confirm", true)
r += 1
else if phase == 2
row(r, "SIGNAL", "CONFIRMED", cConf, "signal " + str.tostring(sinceSig) + "d ago · ratio back in calm zone")
r += 1
else if phase == 3
row(r, "SIGNAL", "FAILED", cFail, "signal " + str.tostring(sinceSig) + "d ago · panic returned · re-arms on close < 1.00")
r += 1
pkNote = "peak " + fmt(peak) + (peak >= bigSpike ? " big · marker on close < 1.00" : offHigh <= -secDD ? " small · secondary on close < 1.00" : offHigh > -minorDD ? " small, mkt near high · minor dip on close < 1.00" : " small, mkt 5–10% off high · no marker")
if phase != 1 and phase != 2 and invSpot
row(r, phase == 3 ? "re-arm" : "SIGNAL", "PENDING", peak >= bigSpike ? vGray : cMuted, pkNote, phase == 3)
r += 1
// CURVE
row(r, "VIX/VIX3M", fmt(rSpot), rSpot > 1 ? cRedTxt : rSpot >= stressLevel ? vGray : cConf, (rSpot > 1 ? "BACKWARDATION" : rSpot >= stressLevel ? "stress" : "calm") + " · prev " + fmt(rSpot[1]))
r += 1
r9 = vix9d / vix
if not na(r9)
row(r, "VIX9D/VIX", fmt(r9), r9 > 1 ? cOrange : cConf, r9 > 1 ? "next 9 days above 30-day (near-term event stress)" : "near term normal", true)
r += 1
if not na(rCurve)
row(r, "VIX/VIX6M", fmt(rCurve), rCurve > 1 ? cRedTxt : cConf, rCurve > 1 ? "longer curve in backwardation too" : "longer curve in contango", true)
r += 1
row(r, "VX1/VX2", fmt(rFut), invFut ? cRedTxt : cConf, invFut ? "futures in backwardation" : "futures in contango", true)
r += 1
// SPREAD
bHot = nz(backRise) >= backRisePct or backAvg >= backFearLevel
fHot = nz(farRise) >= farRisePct
bDir = nz(backRise) >= 3 ? "rising" : nz(backRise) <= -3 ? "falling" : "stable"
row(r, "SPREAD", bDir, bHot or fHot ? cRedTxt : nz(backRise) >= 3 or nz(farRise) > 2 ? vGray : cConf, bHot or fHot ? "fear moving out the curve" : "back-month direction")
r += 1
row(r, "back VX2–4", pct(backRise), bHot ? cRedTxt : nz(backRise) > 3 ? vGray : cConf, "vs 10d avg · warn at +" + str.tostring(backRisePct, "#") + "% or " + fmt(backFearLevel), true)
r += 1
row(r, useVix6m ? "far (VIX6M)" : "far " + symMon(s5) + "–" + symMon(s8), pct(farRise), fHot ? cRedTxt : nz(farRise) > 2 ? vGray : cConf, "vs 10d avg · regime at +" + str.tostring(farRisePct, "#") + "%", true)
r += 1
// EXPIRY reminder (auto-updates every month)
expCol = daysToExp <= 3 ? vOrange : cText
row(r, "VX EXPIRY", str.format_time(nextExp, "EEE MMM d", tz), expCol, str.tostring(daysToExp) + "d · " + array.get(vxCodes, fM - 1) + str.tostring(fY % 100) + " · " + (auto ? "contracts roll automatically" : "ROLL manual inputs after this"))
r += 1
// WATCH
if inv
row(r, "WATCH", "VIX < " + fmt(vix3m), cSig, pct((vix3m / vix - 1) * 100) + " to un-invert (VIX under VIX3M)")
r += 1
if invFut
row(r, "VX1 < " + fmt(t2), pct((t2 / t1 - 1) * 100), cSig, "to un-invert (VX1 under VX2)", true)
r += 1
else
row(r, "FLOOR", floorRising ? "rising" : "flat", floorRising ? vGray : cConf, fmt(floorV[2 * floorLen]) + " > " + fmt(floorV[floorLen]) + " > " + fmt(floorV) + (floorRising ? " · big-spike odds ~2x" : ""))
r += 1
// FULL extras
if fullMode
row(r, "VIX", fmt(vix), cText, "9D " + fmt(vix9d) + " · 3M " + fmt(vix3m))
r += 1
row(r, "VX curve", fmt(t1) + " → " + fmt(lastV), slope > 0 ? cRedTxt : cConf, fmt(t1) + " | " + fmt(t2) + " | " + fmt(t3) + " | " + fmt(t4) + " | " + fmt(w5) + " | " + fmt(w6) + " | " + fmt(w7) + " | " + fmt(w8))
r += 1
row(r, "slope", (slope >= 0 ? "+" : "") + fmt(slope), slope > 0 ? cRedTxt : cConf, slope > 0 ? "whole curve in backwardation" : "front below back", true)
r += 1
if inv
row(r, "FLOOR", floorRising ? "rising" : "flat", floorRising ? vGray : cConf, fmt(floorV[2 * floorLen]) + " > " + fmt(floorV[floorLen]) + " > " + fmt(floorV))
r += 1
row(r, "VVIX", fmt(vvix), vvix >= vvixHigh ? cRedTxt : cText, vvix >= vvixHigh ? "spike zone" : "")
r += 1
row(r, "worse if back >", fmt(backFearLevel), cFail, pct((backFearLevel / backAvg - 1) * 100) + " away", true)
r += 1
miss = (na(vix9d) ? "VIX9D " : "") + (na(vvix) ? "VVIX " : "") + (na(t1) ? "VX1 " : "") + (na(t2) ? "VX2 " : "") + (na(t3) ? "VX3 " : "") + (na(t4) ? "VX4 " : "") + (na(w5) ? "M5 " : "") + (na(w6) ? "M6 " : "") + (na(w7) ? "M7 " : "") + (na(w8) ? "M8 " : "")
if str.length(miss) > 0
row(r, "missing", miss, cMuted, "change prefix in Inputs", true)
r += 1
// ── Alerts ──
alertcondition(sigStart and spikeOver, "Big spike over", "VIX/VIX3M back below 1 after big spike")
alertcondition(sigStart and smallOver, "Secondary signal", "Small spike over with market 10%+ off high")
alertcondition(sigStart and minorOver, "Minor dip signal", "Small spike over with market near its high")
alertcondition(confirmEvt, "Signal confirmed", "VIX/VIX3M below 0.90 — calm confirmed")
alertcondition(failEvt, "Signal failed", "VIX/VIX3M back above fail level — panic returned")
alertcondition(ta.crossover(rSpot, 1.0), "Backwardation", "VIX above VIX3M — curve in backwardation")
alertcondition(spreading and not spreading[1], "Inversion spreading", "Back-month VX futures bid — inversion spreading")
alertcondition(regime and not regime[1], "Regime fear", "Far-month VX futures rising")