 CB-BINANCE basis
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © youngpimpy

//@version=5
indicator(' CB-BINANCE basis', overlay=false)

//Uses candle closes for difference so best accuracy on lower timeframes
premium = request.security('COINBASE:BTCUSD', timeframe.period, close) - request.security('BINANCE:BTCUSDT', timeframe.period, close)

premiumPercent = premium / close * 100

plot(premiumPercent, color=premiumPercent >= 0 ? color.blue : color.red)
plot(0, color=color.new(color.black, 0))

