BTC Spot/Futures Volume Ratio
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © wzkkzw12345

//@version=4
study(title="Spot/Futures")
length = input(14  , title="EMA length") 

res = timeframe.period
spot_volume = security("BINANCE:BTCUSDT", res,  volume) + security("BINANCE:BTCBUSD", res, volume)+security("OKEX:BTCUSDT",res, volume)+security("OKEX:BTCUSDC",res, volume)+security("FTX:BTCUSDT",res, volume/hlc3)+security("FTX:BTCUSD",res, volume/hlc3)
futures_volume = security("BINANCE:BTCUSDTPERP", res, volume)+ security("BINANCE:BTCBUSDPERP", res, volume) + security("BINANCE:BTCPERP", res, volume/hlc3)*100+security("OKEX:BTCPERP", res, volume/hlc3)*100+security("OKEX:BTCUSDTPERP", res, volume/hlc3)+security("FTX:BTCPERP",res, volume/hlc3)



//spot_ema = ema(spot_volume, length)
//futures_ema = ema(futures_volume, length)
ratio_ema = ema(spot_volume/futures_volume* (spot_volume+futures_volume),length)


//plot(spot_ema,color=color.new(color.green,30))
//plot(futures_ema,color=color.new(color.green,30))
//plot(spot_ema/futures_ema,color=color.new(color.green,30))
plot(ratio_ema /ema(spot_volume+futures_volume, length),color=color.new(color.green,30))




