MM Flow
FlowScripts

Perfected FlowScript

Open Interest Suite • [Leviathan]

OI Suite [Leviathan] Perfected is indexed as 038_open_interest_suite_leviathan.flowscript. The exact FlowScript is viewable here; chart observe and trading automation use the current mmflow chart/recipe signal proxy until FlowScript v2 transpilation is available.

This exact FlowScript uses the v2 source dialect. It is viewable and connected to the chart/automation proxy, but direct editor execution needs the FlowScript v2 transpiler.

Dialect

flowscript-v2

Compatibility

flowscript-v2-needs-transpile

Position

offchart

Axis

true

Size

21.5 KB

Lines

545

Native Signal Candidates

12 source-level chart marker triggers extracted from guarded FlowScript v2 blocks.

12/12 guarded

Z+

line 423:9

Trigger

(showShapes) && (zCrossUp)

Value

oiZ

Deps

showShapes:input, zCrossUp:var

Z-

line 433:9

Trigger

(showShapes) && (zCrossDn)

Value

oiZ

Deps

showShapes:input, zCrossDn:var

Z++

line 443:9

Trigger

(showShapes) && (zExtremeUp)

Value

oiZ

Deps

showShapes:input, zExtremeUp:var

Z--

line 453:9

Trigger

(showShapes) && (zExtremeDn)

Value

oiZ

Deps

showShapes:input, zExtremeDn:var

RSI OB

line 464:9

Trigger

(showShapes) && (rsiCrossUp)

Value

oiRsi

Deps

rsiCrossUp:var, showShapes:input

RSI OS

line 474:9

Trigger

(showShapes) && (rsiCrossDn)

Value

oiRsi

Deps

rsiCrossDn:var, showShapes:input

RSI 90+

line 484:9

Trigger

(showShapes) && (rsiExtremeUp)

Value

oiRsi

Deps

rsiExtremeUp:var, showShapes:input

RSI 10-

line 494:9

Trigger

(showShapes) && (rsiExtremeDn)

Value

oiRsi

Deps

rsiExtremeDn:var, showShapes:input

Strong Trend

line 505:9

Trigger

(showShapes) && (strongTrend)

Value

oiDelta

Deps

showShapes:input, strongTrend:var

Short Cover

line 515:9

Trigger

(showShapes) && (shortCover)

Value

oiDelta

Deps

shortCover:var, showShapes:input

New Shorts

line 525:9

Trigger

(showShapes) && (newShorts)

Value

oiDelta

Deps

newShorts:var, showShapes:input

Liquidation

line 535:9

Trigger

(showShapes) && (liquidation)

Value

oiDelta

Deps

liquidation:var, showShapes:input

038_open_interest_suite_leviathan.flowscript

source path: kscripts/perfected/038_open_interest_suite_leviathan.flowscript · sha256:dbfe6534a145a8156b90bb6d793e0a71869a8fa9c2aaf381a0db68cfc0f552b1

