lowstrife

Index Vs Futures 3.0

I have compiled the OKCoin Index into my indicator! I updated my previous version

Spot Vs Futures Index

And now we are at 3.0. Cleaned up the code, made the colors friendly to those on white stylesheets. The Index is the same as the OKCoin.com futures settlement index , and it tracks the FX:USDCNY exchange pair. All exchanges have 1\6th weight. This is the closest we will get here on TV.

Huobi/CNY
OKCoin/CNY
BTCChina/CNY
Bitstamp/USD
Bitfinex/USD
OKCoin.com/USD

Now, I do understand there is a bug (I believe it is with TV); where if you compare two symbols with the / marker, not as much price history loads than if you just load a normal symbol. I do not have a workaround for this at the moment so we will just have to deal with incomplete data. It'll be fine.

Enjoy!
Remove from Favorite Scripts Add to Favorite Scripts
// Spot price vs futures - Tradingview.com
// @author lastbattle, lowstrife, Godmode 3.1, Legion, Carbon
study(title="Index Vs Futures", shorttitle="Index Vs Futures 3.0")

// Rcommend 3M futures for best signal
// Futures: OKCOIN:BTCUSD1W, 796:BTCUSD1W, OKCOIN:BTCUSD2W, OKCOIN:BTCUSD3M, BITMEX:XBTH2016
 
//Security - can comment between line 12 and 13 to change between spot and index
src_futures = security("OKCOIN:BTCUSD3M", period, hlc3)
src_index = ((security("BITFINEX:BTCUSD", period, hlc3)+security("BITSTAMP:BTCUSD", period, hlc3)+security("OKCOIN:BTCUSD", period, hlc3)+security("OKCOIN:BTCCNY/FX_IDC:USDCNY", period, hlc3)+security("BTCCHINA:BTCCNY/FX_IDC:USDCNY", period, hlc3)++security("HUOBI:BTCCNY/FX_IDC:USDCNY", period, hlc3))/6)
//src_index = security("OKCOIN:BTCCNY", period, hlc3)

// Values
difference = nz(nz(src_futures[0]) - nz(src_index[0]))
percent = nz(nz(difference[0]) / nz(src_index[0])*100)
len = input(21, minval=1, title="Length")
length = input(21, minval=1)
out = ema(percent, len)
 
// Functions - The dots
signal = out<-0 ? out+0.25 : out>4.5 ? out-0.25 : na
 
// Plots
plot(percent, style=line,  linewidth=1, color=teal)
plot(out, title="EMA", color=red)
plot(signal, title="Caution!", color=yellow, style=circles, linewidth=1)
band1 = hline(6)
band0 = hline(-0.5)
Ideas Scripts Chart
United States
United Kingdom
India
España
Italia
Brasil
Россия
Türkiye
日本
한국
Home Stock Screener Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Private Messages Chat Ideas Published Followers Following Priority Support Public Profile Profile Settings Billing Sign Out