OPEN-SOURCE SCRIPT
Cập nhật COT Index

Reference:
Trade Stocks and Commodities with the Insiders
Secrets of the COT Report by Larry Williams pg34
The equation is as below:
Current week's value- Lowest value of last three years
---------------------------------------------------------------------------- X 100%
Highest high of last three years-Lowest low of last three years
According to Larry Williams, traders should follow commercials direction. When the commercial index line (yellow line) is above 80, this indicates commercials are bullish. Hence, traders can look for potential buy setup. Conversely, when commercials index line (yellow line) is below 20, this indicates commercials are bearish, we can look for sell setup.
Do note that this is only applicable on Weekly chart as COT reports come out on weekly basis.
Modification from the original COT index from Larry Williams:
1) I've added 1year and 6months period, so traders maybe can look for pullback using shorter period. By default, Larry Williams uses 3 years Commercial index.
2) I've added non-commercials and retail traders index, they basically trade opposite way of commercials.
This indicator should not be used as a timing tool or entry tool, you can use it as your weekly or monthly bias tool. For more information, please read the books. Feel free to modify the code, if u have a better version of this, you may share to me if you want, I will be very grateful!
Trade Stocks and Commodities with the Insiders
Secrets of the COT Report by Larry Williams pg34
The equation is as below:
Current week's value- Lowest value of last three years
---------------------------------------------------------------------------- X 100%
Highest high of last three years-Lowest low of last three years
According to Larry Williams, traders should follow commercials direction. When the commercial index line (yellow line) is above 80, this indicates commercials are bullish. Hence, traders can look for potential buy setup. Conversely, when commercials index line (yellow line) is below 20, this indicates commercials are bearish, we can look for sell setup.
Do note that this is only applicable on Weekly chart as COT reports come out on weekly basis.
Modification from the original COT index from Larry Williams:
1) I've added 1year and 6months period, so traders maybe can look for pullback using shorter period. By default, Larry Williams uses 3 years Commercial index.
2) I've added non-commercials and retail traders index, they basically trade opposite way of commercials.
This indicator should not be used as a timing tool or entry tool, you can use it as your weekly or monthly bias tool. For more information, please read the books. Feel free to modify the code, if u have a better version of this, you may share to me if you want, I will be very grateful!
Phát hành các Ghi chú
Now available more futures chartPhát hành các Ghi chú
# COT Index Indicator - Update Notes## Version 2.0 - Bug Fixes & Data Consistency Improvements
### Bug Fixes
- Fixed syntax error: "end of line without line continuation" in multi-line string concatenation
- Resolved indentation issues with Pine Script line continuation rules
- Corrected data inconsistencies from automatic CFTC code detection
### Major Changes
- **Manual CFTC Code Mapping**: Switched from automatic detection to manual mapping to ensure data accuracy and consistency
- **Verification Table**: Added optional data table showing current week's Commercial Long, Short, and Net Position values
- **CFTC Code Display**: Table now shows which CFTC code is being used for transparency
### Supported Symbols
Please use **ONLY** the official CME/COMEX/CBOT/NYMEX futures symbols listed below:
#### **Metals** (COMEX)
- `GC` - Gold
- `SI` - Silver
- `HG` - Copper
- `PL` - Platinum
- `PA` - Palladium
#### **Energy** (NYMEX)
- `CL` - Crude Oil WTI
- `NG` - Natural Gas
- `RB` - RBOB Gasoline
- `HO` - Heating Oil
#### **Equity Indices** (CME)
- `ES` - E-mini S&P 500
- `NQ` - E-mini NASDAQ-100
- `YM` - E-mini Dow Jones
- `RTY` - E-mini Russell 2000
- `NIY` / `NKD` - Nikkei 225
#### **Currencies** (CME)
- `6E` - Euro FX
- `6B` - British Pound
- `6J` - Japanese Yen
- `6A` - Australian Dollar
- `6C` - Canadian Dollar
- `6S` - Swiss Franc
- `6N` - New Zealand Dollar
- `6M` - Mexican Peso
- `DX` - U.S. Dollar Index
*Note: Spot forex pairs (EURUSD, GBPUSD, etc.) are supported and will automatically map to their futures equivalents*
#### **Grains** (CBOT)
- `ZC` - Corn
- `ZS` - Soybeans
- `ZW` - Wheat
- `ZL` - Soybean Oil
- `ZM` - Soybean Meal
#### **Softs** (ICE/CME)
- `KC` - Coffee
- `SB` - Sugar #11
- `CT` - Cotton
- `CC` - Cocoa
- `LBR` - Lumber
#### **Livestock** (CME)
- `LE` - Live Cattle
- `HE` - Lean Hogs
- `GF` - Feeder Cattle
#### **Treasuries** (CBOT)
- `ZB` - 30-Year T-Bond
- `ZN` - 10-Year T-Note
- `ZF` - 5-Year T-Note
- `ZT` - 2-Year T-Note
#### **Crypto** (CME)
- `BTC` - Bitcoin Futures
- `ETH` - Ethereum Futures
### 📡 Data Provider
**CFTC (Commodity Futures Trading Commission)** via TradingView's LibraryCOT/4
- Data updates: Weekly (Fridays after market close)
- Report type: Legacy COT Reports
- Coverage: Futures Only or Futures + Options (user selectable)
### New Settings
- `Show Verification Table` - Toggle to display current week data summary
### Important Notes
1. **Use official futures symbols only** - Using other symbol formats may result in errors
2. COT data is updated weekly and reflects positions as of Tuesday, published Friday
3. If you encounter "Symbol not supported" error, please verify you're using the correct futures symbol from the list above
4. The verification table shows the CFTC code being used - helpful for troubleshooting
---
**Data Source**: U.S. Commodity Futures Trading Commission (CFTC)
**Powered by**: TradingView LibraryCOT/4
**Inspiration**: Larry Williams' COT methodology
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.