hash verified
//@version=2
// ============================================================================
// Open Interest Suite [Leviathan Perfected]
// Author: Leviathan (@Leviathan)  |  Perfected by: kScript_Perfection_Engineer
// Tags: FUTURES, #openinterest, #oidelta, #oimomentum, #oisuite, #leviathan
//
// Comprehensive composite OI dashboard with seven core metrics: OI Z-Score,
// OI RSI, OI Momentum, OI Delta, Relative OI Delta, Participation Ratio, and
// Transfer of Contracts. Each metric is statistically normalized with
// threshold-based coloring, regime detection, and session-level tracking.
//
// FORMULA FOUNDATION:
// 1. OI Z-Score: z = (OI − μ_OI) / σ_OI  where μ, σ computed over lookback window.
//    Per Chen, Cuny & Haugen (1995): OI levels contain information about future
//    price volatility; extreme z-scores flag unusual positioning regimes.
// 2. OI RSI (Wilder): RSI = 100 − 100/(1 + RS) where RS = EMA(gain)/EMA(loss).
//    Adapted from momentum RSI to OI changes; >70 = stretched OI accumulation.
// 3. Relative OI Delta: |ΔOI| / SMA(|ΔOI|, N) — normalizes current bar's OI change
//    against its own recent history. Per Yang Xu et al. (2021): unexpected OI changes
//    carry more predictive power than absolute levels.
// 4. Participation Ratio: ΔOI / Volume — measures what fraction of volume
//    represents new position opening vs. position transfer. Per ATAS (2019):
//    when delta shows seller initiative but OI grows, both sides accumulate.
// 5. Transfer of Contracts: Volume − |ΔOI| — the residual volume that represents
//    position transfers (old positions closing and new positions opening) rather
//    than net new exposure. Per Hull (2017): transfer volume reveals market
//    turnover independent of directional conviction.
//
// RESEARCH BASIS:
//  • Chen, Nai-Fu; Cuny, Charles J.; Haugen, Robert A. (1995), "Stock Volatility
//    and the Levels of the Basis and Open Interest in Futures Contracts",
//    J. Finance 50(1), 281–300. OI levels predict future volatility.
//  • Yang Xu et al. (2021), "Empirical Analysis of Price Volatility Characteristics
//    of China's Soybean Futures Market". Unexpected OI changes have larger impact
//    on price volatility than expected changes — validates OI delta as information
//    flow proxy.
//  • Christensen, Krogstrup, Kwan & Lustig (2017), NBER WP 23766. Aggregate OI
//    predicts futures returns; coefficient significantly positive per Hong & Yogo.
//  • Brunnermeier & Pedersen (2009), "Market Liquidity and Funding Liquidity".
//    Liquidity spirals explain why leveraged markets experience sudden OI collapse
//    when margin thresholds are breached.
//  • He & Manela (2022), "Fundamentals of Perpetual Futures", arXiv:2212.06888.
//    Perpetual futures OI dynamics reflect momentum-funding feedback loops.
//  • Amberdata (2026), "Leverage & Liquidations: The $31B Deleveraging". OI peaked
//    at $54.7B before collapse; 5% OI liquidation intensity triggers cascades.
// ============================================================================

define(
    title="OI Suite [Leviathan] Perfected",
    position="offchart",
    axis=true
)

// ---------------------------------------------------------------------------
// User Inputs — grouped and constrained per production spec
// ---------------------------------------------------------------------------

// --- Z-Score Group ---
var zLen = input(name="zLen", type="number", defaultValue=30, label="Z-Score Lookback", constraints={min: 5, max: 200, step: 1}, group="Z-Score")
var thrZ = input(name="thrZ", type="number", defaultValue=2.0, label="Z-Score Threshold", constraints={min: 0.5, max: 5.0, step: 0.1}, group="Z-Score")
var showZ = input(name="showZ", type="boolean", defaultValue=true, label="Show OI Z-Score", group="Z-Score")

// --- RSI Group ---
var rsiLen = input(name="rsiLen", type="number", defaultValue=14, label="OI RSI Length", constraints={min: 2, max: 50, step: 1}, group="RSI")
var thrRsiHi = input(name="thrRsiHi", type="number", defaultValue=70, label="OI RSI Overbought", constraints={min: 50, max: 95, step: 1}, group="RSI")
var thrRsiLo = input(name="thrRsiLo", type="number", defaultValue=30, label="OI RSI Oversold", constraints={min: 5, max: 50, step: 1}, group="RSI")
var showRsi = input(name="showRsi", type="boolean", defaultValue=true, label="Show OI RSI", group="RSI")

// --- Momentum Group ---
var momLen = input(name="momLen", type="number", defaultValue=14, label="Momentum Length", constraints={min: 2, max: 100, step: 1}, group="Momentum")
var showMom = input(name="showMom", type="boolean", defaultValue=true, label="Show OI Momentum", group="Momentum")

// --- Delta Group ---
var maLen = input(name="maLen", type="number", defaultValue=14, label="Delta MA Length", constraints={min: 2, max: 100, step: 1}, group="Delta")
var showDelta = input(name="showDelta", type="boolean", defaultValue=true, label="Show OI Delta", group="Delta")
var showRel = input(name="showRel", type="boolean", defaultValue=true, label="Show Relative OI Delta", group="Delta")
var showTransfer = input(name="showTransfer", type="boolean", defaultValue=true, label="Show Transfer of Contracts", group="Delta")
var showPart = input(name="showPart", type="boolean", defaultValue=true, label="Show Participation Ratio", group="Delta")

// --- Display Group ---
var showShapes = input(name="showShapes", type="boolean", defaultValue=true, label="Show Extremity Shapes", group="Display")
var showGuides = input(name="showGuides", type="boolean", defaultValue=true, label="Show Guide Lines", group="Display")
var showFill = input(name="showFill", type="boolean", defaultValue=true, label="Show Fill Zones", group="Display")
var lineWidth = input(name="lineWidth", type="number", defaultValue=2, label="Line Width", constraints={min: 1, max: 4, step: 1}, group="Display")
var shapeSize = input(name="shapeSize", type="number", defaultValue=2, label="Shape Size", constraints={min: 1, max: 4, step: 1}, group="Display")

