trader006

COT Index

1180 1 78
COT Index
Remove from Favorite Scripts Add to Favorite Scripts
//@version=2
study("COT Index", shorttitle="COT index L", precision=2)

length = input(13, title="La/Sm Týdnů")
is_includeoptions = input(true, type=bool, title="Včetně opcí")
force_root = input("", title="Jiný podklad")
nasobek = iff(isdaily,5,1)

coticker =
	  ticker == "AUDUSD" ? "AD" :
	  ticker == "GBPUSD" ? "BP" :
	  ticker == "NZDUSD" ? "NE" :
	  ticker == "BRLUSD" ? "BR" :
	  ticker == "USDCAD" ? "CD" :
	  ticker == "USDCHF" ? "SF" :
	  ticker == "USDCZK" ? "CZ" :
	  ticker == "USDHUF" ? "FR" :
	  ticker == "USDILS" ? "IS" :
	  ticker == "USDJPY" ? "JY" :
	  ticker == "USDMXN" ? "MP" :
	  ticker == "USDNOK" ? "UN" :
	  ticker == "USDPLN" ? "PZ" :
	  ticker == "USDRUB" ? "RU" :
	  ticker == "USDSEK" ? "SE" :
	  ticker == "USDZAR" ? "RA" :
	  ticker == "EURUSD" ? "EC" :
	  ticker == "E61!"   ? "EC" :
	  ticker == "S61!"   ? "SF" :
	  ticker == "J61!"   ? "JY" :
	  ticker == "D61!"   ? "CD" :
	  ticker == "A61!"   ? "AD" :
	  ticker == "N61!"   ? "NE" :
	  ticker == "B61!"   ? "BP" :
	  ticker == "M61!"   ? "MP" :
	  ticker == "YO1!"   ? "MP" :
	  ticker == "6M1!"   ? "MP" :
	  ticker == "DXY"    ? "DX" :

	  ticker == "ZC1!"   ? "C"  :
	  ticker == "ZS1!"   ? "S"  :
	  ticker == "ZM1!"   ? "SM" :
	  ticker == "ZL1!"   ? "BO" :
	  ticker == "ZW1!"   ? "W"  :
	  ticker == "KE1!"   ? "KW" :
	  ticker == "ZO1!"   ? "O"  :
	  ticker == "ZR1!"   ? "RR" :

	  ticker == "COPPER" ? "HG" :
	  ticker == "XAUUSD" ? "GC" :
	  ticker == "XAGUSD" ? "SI" :

	  ticker == "LE1!"   ? "LC" :
	  ticker == "GF1!"   ? "FC" :
	  ticker == "HE1!"   ? "LH" :

	  ticker == "SPX"    ? "SP" :
	  ticker == "SPY"    ? "ES" :
	  ticker == "IUXX"   ? "NQ" :
	  ticker == "DJY0"   ? "DJ" :
	  ticker == "IUX"    ? "TF" :
	  ticker == "IWM"    ? "TF" :
	  ticker == "TNA"    ? "TF" :
	  ticker == "RJ1!"   ? "TF" :
	  ticker == "IDX"    ? "MD" :
	  ticker == "MDY0"   ? "MD" :
	  ticker == "GE1!"   ? "ED" :
	  ticker == "ZQ1!"   ? "FF" :
	  ticker == "ZT1!"   ? "TU" :
	  ticker == "ZF1!"   ? "FV" :
	  ticker == "ZN1!"   ? "TY" :
	  ticker == "ZB1!"   ? "US" :

	  ticker == "FL1!"   ? "CU" :
	  ticker == "VI1!"   ? "VX" :
	  ticker == "VIX"    ? "VX" :
	  ticker == "NY1!"   ? "NK" :
	  ticker == "USOIL"  ? "CL" :
	  ""

root = force_root == "" ? (coticker == "" ? syminfo.root : coticker) : force_root
code = "QUANDL:CFTC/"+root+(is_includeoptions ? "_FO_L_ALL|" : "_F_L_ALL|")

long_comm = security(code + "4", "W", close)
short_comm = security(code + "5", "W", close)

long_large = security(code + "1", "W", close)
short_large = security(code + "2", "W", close)

long_small = security(code + "8", "W", close)
short_small = security(code + "9", "W", close)

net_comm = long_comm-short_comm
net_large = long_large-short_large
net_small = long_small-short_small

max_comm_tr = highest(net_comm, 13 * nasobek)
min_comm_tr = lowest(net_comm, 13 * nasobek)
index_comm_tr = sma(100 * (net_comm - min_comm_tr) / (max_comm_tr - min_comm_tr),nasobek)
max_comm_dv = highest(net_comm, 26 * nasobek)
min_comm_dv = lowest(net_comm, 26 * nasobek)
index_comm_dv = sma(100 * (net_comm - min_comm_dv) / (max_comm_dv - min_comm_dv),nasobek)
max_comm_pa = highest(net_comm, 52 * nasobek)
min_comm_pa = lowest(net_comm, 52 * nasobek)
index_comm_pa = sma(100 * (net_comm - min_comm_pa) / (max_comm_pa - min_comm_pa),nasobek)

max_large = highest(net_large, length * nasobek)
min_large = lowest(net_large, length * nasobek)
index_large = sma(100 * (net_large - min_large) / (max_large - min_large),nasobek)

max_small = highest(net_small, length * nasobek)
min_small = lowest(net_small, length * nasobek)
index_small = sma(100 * (net_small - min_small) / (max_small - min_small),nasobek)

plot(index_comm_tr, color = blue, title="Comm 13", style=line, linewidth=2)
plot(index_comm_dv, color = #00B0FF, title="Comm 26", style=line, linewidth=1)
plot(index_comm_pa, color = #B000FF, title="Comm 52", style=line, linewidth=1)
plot(index_large, color = green, title="Large", style=line, linewidth=1)
plot(index_small, color = red, title="Small", style=line, linewidth=1)

hline(95, color=lime, linestyle=dashed, title="Horní extrém")
hline(5, color=lime, linestyle=dashed, title="Dolní extrém")
Thanks
Reply
English
English (UK)
English (IN)
Deutsch
Français
Español
Italiano
Polski
Türkçe
Русский
Português
Bahasa Indonesia
Bahasa Melayu
ภาษาไทย
Tiếng Việt
日本語
한국어
简体中文
繁體中文
Home Stock Screener Forex Signal Finder Cryptocurrency Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators Website & Broker Solutions Widgets Stock Charting Library Feature Request Blog & News FAQ Help & Wiki Twitter
Profile Profile Settings Account and Billing My Support Tickets Contact Support Ideas Published Followers Following Private Messages Chat Sign Out