[FTX Funding Colored Candles] [third eye]
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © junglockahashi

//@version=5
indicator("[FTX Funding Colored Candles] [third eye]", shorttitle = "[FTX Funding Colored Candles] [third eye]", overlay = true)

res = timeframe.period

FTX_BTCPERP = request.security("FTX:BTCPERP", res ,close)

FTX_USD = request.security("FTX:BTCUSD", res ,close) * 0.125
BINANCE_USDC = request.security("BINANCE:BTCUSDC", res ,close) * 0.125
OKEX_USDC = request.security("OKEX:BTCUSDC", res ,close) * 0.125
COINBASE_USD = request.security("COINBASE:BTCUSD", res ,close) * 0.125
COINBASE_USDC = request.security("COINBASE:BTCUSDC", res ,close) * 0.125
KRAKEN_USD = request.security("KRAKEN:BTCUSD", res ,close) * 0.125
BITSTAMP_USD = request.security("BITSTAMP:BTCUSD", res ,close) * 0.125
BITTREX_USD = request.security("BITTREX:BTCUSD", res ,close) * 0.125

FTX_SPOT_INDEX = FTX_USD + BINANCE_USDC + OKEX_USDC + COINBASE_USD + COINBASE_USDC + KRAKEN_USD + BITSTAMP_USD + BITTREX_USD

Basis = FTX_BTCPERP - FTX_SPOT_INDEX

Basis_above_100 = Basis > 100
plotcandle(Basis_above_100 ? open : na, Basis_above_100 ?  high : na, Basis_above_100 ? low : na, Basis_above_100 ? close : na, "Basis above 100",  
 color = color.orange, wickcolor = color.orange, bordercolor=color.orange)
 
Basis_between_75_and_100 = Basis > 75 and Basis < 100
plotcandle(Basis_between_75_and_100 ? open : na, Basis_between_75_and_100 ?  high : na, Basis_between_75_and_100 ? low : na, Basis_between_75_and_100 ? close : na, "Between 75 and 100",  
 color = color.orange, wickcolor = color.orange, bordercolor=color.orange)

Basis_between_50_and_75 = Basis > 50 and Basis < 75
plotcandle(Basis_between_50_and_75 ? open : na, Basis_between_50_and_75 ?  high : na, Basis_between_50_and_75 ? low : na, Basis_between_50_and_75 ? close : na, "Between 50 and 75",  
 color = #fc2003, wickcolor = #fc2003, bordercolor = #fc2003)
 
Basis_between_40_and_50 = Basis > 40 and Basis < 50
plotcandle(Basis_between_40_and_50 ? open : na, Basis_between_40_and_50 ?  high : na, Basis_between_40_and_50 ? low : na, Basis_between_40_and_50 ? close : na, "Between 40 and 50",  
 color = #fc2003, wickcolor = #fc2003, bordercolor = #fc2003)
 
Basis_between_30_and_40 = Basis > 30 and Basis < 40
plotcandle(Basis_between_30_and_40 ? open : na, Basis_between_30_and_40 ?  high : na, Basis_between_30_and_40 ? low : na, Basis_between_30_and_40 ? close : na, "Between 30 and 40",  
 color = #fc2003, wickcolor = #fc2003, bordercolor = #fc2003)
 
Basis_between_20_and_30 = Basis > 20 and Basis < 30
plotcandle(Basis_between_20_and_30 ? open : na, Basis_between_20_and_30 ?  high : na, Basis_between_20_and_30 ? low : na, Basis_between_20_and_30 ? close : na, "Between 20 and 30",  
 color = #fc2003, wickcolor = #fc2003, bordercolor = #fc2003)
 
Basis_between_10_and_20 = Basis > 10 and Basis < 20
plotcandle(Basis_between_10_and_20 ? open : na, Basis_between_10_and_20 ?  high : na, Basis_between_10_and_20 ? low : na, Basis_between_10_and_20 ? close : na, "Between 10 and 20",  
 color = #f0a1c0, wickcolor = #f0a1c0, bordercolor = #f0a1c0)
 
Basis_between_0_and_10 = Basis > 0 and Basis < 10
plotcandle(Basis_between_0_and_10 ? open : na, Basis_between_0_and_10 ?  high : na, Basis_between_0_and_10 ? low : na, Basis_between_0_and_10 ? close : na, "Between 0 and 10",  
 color = #f0a1c0, wickcolor = #f0a1c0, bordercolor = #f0a1c0)
 
Basis_between_0_and_neg10 = Basis < 0 and Basis > -10
plotcandle(Basis_between_0_and_neg10 ? open : na, Basis_between_0_and_neg10 ?  high : na, Basis_between_0_and_neg10 ? low : na, Basis_between_0_and_neg10 ? close : na, "Between 0 and -10",  
 color = #f0a1c0, wickcolor = #f0a1c0, bordercolor = #f0a1c0)
 
Basis_between_neg10_and_neg15 = Basis < -10 and Basis > -15
plotcandle(Basis_between_neg10_and_neg15 ? open : na, Basis_between_neg10_and_neg15 ?  high : na, Basis_between_neg10_and_neg15 ? low : na, Basis_between_neg10_and_neg15 ? close : na, "Between -10 and -15",  
 color = #6228ad , wickcolor = #6228ad, bordercolor = #6228ad )

Basis_between_neg15_and_neg30 = Basis < -15 and Basis > -30
plotcandle(Basis_between_neg15_and_neg30 ? open : na, Basis_between_neg15_and_neg30 ?  high : na, Basis_between_neg15_and_neg30 ? low : na, Basis_between_neg15_and_neg30 ? close : na, "Between -15 and -30",  
 color = #6228ad , wickcolor = #6228ad, bordercolor = #6228ad )

Basis_between_neg30_and_neg40 = Basis < -30 and Basis > -40
plotcandle(Basis_between_neg30_and_neg40 ? open : na, Basis_between_neg30_and_neg40 ?  high : na, Basis_between_neg30_and_neg40 ? low : na, Basis_between_neg30_and_neg40 ? close : na, "Between -30 and -40",  
 color = #6228ad , wickcolor = #6228ad, bordercolor = #6228ad )
 
Basis_between_neg40_and_neg100 = Basis < -40 and Basis > -100
plotcandle(Basis_between_neg40_and_neg100 ? open : na, Basis_between_neg40_and_neg100 ?  high : na, Basis_between_neg40_and_neg100 ? low : na, Basis_between_neg40_and_neg100 ? close : na, "Between -40 and -100",  
 color = #6228ad , wickcolor = #6228ad, bordercolor = #6228ad )
 
Basis_between_neg100_and_neg200 = Basis < -100 and Basis > -200
plotcandle(Basis_between_neg100_and_neg200 ? open : na, Basis_between_neg100_and_neg200 ?  high : na, Basis_between_neg100_and_neg200 ? low : na, Basis_between_neg100_and_neg200 ? close : na, "Below -100",  
 color = #6228ad , wickcolor = #6228ad, bordercolor = #6228ad )

 