// --- Colors Group ---
var bullColor = input(name="bullColor", type="color", defaultValue="#26a69a", label="Bullish Color", group="Colors")
var bearColor = input(name="bearColor", type="color", defaultValue="#ef5350", label="Bearish Color", group="Colors")
var neutralColor = input(name="neutralColor", type="color", defaultValue="#9e9e9e", label="Neutral Color", group="Colors")
var extremeBullColor = input(name="extremeBullColor", type="color", defaultValue="#00e676", label="Extreme Bull Color", group="Colors")
var extremeBearColor = input(name="extremeBearColor", type="color", defaultValue="#ff1744", label="Extreme Bear Color", group="Colors")
var zColor = input(name="zColor", type="color", defaultValue="#ffeb3b", label="Z-Score Color", group="Colors")
var rsiColor = input(name="rsiColor", type="color", defaultValue="#ce93d8", label="RSI Color", group="Colors")
var momColor = input(name="momColor", type="color", defaultValue="#90caf9", label="Momentum Color", group="Colors")
var relColor = input(name="relColor", type="color", defaultValue="#ffab40", label="Relative Delta Color", group="Colors")
var transferColor = input(name="transferColor", type="color", defaultValue="#8d6e63", label="Transfer Color", group="Colors")
var partColor = input(name="partColor", type="color", defaultValue="#b39ddb", label="Participation Color", group="Colors")

// ---------------------------------------------------------------------------
// Data Sources
// ---------------------------------------------------------------------------
timeseries oiTS = open_interest(symbol=currentSymbol, exchange=currentExchange)
timeseries pxTS = ohlcv(symbol=currentSymbol, exchange=currentExchange)
timeseries oi = oiTS.close
timeseries close = pxTS.close
timeseries high = pxTS.high
timeseries low = pxTS.low
timeseries vol = pxTS.volume

// NaN guard — prevent execution before data is loaded (Chen et al. 1995 data-integrity best practice)
if (isnan(oi[0]) || isnan(close[0]) || isnan(vol[0])) {
    return
}

// ---------------------------------------------------------------------------
// Core Metric Computations with Zero-Division Guards
// ---------------------------------------------------------------------------

// --- OI Delta (first difference) ---
timeseries oiPrev = oi[1]
timeseries oiDelta = oi - oiPrev
timeseries oiDeltaAbs = abs(oiDelta)

// --- Relative OI Delta (normalized against own history) ---
timeseries avgDeltaAbs = sma(oiDeltaAbs, maLen)
timeseries relDelta = avgDeltaAbs > 0 ? oiDeltaAbs / avgDeltaAbs : 0.0

// --- Transfer of Contracts (position transfer volume) ---
timeseries transfer = vol - oiDeltaAbs
timeseries transferNorm = vol > 0 ? transfer / vol * 100.0 : 0.0

// --- Participation Ratio (new exposure / total volume) ---
timeseries partRatio = vol > 0 ? oiDelta / vol : 0.0
timeseries partRatioNorm = vol > 0 ? oiDeltaAbs / vol * 100.0 : 0.0

// --- OI Momentum (absolute change over N bars) ---
timeseries oiMom = oi - oi[momLen]
timeseries oiMomNorm = oi > 0 ? oiMom / oi * 100.0 : 0.0

// --- OI Z-Score (statistical deviation from mean) ---
timeseries oiMean = sma(oi, zLen)
timeseries oiStd = stddev(oi, zLen)
timeseries oiZ = oiStd > 0 ? (oi - oiMean) / oiStd : 0.0

// --- OI RSI (Wilder approximation via EMA gain/loss on OI delta) ---
timeseries gain = math.max(oiDelta, 0.0)
timeseries loss = math.max(-oiDelta, 0.0)
timeseries avgGain = rma(gain, rsiLen)
timeseries avgLoss = rma(loss, rsiLen)
timeseries rs = avgLoss > 0 ? avgGain / avgLoss : 100.0
timeseries oiRsi = 100.0 - (100.0 / (1.0 + rs))

