Author's note: When I searched the Trading View libraries, I didn't find what I was looking for. I noticed that the crypto market currently uses a lot more derivatives called "Perpetual" Futures, while the price is always formulated based on the spot price, or the real coin. I wanted something that would mark the difference in real time between the spot price and the perpetual futures, creating a bar history. Since the relationship between them generates algorithms on exchanges to formulate payment rates for the lowest side, and to formulate the "market price" of the perpetual futures (without expiration), which are not the value of the last trade. I found several scripts that try to show the relationship between the funding rate and the rate, or the increase in these over time. But they don't show the direct action of the two prices in real time, nor a history of this difference. The usefulness of this script is that at times you will see jumps in the price difference and can make assessments from this. Associated with another funding rate script it becomes even more interesting. I also didn't find coverage for the two brokers that my friends and I operate with, so I enabled it for use on these two brokers.
Function: It works for the BYBIT and BINANCE exchanges. In coins that have both markets (Spot and Perpetual futures). It shows in bars the real-time activity of the two markets, the difference between them. A configurable historical average, and bars for each candle. The last one is in real time.
How it works: The script will detect which coin you are looking at, and will use its algorithm to detect if there is an opposite pair. If it is spot, it will identify and look for the perpetual future, and if it is future, it will find the spot prices. It will calculate the difference between them in %, using 0.05 as the default threshold - normally used by brokers as "zero". The futures on average are currently 0.05 higher than the spot in price. And it will show this difference in a bar, green and upwards if the futures are higher, and red if they are lower. and its respective normalized value in %(100)
Example of use:
1: you can check for possible movement patterns in relation to the expectation of future prices and spot, over time. 2. Main: you will notice at times normally prior to larger price movements, the indicator will pulse, indicating changes in the price difference of perpetual futures in relation to spot. - e.g.: in large purchases in spot that pull the price up by buying more positions in the order book, you will see a downward pulse in the indicator bar. as well as in the opposite direction, being an upward pulse. 3. The movement may sometimes be in futures, so you will see the opposite happening, it may be useful to add the opposite currency pair as an additional price, to identify with certainty who is "pulling" whether it is spot or perpetual. But in both cases the possible interpretation is the same. the expectation of futures in relation to the spot price is higher or lower than the average, and there are or are not pulses in one direction or another.
Summary: by following this indicator you can see the real-time vision of large purchases in spot, for example. Someone with great market power may have a future position, and is triggering purchases or ignition in the direction of their position in spot, for example.
Warning: many other indicators and market insights are needed to have a view of the whole and interpret these signals and bar movements. Use and observation lead to an understanding for future actions. But it should always be based on a global context. This is not an indicator to be used alone.
Warning 2: if the opposite pair is not available (exchange only has a spot market, for example) nothing will appear in the indicator. And if it is an exchange other than BYBIT or BINANCE, nothing will probably appear either.