LastBattle

[Bitcoin] Spot price vs Futures indicator

A handy script to detect opportunities in the futures market during extreme movement.
During rallies, futures usually tend to be US$10 above spot price, on the other hand it can be $1 below spot price when the price starts to decline.

You could also draw a trendline to it :) measuring the amount of risk people are willing to take just to predict future prices in the rally/decline.

Credits to lowstrife for the idea, I'm just implementing it :)

开源脚本

本着真正的TradingView精神,该脚本的作者将其开源发布,以便交易者可以理解和验证它。为作者喝彩!您可以免费使用它,但在出版物中重复使用此代码受网站规则的约束。 您可以收藏它以在图表上使用。

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想在图表上使用此脚本?
// Spot price vs futures - Tradingview.com
// @author lastbattle
study(title="spot Vs Futures", shorttitle="spot vs futures [lastbattle]")

// Inputs from user
notifyRed = input(8, title="Sell warning")  // when difference is > x
notifyGreen = input(0, title="Buy warning") // when difference is > x
timePerod = input(-1, title="Time period [-1 = go by chart]", minval=1)

// Security
src_796 = security("796:BTCUSD1W", period, close)
src_btce = security("OKCOIN:BTCCNY / FX:USDCNH", period, close) 
// Futures: OKCOIN:BTCUSD1W, 796:BTCUSD1W, OKCOIN:BTCUSD2W, OKCOIN:BTCUSD3M
// Spot: BITSTAMP:BTCUSD, BITFINEX:BTCUSD, BTCE:BTCUSD, OKCOIN:BTCCNY / FX:USDCNH, HUOBI:BTCCNY / FX:USDCNH

// Functions
isNotifyRed(difference) => difference > notifyRed
isNotifyGreen(difference) => difference < notifyGreen

// Val
difference = nz(nz(src_796[0]) - nz(src_btce[0]))

// Plots
plot(difference, style=line,  linewidth=1, color=isNotifyRed(difference) ? red : isNotifyGreen(difference) ? green : black)

// Band range
//fill(hline(-10), hline(-8), color=green, transp=50)
//fill(hline(10), hline(8), color=red, transp=50)