// ---------------------------------------------------------------------------
// Regime Detection (multi-metric composite classification)
// ---------------------------------------------------------------------------
// Regime 1: OI Z-Score extreme (> +thrZ or < -thrZ) → extreme positioning
// Regime 2: OI RSI extreme (> thrRsiHi or < thrRsiLo) → OI momentum stretched
// Regime 3: OI Delta sign → net new positions vs. net closures
// Regime 4: Price direction + OI direction → classical four-quadrant framework

var priceUp = close > close[1]
var priceDn = close < close[1]
var oiUp = oiDelta > 0
var oiDn = oiDelta < 0

// Classical four-quadrant OI + Price framework (per BBA curriculum):
//   Rising price + Rising OI = strong trend with new participation
//   Rising price + Falling OI = short covering / squeeze
//   Falling price + Rising OI = new shorts entering
//   Falling price + Falling OI = long liquidation / capitulation

var regime = 0  // 0=neutral, 1=strong trend, 2=short covering, 3=new shorts, 4=liquidation
if (priceUp && oiUp) {
    regime = 1
} else if (priceUp && oiDn) {
    regime = 2
} else if (priceDn && oiUp) {
    regime = 3
} else if (priceDn && oiDn) {
    regime = 4
}

// Z-Score regime
var zRegime = 0  // 0=normal, 1=extreme high, -1=extreme low
if (oiZ >= thrZ) {
    zRegime = 1
} else if (oiZ <= -thrZ) {
    zRegime = -1
}

// RSI regime
var rsiRegime = 0  // 0=normal, 1=overbought, -1=oversold
if (oiRsi >= thrRsiHi) {
    rsiRegime = 1
} else if (oiRsi <= thrRsiLo) {
    rsiRegime = -1
}

// ---------------------------------------------------------------------------
// Static State Tracking (Session-level persistence)
// ---------------------------------------------------------------------------
// Tracks session extremes, regime transitions, and extreme-event counts.

static lastBarIndex = 0
static lastRegime = 0
static lastZRegime = 0
static lastRsiRegime = 0
static regimeChangeCount = 0
static sessionHighOI = -999999999.0
static sessionLowOI = 999999999.0
static sessionHighZ = -999999.0
static sessionLowZ = 999999.0
static sessionHighRsi = 0.0
static sessionLowRsi = 100.0
static extremeZUpCount = 0
static extremeZDnCount = 0
static extremeRsiUpCount = 0
static extremeRsiDnCount = 0
static totalBars = 0

var currentBarIndex = bar_index[0]

if (!isnan(currentBarIndex) && currentBarIndex != lastBarIndex) {
    lastBarIndex = currentBarIndex
    totalBars = totalBars + 1

    // Session OI extremes
    if (oi > sessionHighOI) {
        sessionHighOI = oi
    }
    if (oi < sessionLowOI) {
        sessionLowOI = oi
    }

    // Session Z-Score extremes
    if (oiZ > sessionHighZ) {
        sessionHighZ = oiZ
    }
    if (oiZ < sessionLowZ) {
        sessionLowZ = oiZ
    }

    // Session RSI extremes
    if (oiRsi > sessionHighRsi) {
        sessionHighRsi = oiRsi
    }
    if (oiRsi < sessionLowRsi) {
        sessionLowRsi = oiRsi
    }

    // Regime change tracking
    if (lastRegime != regime) {
        lastRegime = regime
        regimeChangeCount = regimeChangeCount + 1
    }
    if (lastZRegime != zRegime) {
        lastZRegime = zRegime
    }
    if (lastRsiRegime != rsiRegime) {
        lastRsiRegime = rsiRegime
    }

    // Extreme event counting
    if (zRegime == 1) {
        extremeZUpCount = extremeZUpCount + 1
    } else if (zRegime == -1) {
        extremeZDnCount = extremeZDnCount + 1
    }
    if (rsiRegime == 1) {
        extremeRsiUpCount = extremeRsiUpCount + 1
    } else if (rsiRegime == -1) {
        extremeRsiDnCount = extremeRsiDnCount + 1
    }
}

// ---------------------------------------------------------------------------
// Plotting — Multiple Visualization Types (Bar, Line, Shape, Fill, HLine)
// ---------------------------------------------------------------------------

// --- Horizontal guide lines ---
hline(value=0, color="#ffffff30", width=1)

if (showGuides) {
    hline(value=thrZ, color=opacity(extremeBullColor, 30), width=1)
    hline(value=-thrZ, color=opacity(extremeBearColor, 30), width=1)
}

