Skip to Main Content
Back to website
Indicator Disclaimer | Report this indicator

TSBuild26 — VORTEX Surface is a dual-source options flow and dealer hedging indicator that blends live Unusual Options Sweeps with a synthetic Garman-Klass 2nd-Order Vanna-Charm Dealer Pinning Surface.

KEY ARCHITECTURAL FEATURES
• Dual-Source Resilience: Queries live request.unusual_options institutional tape prints when available and seamlessly synthesizes a Black-Scholes-Merton Vanna-Charm volatility surface so it never renders blank on any symbol or timeframe.
• Vanna-Charm Dealer Magnet: Calculates how dealer delta decay (Charm) and implied volatility shifts (Vanna) pull spot price toward equilibrium pinning strikes.
• Asymmetric Skew Cone: Uses a 25-Delta Risk-Reversal proxy to expand expected move wings in the direction of institutional call chase or put fear.
• Call & Put Gamma Walls: Plots dynamic +GEX overhead resistance and -GEX downside support boundaries.

HOW TO TRADE IT

  1. Dealer Pin Mean-Reversion: Look for VORTEX Pin Long / Pin Short triggers when price stretches into the Put or Call Wall and rejects back toward the purple Charm Magnet.
  2. Volatility Squeeze Breakouts: Scan for VORTEX Vol Sqz when annualized implied volatility compresses below 18%.

REGISTERED SIGNALS (Alerts, Scanners & Strategy Tester)
• VORTEX Pin Long
• VORTEX Pin Short
• VORTEX Vol Sqz

// #TSBuild26 — VORTEX Options Flow and Dealer Vanna Surface
describe_indicator('VORTEX Surface', 'price', {
    shortName: 'VORTEX'
});

// ─── 1. COMPILER-SAFE INPUTS ─────────────────────────────────────────────────
const dteHorizon   = input.number('Target DTE', 7, { min: 1, max: 60 });
const minSweepPrem = input.number('Min Sweep USD', 50000, { min: 10000, max: 1000000 });
const volLookback  = input.number('Vol Lookback', 20, { min: 10, max: 60 });
const coneSigma    = input.number('Cone Sigma', 1.25, { min: 0.5, max: 3.0 });
const hudPosition  = input('HUD Position', 'top_right', ['top_right', 'bottom_right', 'top_left', 'bottom_left']);

// ─── 2. DUAL-SOURCE ASYNC UNUSUAL OPTIONS ENGINE ─────────────────────────────
let uoaRecords = [];
let dataSourceLabel = 'Synthetic BSM Surface';

try {
    if (typeof request !== 'undefined' && typeof request.unusual_options === 'function') {
        const sym = (typeof constants !== 'undefined' && constants.ticker) ? constants.ticker : current.ticker;
        const resp = await request.unusual_options(sym);
        if (Array.isArray(resp) && resp.length > 0) {
            uoaRecords = resp;
            dataSourceLabel = `Live Tape (${resp.length}) + BSM`;
        }
    }
} catch (err) {
    dataSourceLabel = 'Synthetic BSM Surface';
}

let callFlowUsd = 0, putFlowUsd = 0;
let weightedCallStrikeNum = 0, weightedCallStrikeDen = 0;
let weightedPutStrikeNum  = 0, weightedPutStrikeDen  = 0;

const lastClose = close[close.length - 1] || 100;
for (let k = 0; k < uoaRecords.length; k++) {
    const rec = uoaRecords[k];
    const prem = Number(rec.costBasis || rec.premium || (rec.price * rec.size * 100) || 0);
    const strike = Number(rec.strike || 0);
    const optType = String(rec.type || rec.putCall || '').toUpperCase();

    if (prem >= minSweepPrem && strike > lastClose * 0.5 && strike < lastClose * 1.5) {
        if (optType.indexOf('C') === 0) {
            callFlowUsd += prem;
            weightedCallStrikeNum += strike * prem;
            weightedCallStrikeDen += prem;
        } else if (optType.indexOf('P') === 0) {
            putFlowUsd += prem;
            weightedPutStrikeNum += strike * prem;
            weightedPutStrikeDen += prem;
        }
    }
}

// ─── 3. GARMAN-KLASS IV + 2ND-ORDER VANNA & CHARM DEALER MAGNET ──────────────
const n = close.length;
const gkVol       = series_of(null);
const skewRiskRev = series_of(0);
const callWall    = series_of(null);
const putWall     = series_of(null);
const charmMagnet = series_of(null);
const upperCone   = series_of(null);
const lowerCone   = series_of(null);

const sigPinLong  = series_of(false);
const sigPinShort = series_of(false);
const sigVolSqz   = series_of(false);
const pinLabels   = series_of(null);

const timeFrac = Math.sqrt(dteHorizon / 252);

for (let i = volLookback; i < n; i++) {
    let gkSum = 0;
    let upMoveVol = 0, dnMoveVol = 0;

    for (let j = i - volLookback + 1; j <= i; j++) {
        const h = high[j], l = low[j], o = open[j], c = close[j];
        const hlRatio = l > 0 ? Math.log(h / l) : 0;
        const coRatio = o > 0 ? Math.log(c / o) : 0;
        const gkBar = 0.5 * hlRatio * hlRatio - (2 * Math.LN2 - 1) * coRatio * coRatio;
        gkSum += Math.max(0.000001, gkBar);

        const ret = j > 0 && close[j - 1] > 0 ? (c - close[j - 1]) / close[j - 1] : 0;
        if (ret >= 0) upMoveVol += ret * ret * (volume[j] || 1);
        else dnMoveVol += ret * ret * (volume[j] || 1);
    }

    const annVol = Math.sqrt((gkSum / volLookback) * 252);
    gkVol[i] = annVol;

    const totDirVol = upMoveVol + dnMoveVol;
    const rawSkew = totDirVol > 0 ? ((upMoveVol - dnMoveVol) / totDirVol) : 0;
    skewRiskRev[i] = rawSkew * 100;

    const callWingMult = 1 + Math.max(-0.35, Math.min(0.45, rawSkew * 0.6));
    const putWingMult  = 1 + Math.max(-0.35, Math.min(0.45, -rawSkew * 0.6));

    const baseExpectedMove = close[i] * annVol * timeFrac * coneSigma;
    upperCone[i] = close[i] + baseExpectedMove * callWingMult;
    lowerCone[i] = close[i] - baseExpectedMove * putWingMult;

    const isRecent = i >= n - volLookback;
    const liveCallStrike = (isRecent && weightedCallStrikeDen > 0) ? (weightedCallStrikeNum / weightedCallStrikeDen) : null;
    const livePutStrike  = (isRecent && weightedPutStrikeDen > 0)  ? (weightedPutStrikeNum / weightedPutStrikeDen)  : null;

    callWall[i] = liveCallStrike !== null ? (liveCallStrike * 0.5 + upperCone[i] * 0.5) : (close[i] + baseExpectedMove * 0.72 * callWingMult);
    putWall[i]  = livePutStrike  !== null ? (livePutStrike  * 0.5 + lowerCone[i] * 0.5) : (close[i] - baseExpectedMove * 0.72 * putWingMult);

    const dVol = gkVol[i - 1] !== null ? (annVol - gkVol[i - 1]) : 0;
    const vannaBias = -dVol * rawSkew * close[i] * 2.5;
    const uoaNetWeight = (callFlowUsd + putFlowUsd > 0 && isRecent) ? ((callFlowUsd - putFlowUsd) / (callFlowUsd + putFlowUsd)) : (rawSkew * 0.5);
    charmMagnet[i] = ((callWall[i] + putWall[i]) / 2) + (baseExpectedMove * 0.22 * uoaNetWeight) + vannaBias;

    if (low[i] <= putWall[i] && close[i] > open[i] && close[i] < charmMagnet[i]) {
        sigPinLong[i] = true;
        pinLabels[i] = 'VANNA PIN LONG';
    } else if (high[i] >= callWall[i] && close[i] < open[i] && close[i] > charmMagnet[i]) {
        sigPinShort[i] = true;
        pinLabels[i] = 'CHARM FADE SHORT';
    }
    if (annVol < 0.18) sigVolSqz[i] = true;
}

// ─── 4. SANITIZED RENDERING ──────────────────────────────────────────────────
const pUpCone = paint(upperCone,   { name: 'Upper Wing',   color: '#38BDF8', style: 'dotted', thickness: 1, ignoreWhenScaling: true });
const pDnCone = paint(lowerCone,   { name: 'Lower Wing',   color: '#FB7185', style: 'dotted', thickness: 1, ignoreWhenScaling: true });
const pCallW  = paint(callWall,    { name: 'Call Wall',    color: '#10B981', thickness: 2, ignoreWhenScaling: true });
const pPutW   = paint(putWall,     { name: 'Put Wall',     color: '#F43F5E', thickness: 2, ignoreWhenScaling: true });
const pMagnet = paint(charmMagnet, { name: 'Charm Magnet', color: '#A78BFA', thickness: 2 });

fill(pCallW,  pMagnet, '#10B981', 0.10, 'Upper Zone');
fill(pMagnet, pPutW,   '#F43F5E', 0.10, 'Lower Zone');
fill(pUpCone, pDnCone, '#6366F1', 0.06, 'Skew Cone');

paint(pinLabels, { name: 'Pin Tag', style: 'labels_below', color: '#A78BFA', backgroundColor: '#1E1B4B', fontColor: '#DDD6FE' });

// ─── 5. STATIC-NAME HUD OVERLAY & SIGNALS ────────────────────────────────────
const last = n - 1;
const curIv = ((gkVol[last] || 0) * 100).toFixed(1) + '%';
const curSkew = (skewRiskRev[last] || 0).toFixed(1);
const skewRegime = (skewRiskRev[last] || 0) > 12 ? 'CALL CHASE' : ((skewRiskRev[last] || 0) < -12 ? 'PUT FEAR' : 'BALANCED');
const skewCol = (skewRiskRev[last] || 0) > 12 ? '#00F5D4' : ((skewRiskRev[last] || 0) < -12 ? '#F43F5E' : '#FBBF24');

const magnetPx = charmMagnet[last] !== null ? charmMagnet[last].toFixed(2) : 'N/A';
const magnetPullPct = (charmMagnet[last] !== null && close[last] > 0) ? (((charmMagnet[last] - close[last]) / close[last]) * 100).toFixed(2) + '%' : '0.00%';
const flowRatio = (callFlowUsd + putFlowUsd > 0)
    ? `$${(callFlowUsd / 1000).toFixed(0)}K C / $${(putFlowUsd / 1000).toFixed(0)}K P`
    : 'Implied Skew';

paint_overlay('VORTEX HUD', { position: hudPosition, order: 'above_all' }, {
    background: '#090D16F2',
    border: '1px solid #312E81',
    borderRadius: '8px',
    fontSize: '11px',
    rows: [
        { cells: [{ colspan: 2, text: 'VORTEX VANNA-CHARM SURFACE', color: '#E0E7FF', fontWeight: 'bold', padding: '7px 12px', background: '#1E1B4B' }] },
        { cells: [{ text: 'Surface Feed', color: '#94A3B8', padding: '4px 12px' }, { text: dataSourceLabel, color: '#A5B4FC', padding: '4px 12px' }] },
        { cells: [{ text: 'Skew Regime', color: '#94A3B8', padding: '4px 12px' }, { text: `${skewRegime} (${curSkew})`, color: skewCol, fontWeight: 'bold', padding: '4px 12px' }] },
        { cells: [{ text: 'Implied Vol', color: '#94A3B8', padding: '4px 12px' }, { text: `${curIv} (${dteHorizon} DTE)`, color: '#F8FAFC', padding: '4px 12px' }] },
        { cells: [{ text: 'Charm Magnet', color: '#94A3B8', padding: '4px 12px' }, { text: `${magnetPx} (${magnetPullPct})`, color: '#00F5D4', fontWeight: 'bold', padding: '4px 12px' }] },
        { cells: [{ text: 'Call / Put Wall', color: '#94A3B8', padding: '4px 12px' }, { text: `${(callWall[last] || 0).toFixed(2)} | ${(putWall[last] || 0).toFixed(2)}`, color: '#38BDF8', fontWeight: 'bold', padding: '4px 12px' }] },
        { cells: [{ text: 'Sweep Flow', color: '#94A3B8', padding: '5px 12px' }, { text: flowRatio, color: '#FBBF24', fontWeight: 'bold', padding: '5px 12px' }] }
    ]
});

register_signal(sigPinLong,  'VORTEX Pin Long');
register_signal(sigPinShort, 'VORTEX Pin Short');
register_signal(sigVolSqz,   'VORTEX Vol Sqz');