creationlayer

Bitcoin Index vs. Futures OKCoin Weekly

237 1 36
Simple adaptation to lastbattles script to add calculation for index price: calculation can be seen here: https://www.okcoin.com/future/market.do?symbol=2

I recommend setting it to columns, and setting price at 0, 0 to see divergence of sell/buy.
Remove from Favorite Scripts Add to Favorite Scripts
// Futures Fomo - Tradingview.com
// Update of @lastbattle script to account for OKCoin futures index scheme
study(title="Bitcoin Index vs. Futures OKCoin Weekly", shorttitle="Futures Price Difference")

// Inputs from user
notifyRed = input(0, 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
futures = security("OKCOIN:BTCUSD1W", period, close)
spot1 = security("BITFINEX:BTCUSD", period, close) 
spot2 = security("OKCOIN:BTCUSD", period, close)
spot3 = security("OKCOIN:BTCCNY / FX:USDCNH", period, close)
spot4 = security("HUOBI:BTCCNY / FX:USDCNH", period, close)
spot5 = security("BTCCHINA:BTCCNY / FX:USDCNH", period, close)
spot6 = security("BITSTAMP:BTCUSD", period, close)
spot = (spot1+spot2+spot3+spot4+spot5+spot6) / 6

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

// Val
difference = nz(nz(futures[0]) - nz(spot[0]))

// Plots
plot(difference, style=line,  linewidth=1, color=isNotifyRed(difference) ? red : isNotifyGreen(difference) ? green : black)
I realize the indicator is based upon a rolling average of CNY price, but I do not know the exact methodology to implement this in the script any help is appreciated.
Reply
Ideas Scripts Chart
United States
United Kingdom
India
España
France
Italia
Polska
Brasil
Россия
Türkiye
Indonesia
日本
한국
Home Stock Screener Forex Signal Finder 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 Account and Billing Sign Out