Greeny

COT (Legacy): Commercial Interest

Open Interest for commercial traders from legacy commitment of traders ( COT ) report. For the main symbol but also allows to override it. Also allows to include options in consideration.
Remove from Favorite Scripts Add to Favorite Scripts
study("Commercial Interest", shorttitle="Com Int", precision=0)
force_root = input("", title="Override Product")
is_includeoptions = input(false, type=bool, title="Include Options")

fxroot =
	  ticker == "USDCAD" ? "CD" : 
	  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 == "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 = security("QUANDL:CFTC/"+code+"|5", "D", close)

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

plot(long, color = green, title="Long")
plot(short, color = red, title="Short")
plot(long-short, color = yellow, title="Net", style=histogram)
hline(0, color=yellow, linestyle=dashed)
Is there a way to add the EURGBP pair to this? I tried editing the code by adding to the fxroot variable but it doesn't display (other pairs work). The CFTC code is #299741
Reply
Hi Greeny! Same comment as on the Open interest, how do I create the Commercial interest for gold ? W hat is important here is to show the net commercial position as a line. Is it possbile?
+2 Reply
1. Apply this script to the chart
2. Switch the GC1!
3. Go to the indicator settings and change Net style from histogram to line.
+1 Reply
what do you mean apply the scipt to the chart? copy the script and paste it in the pine scipt editor?
Reply
Greeny, can I ask you to TEST something please:

CONTRACT CLU2014 (SEPTEMBER CRUDE_OIL FUTURE)

WHAT IS THE NET COMMERCIAL POSITION (long-short) YOU GET ON THE CHART?

Thank you
Reply
Greeny

seems ok on the 1st check:

CRUDE OIL

NET COMMERCIAL = -404265 contracts

The only thing is that this data refers to the 22nd of July. The new CFTC report of the 29th of July has already been issued. So we have two weeks old data. I'm chacking with Qundnl where are they normally uploading the data. We need to have the results as sson as possible, there could be big chnages in two weeks...


Crude
+1 Reply
I have the same number.
Agree, quandl needs to adjust their update policy for this datasets. I'll try to contact them also.
+1 Reply
great, the results are issued by CFTC on friday. In reality they refer to the data collected on the previous tuesday, but nothing we can do here this is how CFTC works. If we can have the data the same day (friday) or saturday it's ok. I have tried to use the code for the GRAINS (wheat, soybeans, corn etc) but it doesn't work. Is it the same for you? Try for example ZSU2104 (September Soybean)
+1 Reply
HI Greeny,

how can I get the chart from CME contracts such as grains (soybean, wheat, corn etc) or live stock (such as live cattle, hogs etc). If I use this code the vhart doen't appear. I have talked to the quandl (thay could have choosen and easier name..:) and they said all the data is there ready
+2 Reply
sorry for the typos .. I'm on the train..
Reply
United States
United Kingdom
India
Deutschland
España
France
Việt Nam
Italia
Polska
Brasil
Россия
Türkiye
Indonesia
Malaysia
日本
한국
简体
繁體
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 Support Priority Support Report Issue Ideas Published Followers Following Private Messages Chat Sign Out