This is a script that shows the contango between spot and volumes of Bitcoin to identify overbought and oversold conditions. When a market is in contango, the of a contract is higher than the spot . Conversely, when a market is in backwardation, the of the contract is lower than the spot .
The aggregate daily volumes on top exchanges are taken to obtain Total Spot and Total . The script then plots (Total /Total Spot ) - 1 to illustrate the percent difference (contango) between spot and volumes of Bitcoin . This data by itself is useful, but because aggregate volumes are so much larger than spot volumes, no negative values are produced. To correct for this, the Z-score of contango is taken. The Z-score (z) of a data item x measures the distance (in standard deviations StdDev) and direction of the item from its mean (U):
Z-score = (x - U) / StDev
A value of zero indicates that the data item x is equal to the mean U, while positive or negative values show that the data item is above or below the mean (x Values of +2 and -2 show that the data item is two standard deviations above or below the chosen mean, respectively, and over 95.5% of all data items are contained within these two horizontal references). We substitute x with contango C, the mean U with ( ) of n periods (50), and StdDev with the standard deviation of closing contango for n periods (50), so the above formula becomes: Z-score = (C - (50)) / StdDev(C,50).
When in contango, Bitcoin may be overbought.
When in backwardation, Bitcoin may be oversold.
The current bar calculation will always look incorrect due to TV plotting the Z-score before the bar closes.
Contango = (Futures OBV / Spot OBV) - 1
Also changed the sma period (n) in the Z-score calculation to 20.
Coinbase/Deribit --> Coinbase/Bitmex
Bitfinex/Bitmex --> Bitfinex/Bybit
Bitstamp/Bybit --> Bitstamp/Deribit