Bybit perp discount vs Coinbase BTC
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Digi20
//@version=4

study("Bybit Discount", shorttitle='Bybit Discount', overlay=false, precision=3)

coinbase = input(title="coinbase", defval = "COINBASE:BTCUSD")
bybit = input(title="bybit", defval = "BYBIT:BTCUSDT")

coinbase_ = security(coinbase, timeframe.period, close)
bybit_ = security(bybit, timeframe.period, close)

diff = coinbase_ - bybit_
col = diff >= 0 ? #FFFFFF : #FF69B4

plot(diff, color=col, style=plot.style_histogram, linewidth=1)