Ku-Chart
https://gyazo.com/faffc3d8f34dc3452b72ef608e37b6f2
Pineスクリプト
code:Pineスクリプト(js)
//@version=3
study(title="Ku-Chart")
hide_bool = input(true ,title="show top2 bot2 on/off")
is_enable = timeframe=="Daily" and period!="M" and period!="W" ? true
: timeframe=="Weekly" and period!="M" ? true
: timeframe=="Monthly" or timeframe=="Yearly" ? true
: false
calc_log(target) => nz( log( 1 + roc(target ,1) ))
EURUSD = is_enable ? calc_log(security('FX:EURUSD' ,period ,close)) : 0
GBPUSD = is_enable ? calc_log(security('FX:GBPUSD' ,period ,close)) : 0
USDJPY = is_enable ? calc_log(security('FX:USDJPY' ,period ,close)) : 0
USDCHF = is_enable ? calc_log(security('FX:USDCHF' ,period ,close)) : 0
AUDUSD = is_enable ? calc_log(security('FX:AUDUSD' ,period ,close)) : 0
USDCAD = is_enable ? calc_log(security('FX:USDCAD' ,period ,close)) : 0
NZDUSD = is_enable ? calc_log(security('FX:NZDUSD' ,period ,close)) : 0
ku_usd = ( -EURUSD -GBPUSD +USDJPY +USDCHF -AUDUSD +USDCAD -NZDUSD ) / 8
ku_eur = EURUSD + ku_usd
ku_gbp = GBPUSD + ku_usd
ku_jpy = -USDJPY + ku_usd
ku_chf = -USDCHF + ku_usd
ku_aud = AUDUSD + ku_usd
ku_cad = -USDCAD + ku_usd
ku_nzd = NZDUSD + ku_usd
is_zero = timeframe=="Daily" and dayofmonth1!=dayofmonth ? true : timeframe=="Weekly" and weekofyear1!=weekofyear ? true : timeframe=="Monthly" and month1!=month ? true : timeframe=="Yearly" and year1!=year ? true : false
tf_ku_usd = 0.0
tf_ku_eur = 0.0
tf_ku_gbp = 0.0
tf_ku_jpy = 0.0
tf_ku_chf = 0.0
tf_ku_aud = 0.0
tf_ku_cad = 0.0
tf_ku_nzd = 0.0
tf_ku_usd := is_zero ? na : nz(tf_ku_usd1) + ku_usd tf_ku_eur := is_zero ? na : nz(tf_ku_eur1) + ku_eur tf_ku_gbp := is_zero ? na : nz(tf_ku_gbp1) + ku_gbp tf_ku_jpy := is_zero ? na : nz(tf_ku_jpy1) + ku_jpy tf_ku_chf := is_zero ? na : nz(tf_ku_chf1) + ku_chf tf_ku_aud := is_zero ? na : nz(tf_ku_aud1) + ku_aud tf_ku_cad := is_zero ? na : nz(tf_ku_cad1) + ku_cad tf_ku_nzd := is_zero ? na : nz(tf_ku_nzd1) + ku_nzd rank(target) =>
_1 = target > tf_ku_usd ? 0 : 1
_2 = target > tf_ku_eur ? 0 : 1
_3 = target > tf_ku_gbp ? 0 : 1
_4 = target > tf_ku_jpy ? 0 : 1
_5 = target > tf_ku_chf ? 0 : 1
_6 = target > tf_ku_aud ? 0 : 1
_7 = target > tf_ku_cad ? 0 : 1
_8 = target > tf_ku_nzd ? 0 : 1
_1 + _2 + _3 + _4 + _5 + _6 + _7 + _8
plot(hide_bool==false or (hide_bool and (rank(tf_ku_usd)<3 or rank(tf_ku_usd)>6)) ? tf_ku_usd : na ,title="Ku_USD" ,color=red ,linewidth=2 ,style=linebr)
plot(hide_bool==false or (hide_bool and (rank(tf_ku_eur)<3 or rank(tf_ku_eur)>6)) ? tf_ku_eur : na ,title="Ku_EUR" ,color=blue ,linewidth=2 ,style=linebr)
plot(hide_bool==false or (hide_bool and (rank(tf_ku_gbp)<3 or rank(tf_ku_gbp)>6)) ? tf_ku_gbp : na ,title="Ku_GBP" ,color=olive ,linewidth=2 ,style=linebr)
plot(hide_bool==false or (hide_bool and (rank(tf_ku_jpy)<3 or rank(tf_ku_jpy)>6)) ? tf_ku_jpy : na ,title="Ku_JPY" ,color=fuchsia ,linewidth=2 ,style=linebr)
plot(hide_bool==false or (hide_bool and (rank(tf_ku_chf)<3 or rank(tf_ku_chf)>6)) ? tf_ku_chf : na ,title="Ku_CHF" ,color=silver ,linewidth=2 ,style=linebr)
plot(hide_bool==false or (hide_bool and (rank(tf_ku_aud)<3 or rank(tf_ku_aud)>6)) ? tf_ku_aud : na ,title="Ku_AUD" ,color=teal ,linewidth=2 ,style=linebr)
plot(hide_bool==false or (hide_bool and (rank(tf_ku_cad)<3 or rank(tf_ku_cad)>6)) ? tf_ku_cad : na ,title="Ku_CAD" ,color=orange ,linewidth=2 ,style=linebr)
plot(hide_bool==false or (hide_bool and (rank(tf_ku_nzd)<3 or rank(tf_ku_nzd)>6)) ? tf_ku_nzd : na ,title="Ku_NZD" ,color=lime ,linewidth=2 ,style=linebr)
hline(0 ,title="0" ,color=black ,linestyle=dashed)