vertex21

COT Swap dealers Net positions

86
If Swap dealers net positions grows then price grows too, else counterpart
오픈 소스 스크립트

이 스크립트의 오써는 참된 트레이딩뷰의 스피릿으로 이 스크립트를 오픈소스로 퍼블리쉬하여 트레이더들로 하여금 이해 및 검증할 수 있도록 하였습니다. 오써를 응원합니다! 스크립트를 무료로 쓸 수 있지만, 다른 퍼블리케이션에서 이 코드를 재사용하는 것은 하우스룰을 따릅니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

차트에 이 스크립트를 사용하시겠습니까?
//Created by ChrisMoody on 3-30-2015
//Shows Net Commercials
//Full Credit goes to Greeny fo rcreating original code.  I only made slight modifications.
//Modifications include - Taking away Net Longs and Shorts, Adding Background Highlighting when Commercials go from Long to Short
//Methodology Is from Jake Bernstein at www.Trade-Futures.com and www.2Chimps.net

study("COT Swap dealers Net positions", shorttitle="COT Swap Net", precision=0)
force_root = input("", title="Override Product")
is_includeoptions = input(false, type=bool, title="Include Options")
si = input(false, type=bool, title="Show Inverse")
sbc = input(false, type=bool, title="Color Price Bars?")
sbg = input(true, type=bool, title="Show Background Highlight when Commercials Change From Buying to Selling?")
sa1 = input(true, type=bool, title="Alert If Commercials Change From Buying to Selling?")

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" :
	  ticker == "USDWTI" ? "WT" :
	  ""
//root = force_root == "" ? fxroot == "" ? syminfo.root : fxroot : force_root
//code = root + (is_includeoptions ? "CL_F_ALL" : "CL_FO_ALL")
code = is_includeoptions ? "CL_FO_ALL" : "CL_F_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 == "USDWTI" ? true :
	  false

long_total = security("QUANDL:CFTC/"+code+"|3", "D", close)
short_total = security("QUANDL:CFTC/"+code+"|4", "D", close)
//Code for Commercials Net Totals
long = is_inversed ? short_total : long_total
short = is_inversed ? long_total : short_total
net = long - short
//Alert criteria
alert1 = net[1] > 0 and net < 0 ? 1 : 0
//Code for Histogram Color
col= net > 0 ? green : red

plot(si and long-short ? (long-short)*-1 : long-short, color = col, title="Net", style=columns)
hline(0, color=black, linestyle=dashed)
barcolor(sbc and (net[1] > 0 and net < 0) ? orange : na)
bgcolor(sbg and (net[1] > 0 and net < 0) ? lime : na, transp=20)

plot(sa1 and alert1 ? alert1 : 0, title="Alert If Commercials Go From Net Buy to Sell", style=line, linewidth=2, color=lime)