OPEN-SOURCE SCRIPT

Binance Perp Premium/Discount

This TradingView Pine Script indicator calculates and displays the premium or discount percentage between a cryptocurrency's spot price and its corresponding perpetual futures (perp) price on Binance. It automatically detects whether the current chart symbol represents a spot or perp market by checking for the ".P" suffix. The script then retrieves the closing prices for both the spot and perp symbols using the request.security function. If valid data is available for both markets, it computes the premium or discount as a percentage and visualizes this difference as a histogram below the main chart. Green bars indicate a premium (perp price above spot), while red bars signify a discount (perp price below spot). The indicator includes error handling to display 'n/a' when data for the required symbols is unavailable, ensuring robustness across various chart applications.
sentimentVolume Indicatorvolumedelta

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer