OPEN-SOURCE SCRIPT
تم تحديثه COT Heatmap [invincible3]

COT Heatmap [invincible3]
COT Heatmap is a professional Commitment of Traders dashboard designed to visualize historical positioning pressure between two selected markets, currencies, commodities, indices, or crypto futures. The indicator converts weekly COT positioning data into an easy-to-read heatmap table, allowing traders to compare Non-Commercial and Commercial positioning strength, extremes, long/short participation, and A-B spread pressure directly on the chart.
The tool is built for macro, forex, commodities, futures, and intermarket analysis. It can automatically detect the current chart symbol or allow the user to manually select Pair A and Pair B from a predefined COT market list.
-----------------------------------------------------------------------------------------------
Main Features
-----------------------------------------------------------------------------------------------
Data Source
The indicator uses weekly COT data through TradingView’s COT Library.
Available data modes:
Futures Only
Uses futures positioning data only.
Futures and Options
Uses combined futures and options positioning data.
The indicator uses Legacy COT report categories:
All COT calculations are performed on the weekly timeframe.
-----------------------------------------------------------------------------------------------
Participant Modes
The indicator supports three participant display modes:
Non-Commercial Only
Shows speculative positioning metrics.
Commercial Only
Shows hedger/commercial positioning metrics.
Both
Shows both Non-Commercial and Commercial metrics side by side.
-----------------------------------------------------------------------------------------------
Core Positioning Formulas
For each selected market:
Open Interest
OI = Total Open Interest
Non-Commercial Net Position
NC Net = NC Long − NC Short
Commercial Net Position
Commercial Net = Commercial Long − Commercial Short
Long Change
Long Change = Current Long − Previous Week Long
Short Change
Short Change = Current Short − Previous Week Short
Net Change
Net Change = Long Change − Short Change
-----------------------------------------------------------------------------------------------
Long% and Short% Formulas
The indicator normalizes long and short positions against open interest.
Long Percentage
Long% = Long Positions / Open Interest × 100
Short Percentage
Short% = Short Positions / Open Interest × 100
These values show how much of total open interest is held on the long or short side by a specific participant group.
-----------------------------------------------------------------------------------------------
Flip% Formula
Flip% measures the net long/short bias as a percentage of open interest.
Flip%
Flip% = Long% − Short%
Interpretation:
Example:
If Non-Commercial Long% = 42%
and Non-Commercial Short% = 25%
Then:
NC Flip% = 42 − 25 = +17%
This means Non-Commercial traders are net long by 17% of open interest.
-----------------------------------------------------------------------------------------------
Difference Metrics
The indicator compares Non-Commercial and Commercial net positioning.
Non-Commercial Difference
NC Difference = NC Net − Commercial Net
This measures how strongly speculative positioning differs from commercial positioning.
Commercial Difference
Commercial Difference = Commercial Net − NC Net
This is the inverse view, useful when analyzing commercial hedger pressure.
-----------------------------------------------------------------------------------------------
Diff13 / Diff26 / Diff52 Formulas
The Diff columns are stochastic-style normalized scores of the positioning difference over different historical windows.
Stochastic Positioning Score
Stoch(X, Length) =
(X − Lowest(X, Length)) / (Highest(X, Length) − Lowest(X, Length)) × 100
If the range is zero, the value returns 50.
Where:
NC Diff13*
NC Diff13 = Stoch(NC Difference, 13)
NC Diff26
NC Diff26 = Stoch(NC Difference, 26)
NC Diff52
NC Diff52 = Stoch(NC Difference, 52)
Commercial Diff13
Commercial Diff13 = Stoch(Commercial Difference, 13)
Commercial Diff26
Commercial Diff26 = Stoch(Commercial Difference, 26)
Commercial Diff52
Commercial Diff52 = Stoch(Commercial Difference, 52)
Interpretation:
-----------------------------------------------------------------------------------------------
COT Index Formulas
The COT Index measures where current net positioning stands relative to its own historical range.
COT Index
COT Index =
(Current Net Position − Lowest Net Position over N weeks) /
(Highest Net Position over N weeks − Lowest Net Position over N weeks) × 100
If the range is zero, the value returns 50.
-----------------------------------------------------------------------------------------------
Non-Commercial COT Index
NC Index 52
NCIdx52 = Stoch(NC Net, 52)
This shows where current Non-Commercial net positioning stands within its 1-year range.
NC Index 156
NCIdx156 = Stoch(NC Net, 156)
This shows where current Non-Commercial net positioning stands within its 3-year range.
-----------------------------------------------------------------------------------------------
Commercial COT Index
Commercial Index 52
ComIdx52 = Stoch(Commercial Net, 52)
This shows where current Commercial net positioning stands within its 1-year range.
Commercial Index 156
ComIdx156 = Stoch(Commercial Net, 156)
This shows where current Commercial net positioning stands within its 3-year range.
-----------------------------------------------------------------------------------------------
A-B Spread Formulas
The indicator can also compare Pair A and Pair B positioning directly.
A-B Non-Commercial Flip%
A-B NC Flip% = Pair A NC Flip% − Pair B NC Flip%
A-B Commercial Flip%
A-B Commercial Flip% = Pair A Commercial Flip% − Pair B Commercial Flip%
Interpretation:
Example:
If EUR NC Flip% = +20%
and USD NC Flip% = +5%
Then:
EUR − USD NC Flip% = +15%
This suggests stronger speculative positioning in EUR relative to USD.
-----------------------------------------------------------------------------------------------
Heatmap Color Logic
The table uses color gradients to make positioning extremes easy to identify.
For score-based columns such as Diff13, Diff26, Diff52, NCIdx52, NCIdx156, ComIdx52, and ComIdx156:
Default colors:
For Long% columns:
For Short% columns:
For Flip% columns:
The heatmap uses a signed scale.
Signed Heatmap Normalization
Normalized Flip Value =
(Flip% + Flip Scale) / (2 × Flip Scale)
The value is clamped between 0 and 1.
Default Flip Scale = 35%
This means:
-----------------------------------------------------------------------------------------------
How to Read the Table
Each row represents one weekly COT snapshot.
The Date column shows the COT week.
Pair A and Pair B are displayed in separate grouped sections. Each section can include Non-Commercial metrics, Commercial metrics, or both, depending on user settings.
Important interpretation guidelines:
Diff13 / Diff26 / Diff52
Shows short-term, medium-term, and 1-year positioning extremes between Non-Commercial and Commercial groups.
NCIdx52 / NCIdx156
Shows whether speculative positioning is historically stretched or depressed.
ComIdx52 / ComIdx156
Shows whether commercial hedger positioning is historically stretched or depressed.
Long%
Shows the long-side participation as a percentage of open interest.
Short%
Shows the short-side participation as a percentage of open interest.
Flip%
Shows the net directional bias after subtracting short exposure from long exposure.
A-B Flip%
Shows relative positioning pressure between the two selected markets.
-----------------------------------------------------------------------------------------------
Example Use Cases
Forex Analysis
Use Pair A and Pair B to compare currency futures positioning.
Example:
Pair A = EUR
Pair B = USD
This allows EUR/USD positioning analysis using COT data.
Commodity Analysis
Compare metals, energy, or agricultural markets.
Example:
Pair A = Gold
Pair B = Silver
This helps identify relative speculative or commercial positioning strength.
Index Analysis
Compare equity index futures.
Example:
Pair A = NASDAQ
Pair B = S&P 500
This can help identify relative risk appetite and index positioning rotation.
Macro Sentiment Analysis
Use Non-Commercial positioning to track speculative crowding and Commercial positioning to observe hedging pressure.
-----------------------------------------------------------------------------------------------
Notes
COT data is weekly and is not designed for intraday signals. This indicator is best used as a macro positioning tool, sentiment confirmation tool, or higher-timeframe market context dashboard.
The heatmap does not generate direct buy or sell signals. Instead, it provides a structured view of positioning extremes, participant behavior, and relative strength between selected COT markets.
Extreme readings can remain extreme for long periods, so COT data should be combined with price action, trend structure, volatility, liquidity, and broader market context.
-----------------------------------------------------------------------------------------------
Summary
COT Historical Heatmap [invincible3] transforms weekly Commitment of Traders data into a clean, customizable, and visually intuitive positioning dashboard. By combining Net Positioning, Long%, Short%, Flip%, COT Index, Difference Scores, and A-B relative spread analysis, it helps traders understand how Non-Commercial and Commercial participants are positioned across major futures markets.
COT Heatmap is a professional Commitment of Traders dashboard designed to visualize historical positioning pressure between two selected markets, currencies, commodities, indices, or crypto futures. The indicator converts weekly COT positioning data into an easy-to-read heatmap table, allowing traders to compare Non-Commercial and Commercial positioning strength, extremes, long/short participation, and A-B spread pressure directly on the chart.
The tool is built for macro, forex, commodities, futures, and intermarket analysis. It can automatically detect the current chart symbol or allow the user to manually select Pair A and Pair B from a predefined COT market list.
-----------------------------------------------------------------------------------------------
Main Features
- Historical COT heatmap table
- Auto symbol detection from the chart
- Manual Pair A / Pair B selection
- Futures Only or Futures + Options data mode
- Non-Commercial, Commercial, or Both participant modes
- Separate metric control for Pair A and Pair B
- Historical weekly values displayed by date
- Adjustable table size, position, start date, and number of periods
- Heatmap coloring for fast visual interpretation
- Optional A-B positioning spread columns
-----------------------------------------------------------------------------------------------
Data Source
The indicator uses weekly COT data through TradingView’s COT Library.
Available data modes:
Futures Only
Uses futures positioning data only.
Futures and Options
Uses combined futures and options positioning data.
The indicator uses Legacy COT report categories:
- Non-Commercial Positions
- Commercial Positions
- Open Interest
All COT calculations are performed on the weekly timeframe.
-----------------------------------------------------------------------------------------------
Participant Modes
The indicator supports three participant display modes:
Non-Commercial Only
Shows speculative positioning metrics.
Commercial Only
Shows hedger/commercial positioning metrics.
Both
Shows both Non-Commercial and Commercial metrics side by side.
-----------------------------------------------------------------------------------------------
Core Positioning Formulas
For each selected market:
Open Interest
OI = Total Open Interest
Non-Commercial Net Position
NC Net = NC Long − NC Short
Commercial Net Position
Commercial Net = Commercial Long − Commercial Short
Long Change
Long Change = Current Long − Previous Week Long
Short Change
Short Change = Current Short − Previous Week Short
Net Change
Net Change = Long Change − Short Change
-----------------------------------------------------------------------------------------------
Long% and Short% Formulas
The indicator normalizes long and short positions against open interest.
Long Percentage
Long% = Long Positions / Open Interest × 100
Short Percentage
Short% = Short Positions / Open Interest × 100
These values show how much of total open interest is held on the long or short side by a specific participant group.
-----------------------------------------------------------------------------------------------
Flip% Formula
Flip% measures the net long/short bias as a percentage of open interest.
Flip%
Flip% = Long% − Short%
Interpretation:
- Positive Flip% = participant group is net long
- Negative Flip% = participant group is net short
- Higher positive values show stronger bullish positioning
- Lower negative values show stronger bearish positioning
Example:
If Non-Commercial Long% = 42%
and Non-Commercial Short% = 25%
Then:
NC Flip% = 42 − 25 = +17%
This means Non-Commercial traders are net long by 17% of open interest.
-----------------------------------------------------------------------------------------------
Difference Metrics
The indicator compares Non-Commercial and Commercial net positioning.
Non-Commercial Difference
NC Difference = NC Net − Commercial Net
This measures how strongly speculative positioning differs from commercial positioning.
Commercial Difference
Commercial Difference = Commercial Net − NC Net
This is the inverse view, useful when analyzing commercial hedger pressure.
-----------------------------------------------------------------------------------------------
Diff13 / Diff26 / Diff52 Formulas
The Diff columns are stochastic-style normalized scores of the positioning difference over different historical windows.
Stochastic Positioning Score
Stoch(X, Length) =
(X − Lowest(X, Length)) / (Highest(X, Length) − Lowest(X, Length)) × 100
If the range is zero, the value returns 50.
Where:
- X = selected positioning series
- Length = 13, 26, or 52 weeks
NC Diff13*
NC Diff13 = Stoch(NC Difference, 13)
NC Diff26
NC Diff26 = Stoch(NC Difference, 26)
NC Diff52
NC Diff52 = Stoch(NC Difference, 52)
Commercial Diff13
Commercial Diff13 = Stoch(Commercial Difference, 13)
Commercial Diff26
Commercial Diff26 = Stoch(Commercial Difference, 26)
Commercial Diff52
Commercial Diff52 = Stoch(Commercial Difference, 52)
Interpretation:
- Values near 100 show positioning is near the upper extreme of the selected lookback period
- Values near 50 show neutral/mid-range positioning
- Values near 0 show positioning is near the lower extreme of the selected lookback period
-----------------------------------------------------------------------------------------------
COT Index Formulas
The COT Index measures where current net positioning stands relative to its own historical range.
COT Index
COT Index =
(Current Net Position − Lowest Net Position over N weeks) /
(Highest Net Position over N weeks − Lowest Net Position over N weeks) × 100
If the range is zero, the value returns 50.
-----------------------------------------------------------------------------------------------
Non-Commercial COT Index
NC Index 52
NCIdx52 = Stoch(NC Net, 52)
This shows where current Non-Commercial net positioning stands within its 1-year range.
NC Index 156
NCIdx156 = Stoch(NC Net, 156)
This shows where current Non-Commercial net positioning stands within its 3-year range.
-----------------------------------------------------------------------------------------------
Commercial COT Index
Commercial Index 52
ComIdx52 = Stoch(Commercial Net, 52)
This shows where current Commercial net positioning stands within its 1-year range.
Commercial Index 156
ComIdx156 = Stoch(Commercial Net, 156)
This shows where current Commercial net positioning stands within its 3-year range.
-----------------------------------------------------------------------------------------------
A-B Spread Formulas
The indicator can also compare Pair A and Pair B positioning directly.
A-B Non-Commercial Flip%
A-B NC Flip% = Pair A NC Flip% − Pair B NC Flip%
A-B Commercial Flip%
A-B Commercial Flip% = Pair A Commercial Flip% − Pair B Commercial Flip%
Interpretation:
- Positive A-B Flip% means Pair A has stronger positioning than Pair B
- Negative A-B Flip% means Pair B has stronger positioning than Pair A
- Useful for forex pair analysis, relative commodity analysis, and intermarket comparison
Example:
If EUR NC Flip% = +20%
and USD NC Flip% = +5%
Then:
EUR − USD NC Flip% = +15%
This suggests stronger speculative positioning in EUR relative to USD.
-----------------------------------------------------------------------------------------------
Heatmap Color Logic
The table uses color gradients to make positioning extremes easy to identify.
For score-based columns such as Diff13, Diff26, Diff52, NCIdx52, NCIdx156, ComIdx52, and ComIdx156:
- High values move toward the positive color
- Mid-range values move toward the neutral color
- Low values move toward the negative color
Default colors:
- Positive: Blue
- Neutral: Pink
- Negative: Red
For Long% columns:
- Higher Long% is treated as stronger
- Lower Long% is treated as weaker
For Short% columns:
- Higher Short% is treated as weaker
- Lower Short% is treated as stronger
For Flip% columns:
The heatmap uses a signed scale.
Signed Heatmap Normalization
Normalized Flip Value =
(Flip% + Flip Scale) / (2 × Flip Scale)
The value is clamped between 0 and 1.
Default Flip Scale = 35%
This means:
- +35% or above = strong positive color
- 0% = neutral color
- −35% or below = strong negative color
-----------------------------------------------------------------------------------------------
How to Read the Table
Each row represents one weekly COT snapshot.
The Date column shows the COT week.
Pair A and Pair B are displayed in separate grouped sections. Each section can include Non-Commercial metrics, Commercial metrics, or both, depending on user settings.
Important interpretation guidelines:
Diff13 / Diff26 / Diff52
Shows short-term, medium-term, and 1-year positioning extremes between Non-Commercial and Commercial groups.
NCIdx52 / NCIdx156
Shows whether speculative positioning is historically stretched or depressed.
ComIdx52 / ComIdx156
Shows whether commercial hedger positioning is historically stretched or depressed.
Long%
Shows the long-side participation as a percentage of open interest.
Short%
Shows the short-side participation as a percentage of open interest.
Flip%
Shows the net directional bias after subtracting short exposure from long exposure.
A-B Flip%
Shows relative positioning pressure between the two selected markets.
-----------------------------------------------------------------------------------------------
Example Use Cases
Forex Analysis
Use Pair A and Pair B to compare currency futures positioning.
Example:
Pair A = EUR
Pair B = USD
This allows EUR/USD positioning analysis using COT data.
Commodity Analysis
Compare metals, energy, or agricultural markets.
Example:
Pair A = Gold
Pair B = Silver
This helps identify relative speculative or commercial positioning strength.
Index Analysis
Compare equity index futures.
Example:
Pair A = NASDAQ
Pair B = S&P 500
This can help identify relative risk appetite and index positioning rotation.
Macro Sentiment Analysis
Use Non-Commercial positioning to track speculative crowding and Commercial positioning to observe hedging pressure.
-----------------------------------------------------------------------------------------------
Notes
COT data is weekly and is not designed for intraday signals. This indicator is best used as a macro positioning tool, sentiment confirmation tool, or higher-timeframe market context dashboard.
The heatmap does not generate direct buy or sell signals. Instead, it provides a structured view of positioning extremes, participant behavior, and relative strength between selected COT markets.
Extreme readings can remain extreme for long periods, so COT data should be combined with price action, trend structure, volatility, liquidity, and broader market context.
-----------------------------------------------------------------------------------------------
Summary
COT Historical Heatmap [invincible3] transforms weekly Commitment of Traders data into a clean, customizable, and visually intuitive positioning dashboard. By combining Net Positioning, Long%, Short%, Flip%, COT Index, Difference Scores, and A-B relative spread analysis, it helps traders understand how Non-Commercial and Commercial participants are positioned across major futures markets.
ملاحظات الأخبار
The COT Heatmap is updated with a cleaner, more professional layout. Compact metric labels are added, Non-Commercial Net positioning is placed first, and the Pair A, Pair B, and relative sections are clearly separated. Bias columns with detailed tooltips are included, the color palette is strengthened, and all table backgrounds are fully opaque, preventing chart candles and markers from showing through.ملاحظات الأخبار
Updated the commercial bias logicsنص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.