Open Interest All Exchanges
// This high code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// ©JanLosev
// I am happy and make the people around me happier. 
// With Love JanLosev. 
// @version=5
indicator(title='Open Interest', shorttitle='OI', overlay=false, precision=0)


OPEN_BITFINEX  = request.security('BITFINEX:BTCUSDLONGS',"", open) + request.security('BITFINEX:BTCUSDSHORTS',"", open) + request.security('BITFINEX:BTCUSTLONGS',"", open) + request.security('BITFINEX:BTCUSTLONGS',"", open)
CLOSE_BITFINEX = request.security('BITFINEX:BTCUSDLONGS',"", close) + request.security('BITFINEX:BTCUSDSHORTS',"", close) + request.security('BITFINEX:BTCUSTLONGS',"", close) + request.security('BITFINEX:BTCUSTLONGS',"", close)
HIGH_BITFINEX  = request.security('BITFINEX:BTCUSDLONGS',"", high) + request.security('BITFINEX:BTCUSDSHORTS',"", high) + request.security('BITFINEX:BTCUSTLONGS',"", high) + request.security('BITFINEX:BTCUSTLONGS',"", high)
LOW_BITFINEX   = request.security('BITFINEX:BTCUSDLONGS',"", low) + request.security('BITFINEX:BTCUSDSHORTS',"", low) + request.security('BITFINEX:BTCUSTLONGS',"", low) + request.security('BITFINEX:BTCUSTLONGS',"", low)


OPEN_BINANCE  = request.security('BINANCE:BTCUSDTPERP_OI',"", open)  
CLOSE_BINANCE = request.security('BINANCE:BTCUSDTPERP_OI',"", close) 
HIGH_BINANCE  = request.security('BINANCE:BTCUSDTPERP_OI',"", high) 
LOW_BINANCE   = request.security('BINANCE:BTCUSDTPERP_OI',"", low)   


OPEN_KRAKEN  = request.security('KRAKEN:BTCUSDPERP_OI',"", open) / request.security('KRAKEN:BTCUSDPERP',"", open)
CLOSE_KRAKEN = request.security('KRAKEN:BTCUSDPERP_OI',"", close) / request.security('KRAKEN:BTCUSDPERP',"", close)
HIGH_KRAKEN  = request.security('KRAKEN:BTCUSDPERP_OI',"", high) / request.security('KRAKEN:BTCUSDPERP',"", high)
LOW_KRAKEN   = request.security('KRAKEN:BTCUSDPERP_OI',"", low) / request.security('KRAKEN:BTCUSDPERP',"", low)


OPEN_BITMEX  = request.security('BITMEX:XBTUSD_OI',"", open) / request.security('BITMEX:XBTUSD.P',"", open) + request.security('BITMEX:XBTUSDT_OI',"", open) / request.security('BITMEX:XBTUSDT.P',"", open)
CLOSE_BITMEX = request.security('BITMEX:XBTUSD_OI',"", close) / request.security('BITMEX:XBTUSD.P',"", close) + request.security('BITMEX:XBTUSDT_OI',"", close) / request.security('BITMEX:XBTUSDT.P',"", close)
HIGH_BITMEX  = request.security('BITMEX:XBTUSD_OI',"", high) / request.security('BITMEX:XBTUSD.P',"", high) + request.security('BITMEX:XBTUSDT_OI',"", high) / request.security('BITMEX:XBTUSDT.P',"", high)
LOW_BITMEX   = request.security('BITMEX:XBTUSD_OI',"", low) / request.security('BITMEX:XBTUSD.P',"", low) + request.security('BITMEX:XBTUSDT_OI',"", low) / request.security('BITMEX:XBTUSDT.P',"", low)


Open = (na(OPEN_BITFINEX) ? 0 : OPEN_BITFINEX) + (na(OPEN_BINANCE) ? 0 : OPEN_BINANCE) + (na(OPEN_KRAKEN) ? 0 : OPEN_KRAKEN) + (na(OPEN_BITMEX) ? 0 : OPEN_BITMEX)
Close = (na(CLOSE_BITFINEX) ? 0 : CLOSE_BITFINEX) + (na(CLOSE_BINANCE) ? 0 : CLOSE_BINANCE) + (na(CLOSE_KRAKEN) ? 0 : CLOSE_KRAKEN) + (na(CLOSE_BITMEX) ? 0 : CLOSE_BITMEX)
High = (na(HIGH_BITFINEX) ? 0 : HIGH_BITFINEX) + (na(HIGH_BINANCE) ? 0 : HIGH_BINANCE) + (na(HIGH_KRAKEN) ? 0 : HIGH_KRAKEN) + (na(HIGH_BITMEX) ? 0 : HIGH_BITMEX)
Low = (na(LOW_BITFINEX) ? 0 : LOW_BITFINEX) + (na(LOW_BINANCE) ? 0 : LOW_BINANCE) + (na(LOW_KRAKEN) ? 0 : LOW_KRAKEN) + (na(LOW_BITMEX) ? 0 : LOW_BITMEX)

plotcandle(Open, High, Low, Close, color = Open < Close ? color.new(#2962ff, 50) : color.new(#5d606b, 50), wickcolor = Open < Close ? color.new(#2962ff, 10) : color.new(#5d606b, 10), bordercolor = Open < Close ? color.new(#2962ff, 10) : color.new(#5d606b, 10), title = 'Open Interest')