OI Volume Oscillator Cross Dynamics
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Crypto_Moses

//@version=5
indicator(title="Custom Open Interest and Volume Oscillator", shorttitle="OI_VO", overlay=false)

// Open Interest Code
Coin = input("BTC", title = "Coin")
Margin = input("Tether", title = 'Margin')

Exchange = 'BINANCE:'
SelectCoin = Coin
Code = (Margin == 'Tether') ? 'USDTPERP_OI' : 'PERP_OI'
Altcoin = Exchange + SelectCoin + Code

OpenInterest = request.security(Altcoin, timeframe.period, close)
plot(OpenInterest, color=color.red, title="Open Interest", linewidth=2)

// Volume Oscillator Code
shortPeriod = input.int(5, title="Short Period")
longPeriod = input.int(20, title="Long Period")
volMultiplier = input.float(1000, title="Volume Oscillator Multiplier")
shortMA = ta.sma(volume, shortPeriod)
longMA = ta.sma(volume, longPeriod)
volOsc = (shortMA - longMA) * volMultiplier
plot(volOsc, color=color.blue, title="Volume Oscillator")

// Crossover/Crossunder Conditions
bullishCross = ta.crossover(volOsc, OpenInterest)
bearishCross = ta.crossunder(volOsc, OpenInterest)

// Plotting Shapes for Crossovers
plotshape(series=bullishCross, color=color.green, style=shape.triangleup, location=location.belowbar, size=size.small, title="Bullish Cross")
plotshape(series=bearishCross, color=color.red, style=shape.triangledown, location=location.abovebar, size=size.small, title="Bearish Cross")