Greeny

COT (Legacy): Commercial Index

cot
290 7 48
cot
Commercial Index . COT Index based on commercial net value.
Remove from Favorite Scripts Add to Favorite Scripts
study("Commercial Index", shorttitle="Com Index", precision=2)
force_root = input("", title="Override Product")
is_includeoptions = input(false, type=bool, title="Include Options")

fxroot =
	  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 == "AUDUSD" ? "AD" : 
	  ticker == "GBPUSD" ? "BP" : 
	  ticker == "NZDUSD" ? "NE" : 
	  ticker == "BRLUSD" ? "BR" : 
	  ""
root = force_root == "" ? fxroot == "" ? syminfo.root : fxroot : force_root
code = root + (is_includeoptions ? "_FO_L_ALL" : "_F_L_ALL")

is_inversed = 
	  ticker == "USDCAD" ? true : 
	  ticker == "USDCHF" ? true : 
	  ticker == "USDCZK" ? true : 
	  ticker == "USDHUF" ? true : 
	  ticker == "USDILS" ? true : 
	  ticker == "USDJPY" ? true : 
	  ticker == "USDMXN" ? true : 
	  ticker == "USDNOK" ? true : 
	  ticker == "USDPLN" ? true : 
	  ticker == "USDRUB" ? true : 
	  ticker == "USDSEK" ? true : 
	  ticker == "USDZAR" ? true : 
	  false

long_total = security("QUANDL:CFTC/"+code+"|4", "D", close)
short_total = close

long = is_inversed ? short_total : long_total
short = is_inversed ? long_total : short_total
net = long-short

length = input(24, title="Period (weeks)")

max = highest(net, length)
min = lowest(net, length)
index = 100 * (net - min) / (max - min)

index_adopted = security("QUANDL:CFTC/"+code+"|5", "D", index)

plot(index_adopted, color = black, title="Index", style=line)
hline(60, color=blue, linestyle=dashed)
hline(10, color=blue, linestyle=dashed)
motcha1
2 years ago
Oh my God Greeny You are the best on Trading View!! I'm sorry to push it but since you are my savior at the moment, can you do it for Gold and silver? and do you know how to construct Willco?
You are a genius man, no one on the site was able to do those! keep up the good work. I'm sure as hell subscribing to you.
Reply
Greeny PRO motcha1
2 years ago
Apply this indicator on the chart and switch to GC1! (Gold) or SI1! (Silver). Alternatively you may override product in the indicator inputs - use GC for gold and SI for silver.
Reply
motcha1 Greeny
2 years ago
Brilliant thanks!
Reply
motcha1
2 years ago
I do have a question as well, the period is 6 months? by period I mean the highs and lows used in the formula.
Reply
Greeny PRO motcha1
2 years ago
BY default period is 6 months (24 weeks). You may change it in the indicator inputs.
Reply
motcha1
2 years ago
Willco of course is commercial net position/open interest.
Reply
Greeny PRO motcha1
2 years ago
Try this
William
Reply
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