0% found this document useful (0 votes)
126 views

COT+Code

This document defines functions to retrieve Commitment of Traders (COT) data from Quandl for different commodities and indexes. It specifies the Quandl codes and whether positions are inverted based on the ticker. Plots are generated showing the long and short positions for both total commercials and large speculators over time.

Uploaded by

mutoto andrew
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
126 views

COT+Code

This document defines functions to retrieve Commitment of Traders (COT) data from Quandl for different commodities and indexes. It specifies the Quandl codes and whether positions are inverted based on the ticker. Plots are generated showing the long and short positions for both total commercials and large speculators over time.

Uploaded by

mutoto andrew
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

//@version=3

study("COMMITMENT OF TRADERS", shorttitle="COT", precision=0)

force_root = input("", title="Override Product")

fxroot =

ticker == "USDCAD" ? "090741" :

ticker == "USDCAD" ? "090741" :

ticker == "USDCHF" ? "092741" :

ticker == "USDCZK" ? "CZ" :

ticker == "USDHUF" ? "FR" :

ticker == "USDILS" ? "IS" :

ticker == "USDJPY" ? "097741" :

ticker == "USDMXN" ? "095741" :

ticker == "USDNOK" ? "UN" :

ticker == "USDPLN" ? "PZ" :

ticker == "USDRUB" ? "089741" :

ticker == "USDSEK" ? "SE" :

ticker == "USDZAR" ? "122741" :

ticker == "EURUSD" ? "099741" :

ticker == "AUDUSD" ? "232741" :

ticker == "GBPUSD" ? "096742" :

ticker == "NZDUSD" ? "112741" :

ticker == "BRLUSD" ? "102741" :

ticker == "USOIL" ? "067411" :

ticker == "CL1!" ? "067411" :

ticker == "US30" ? "020601" :

ticker == "US10" ? "043602" :

ticker == "ZB1!" ? "020601" :


ticker == "ZN1!" ? "043602" :

ticker == "ZF1!" ? "044601" :

ticker == "US05" ? "044601" :

ticker == "ZT1!" ? "042601" :

ticker == "US02" ? "042601" :

ticker == "GC1!" ? "088691" :

ticker == "XAUUSD" ? "088691" :

ticker == "SOYBNUSD" ? "005602" :

ticker == "ZS1!" ? "005602" :

ticker == "ES1!" ? "13874A" :

ticker == "SPX" ? "13874A" :

ticker == "A61!" ? "232741" :

ticker == "B61!" ? "096742" :

ticker == "D61!" ? "090741" :

ticker == "E61!" ? "099741" :

ticker == "J61!" ? "097741" :

ticker == "N61!" ? "112741" :

ticker == "S61!" ? "092741" :

ticker == "ZW1!" ? "001626" :

ticker == "DX1!" ? "098662" :

ticker == "ZM1!" ? "026603" :

ticker == "CC1!" ? "073732" :

ticker == "KC1!" ? "083731" :

ticker == "HG1!" ? "085692" :

ticker == "ZC1!" ? "002602" :

ticker == "CORNUSD" ? "002602" :

ticker == "YM1!" ? "12460P" :

ticker == "NQ1!" ? "20974P" :


ticker == "NG1!" ? "023651" :

ticker == "GE1!" ? "132741" :

ticker == "HO1!" ? "022651" :

ticker == "RB1!" ? "111659" :

ticker == "O1!" ? "004603" :

ticker == "PL1!" ? "076651" :

ticker == "SI1!" ? "084691" :

ticker == "RJ1!" ? "TF" :

ticker == "ZM1!" ? "026603" :

ticker == "SM1!" ? "026603" :

ticker == "ZL1!" ? "007601" :

ticker == "BO1!" ? "007601" :

ticker == "WHEATUSD" ? "001626" :

ticker == "W1!" ? "001626" :

""

root = force_root == "" ? fxroot == "" ? syminfo.root : fxroot : force_root

quandlcode = root + "_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 :

ticker == "C61!" ? true :

ticker == "J61!" ? true :

ticker == "S61!" ? true :

false

long_total_cms = security("QUANDL:CFTC/"+quandlcode+"|4", "D", close)

short_total_cms = security("QUANDL:CFTC/"+quandlcode+"|5", "D", close)

long_LargeSpecs = security("QUANDL:CFTC/"+quandlcode+"|1", "D", close)

short_LargeSpecs = security("QUANDL:CFTC/"+quandlcode+"|2", "D", close)

long_cms = is_inversed ? short_total_cms : long_total_cms

short_cms = is_inversed ? long_total_cms : short_total_cms

longls = is_inversed ? short_LargeSpecs : long_LargeSpecs

shortls = is_inversed ? long_LargeSpecs : short_LargeSpecs

plot(long_cms, color = blue, transp=0, title="Long Comms",linewidth=2)

plot(short_cms, color = orange, transp=0, title="Short Comms",linewidth=2)

plot(long_cms-short_cms, color = red, transp=0, title="Comms Net", style=line,linewidth=2)

hline(0, color=orange, linestyle=dotted,linewidth=2)


plot(longls, color = #9933ff, transp=0, title="Long Large Specs", linewidth=2)

plot(shortls, color = #996600, transp=0, title="Short Large Specs", linewidth=2)

plot(longls-shortls, color = green, transp=0, title="Large Spec Net", style=line, linewidth=2)

plot(close)

You might also like