// --- OI Delta as bar histogram (primary visualization, bid/ask style) ---
if (showDelta) {
    plotBar(
        value=oiDelta,
        colors=[bullColor, bearColor],
        width=1,
        label=["OI Delta"],
        desc=["Per-bar OI change: positive = new positions, negative = position closures"]
    )
}

// --- OI Delta smoothed line overlay ---
timeseries oiDeltaMA = ema(oiDelta, maLen)
if (showDelta) {
    plotLine(
        value=oiDeltaMA,
        width=lineWidth,
        colors=[neutralColor],
        label=["OI Delta EMA"],
        desc=["EMA-smoothed OI delta for trend persistence filter"]
    )
}

// --- Relative OI Delta line ---
if (showRel) {
    plotLine(
        value=relDelta,
        width=lineWidth,
        colors=[relColor],
        label=["Rel OI Delta"],
        desc=["Absolute OI delta normalized by its own SMA; >1 = above-average change, per Yang Xu et al. (2021)"]
    )
}

// --- OI Z-Score with threshold fill and regime coloring ---
if (showZ) {
    if (showFill) {
        plotLine(
            value=([0, oiZ]),
            width=1,
            colors=[opacity(bullColor, 15), opacity(bearColor, 15)],
            colorIndex=oiZ > 0 ? 0 : 1,
            fill=true,
            label=["Z-Score Fill"],
            desc=["Z-Score fill from zero line, regime-colored"]
        )
    }
    plotLine(
        value=oiZ,
        width=lineWidth,
        colors=[zColor],
        label=["OI Z-Score"],
        desc=["Z-score of OI level over " + zLen + " bars; |z| > " + thrZ + " flags extreme positioning regimes per Chen, Cuny & Haugen (1995)"]
    )
}

// --- OI RSI with threshold fill ---
if (showRsi) {
    if (showFill) {
        plotLine(
            value=([thrRsiLo, oiRsi]),
            width=1,
            colors=[opacity(bearColor, 10), opacity(bullColor, 10)],
            colorIndex=oiRsi > 50 ? 0 : 1,
            fill=true,
            label=["RSI Fill"],
            desc=["OI RSI fill from oversold threshold"]
        )
    }
    plotLine(
        value=oiRsi,
        width=lineWidth,
        colors=[rsiColor],
        label=["OI RSI"],
        desc=["RSI of OI changes (Wilder form); >" + thrRsiHi + " = OI momentum stretched up, <" + thrRsiLo + " = stretched down"]
    )
}

// --- OI Momentum line ---
if (showMom) {
    plotLine(
        value=oiMomNorm,
        width=lineWidth,
        colors=[momColor],
        label=["OI Momentum"],
        desc=["OI momentum normalized as % of current OI; magnitude indicates positioning velocity"]
    )
}

// --- Transfer of Contracts line ---
if (showTransfer) {
    plotLine(
        value=transferNorm,
        width=lineWidth,
        colors=[transferColor],
        label=["Transfer %"],
        desc=["Transfer of contracts as % of volume: (Volume − |ΔOI|) / Volume × 100 per Hull (2017)"]
    )
}

// --- Participation Ratio line ---
if (showPart) {
    plotLine(
        value=partRatioNorm,
        width=lineWidth,
        colors=[partColor],
        label=["Participation %"],
        desc=["Participation ratio as % of volume: |ΔOI| / Volume × 100; high = new positioning dominates, low = transfer dominates"]
    )
}

// ---------------------------------------------------------------------------
// Shape Markers — Extreme Detection & Regime Transitions
// ---------------------------------------------------------------------------
if (showShapes) {
    // Z-Score extreme crosses
    var zCrossUp = oiZ >= thrZ && !isnan(oiZ[1]) && oiZ[1] < thrZ
    var zCrossDn = oiZ <= -thrZ && !isnan(oiZ[1]) && oiZ[1] > -thrZ
    var zExtremeUp = oiZ >= thrZ * 1.5 && !isnan(oiZ[1]) && oiZ[1] < thrZ * 1.5
    var zExtremeDn = oiZ <= -thrZ * 1.5 && !isnan(oiZ[1]) && oiZ[1] > -thrZ * 1.5

    // RSI extreme crosses
    var rsiCrossUp = oiRsi >= thrRsiHi && !isnan(oiRsi[1]) && oiRsi[1] < thrRsiHi
    var rsiCrossDn = oiRsi <= thrRsiLo && !isnan(oiRsi[1]) && oiRsi[1] > thrRsiLo
    var rsiExtremeUp = oiRsi >= 90 && !isnan(oiRsi[1]) && oiRsi[1] < 90
    var rsiExtremeDn = oiRsi <= 10 && !isnan(oiRsi[1]) && oiRsi[1] > 10

    // Four-quadrant regime shape markers (significant OI + Price combinations)
    var strongTrend = regime == 1 && !isnan(regime[1]) && regime[1] != 1 && oiDeltaAbs > avgDeltaAbs
    var shortCover = regime == 2 && !isnan(regime[1]) && regime[1] != 2 && oiDeltaAbs > avgDeltaAbs
    var newShorts = regime == 3 && !isnan(regime[1]) && regime[1] != 3 && oiDeltaAbs > avgDeltaAbs
    var liquidation = regime == 4 && !isnan(regime[1]) && regime[1] != 4 && oiDeltaAbs > avgDeltaAbs

    if (zCrossUp) {
        plotShape(
            value=oiZ,
            shape="triangleup",
            color=extremeBullColor,
            width=shapeSize,
            label=["Z+"],
            desc=["OI Z-Score crossed above +" + thrZ + " — extreme high positioning per Chen et al. (1995)"]
        )
    }
    if (zCrossDn) {
        plotShape(
            value=oiZ,
            shape="triangledown",
            color=extremeBearColor,
            width=shapeSize,
            label=["Z-"],
            desc=["OI Z-Score crossed below -" + thrZ + " — extreme low positioning, potential capitulation"]
        )
    }
    if (zExtremeUp) {
        plotShape(
            value=oiZ,
            shape="diamond",
            color=extremeBullColor,
            width=shapeSize + 1,
            label=["Z++"],
            desc=["OI Z-Score reached extreme +" + (thrZ * 1.5) + " — highly stretched long positioning, reversal risk"]
        )
    }
    if (zExtremeDn) {
        plotShape(
            value=oiZ,
            shape="diamond",
            color=extremeBearColor,
            width=shapeSize + 1,
            label=["Z--"],
            desc=["OI Z-Score reached extreme -" + (thrZ * 1.5) + " — highly stretched short positioning, squeeze risk"]
        )
    }

    if (rsiCrossUp) {
        plotShape(
            value=oiRsi,
            shape="triangleup",
            color=extremeBearColor,
            width=shapeSize,
            label=["RSI OB"],
            desc=["OI RSI crossed above " + thrRsiHi + " — overbought OI momentum, stretched accumulation"]
        )
    }
    if (rsiCrossDn) {
        plotShape(
            value=oiRsi,
            shape="triangledown",
            color=extremeBullColor,
            width=shapeSize,
            label=["RSI OS"],
            desc=["OI RSI crossed below " + thrRsiLo + " — oversold OI momentum, stretched liquidation"]
        )
    }
    if (rsiExtremeUp) {
        plotShape(
            value=oiRsi,
            shape="diamond",
            color=extremeBearColor,
            width=shapeSize + 1,
            label=["RSI 90+"],
            desc=["OI RSI reached 90+ — extreme OI momentum, imminent reversal likely"]
        )
    }
    if (rsiExtremeDn) {
        plotShape(
            value=oiRsi,
            shape="diamond",
            color=extremeBullColor,
            width=shapeSize + 1,
            label=["RSI 10-"],
            desc=["OI RSI reached 10- — extreme OI exhaustion, potential accumulation opportunity"]
        )
    }

    if (strongTrend) {
        plotShape(
            value=oiDelta,
            shape="triangleup",
            color=extremeBullColor,
            width=shapeSize,
            label=["Strong Trend"],
            desc=["Rising price + Rising OI = strong trend with new participation (classic bullish confirmation)"]
        )
    }
    if (shortCover) {
        plotShape(
            value=oiDelta,
            shape="triangledown",
            color=neutralColor,
            width=shapeSize,
            label=["Short Cover"],
            desc=["Rising price + Falling OI = short covering / squeeze — weak trend, no new money"]
        )
    }
    if (newShorts) {
        plotShape(
            value=oiDelta,
            shape="triangledown",
            color=extremeBearColor,
            width=shapeSize,
            label=["New Shorts"],
            desc=["Falling price + Rising OI = new shorts entering — bearish confirmation with fresh positioning"]
        )
    }
    if (liquidation) {
        plotShape(
            value=oiDelta,
            shape="triangledown",
            color=extremeBearColor,
            width=shapeSize + 1,
            label=["Liquidation"],
            desc=["Falling price + Falling OI = long liquidation / capitulation — forced exit, potential bottoming"]
        )
    }
}