OPEN-SOURCE SCRIPT

@tk · spectral

█  OVERVIEW


This script is an indicator that helps traders to identify the price difference between spot and futures of the current crypto plotted into the chart. It works in both types of markets, when the chart is plotting the crypto in spot market, it will compare with its respective futures ticker and vice-versa. If the current asset isn't a crypt ticker, the indicator will not be plotted into the chart.



█  MOTIVATION


Since crypto's derivative market is based on spot market asset's price, to calculate the arbitrage mechanisms that attempts to balance the asset price, this indicator can help traders to identify some spot and futures price divergence that can create an anomaly of funding rate and can push it to an extreme negative — or positive — rate. So, easing to track the price difference between both markets will bring more evidences to identify an artificial price move, specially in crypto assets with low market cap.



█  CONCEPT


The trading concept to use this indicator is the concept of the arbitrage machamism created by exchanges that calculates the funding rate based on spot and futures price difference that will vary from exchange to exchange. This strategy don't works alone. It needs to be aligned together with others indicators like Exponential Moving Averages, Chart Patterns, Support and Resistance, and so on... Even more confluences that you have, bigger are your chances to increase the probability for a successful trade. So, don't use this indicator alone. Compose a trading strategy and use it to improve your analysis.



█  CUSTOMIZATION


This indicator allows the trader to customize the following settings:

GENERAL

Text size
  Changes the font size of price difference table to improve accessibility.
  Type: string
  Options: `tiny`, `small`, `normal`, `large`.
  Default: `small`

Position
  Changes the position of price difference table.
  Type: string
  Options: `top_left`, `top_center`, `top_right`, `middle_left`, `middle_center`, `middle_right`, `bottom_left`, `bottom_center`, `bottom_right`.
  Default: `bottom_right`

Pair Quote
  The ticker quote symbol that will be used to base the ticker comparison from spot to futures (e.g. BTCUSDT which `USDT` is the quote. ETHBTC which `BTC` is the quote).
  Type: string
  Default: USDT

Spectrum Color
  The color of the spectrum candles. Spectrum candles are the candles of the opposite market. If the current ticker is in the spot market, the spectrum candles will be the price of the futures market.
  Type: color
  Default: #434651



█  FUNCTIONS


The indicator contains the following functions:


stripStarts(src, str)
  Strips a defined pattern from a string.
  Parameters:
    src: (string) Source string
    str: (string) String pattern to be stripped from start of source string.
  Returns: (string) Stripped string with matched regex pattern.
arbitragecryptocryptofuturesderivativesdiffforecastingfundingratesOscillatorsSharkspotderivativesspotdiffTKVolatility

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