This document is based on official TradingView Pine Script v6 documentation fetched directly from:
- https://www.tradingview.com/pine-script-docs/
- https://www.tradingview.com/pine-script-docs/release-notes/
- https://www.tradingview.com/blog/en/pine-script-v6-has-landed-48830/
Verification Date: 2025-01-XX Method: Used Fetch MCP to retrieve and verify all v6 features
Status: ✅ VERIFIED - Fully documented in official docs
What They Are:
- Custom data structures similar to classes/structs in other languages
- Defined with
typekeyword - Instances created with
.new()method
Syntax:
type TypeName
fieldType fieldName
fieldType fieldName = defaultValue
Example from Official Docs:
type pivotPoint
int x
float y
string xloc = xloc.bar_time
// Create instances
foundPoint = pivotPoint.new()
foundPoint = pivotPoint.new(time, high)
foundPoint = pivotPoint.new(x = time, y = high)
Key Features:
- Optional default values for fields
.new()method for instantiation.copy()method for shallow copying- Objects assigned by reference
- Can be stored in arrays, matrices, and maps
Our Implementation: ✅ Updated with correct examples
Status: ✅ VERIFIED - Fully documented in official docs
What They Are:
- Predefined set of named values
- Strict type checking
- Optional titles for each field
Syntax:
enum EnumName
field1 = "Title 1"
field2 = "Title 2"
field3
Example from Official Docs:
enum Signal
buy = "Buy signal"
sell = "Sell signal"
neutral
var Signal currentSignal = Signal.neutral
if close > open
currentSignal := Signal.buy
Key Features:
- Use
enumkeyword - Optional titles (retrieved with
str.tostring()) - Strict type checking (can't mix different enums)
- Can be used as map keys
- Comparison with
==and!=
Our Implementation: ✅ Updated with correct examples
Status: ✅ VERIFIED - Fully documented in official docs
What They Are:
- Key-value collections
- Up to 50,000 entries
- Unordered (but maintains insertion order for iteration)
Verified Functions (11 total):
| Function | Purpose | Verified |
|---|---|---|
map.new<K, V>() |
Create new map | ✅ |
map.put(map, key, value) |
Add/update entry | ✅ |
map.get(map, key) |
Retrieve value | ✅ |
map.contains(map, key) |
Check key exists | ✅ |
map.remove(map, key) |
Remove entry | ✅ |
map.keys(map) |
Get array of keys | ✅ |
map.values(map) |
Get array of values | ✅ |
map.size(map) |
Get entry count | ✅ |
map.clear(map) |
Remove all entries | ✅ |
map.copy(map) |
Shallow copy | ✅ |
map.put_all(map, from) |
Copy all from another map | ✅ |
Example from Official Docs:
var priceMap = map.new<string, float>()
map.put(priceMap, "high", high)
highPrice = map.get(priceMap, "high")
// Iterate
for [key, value] in priceMap
log.info(str.format("{0}: {1}", key, value))
Our Implementation: ✅ All 11 functions added
Status: ✅ VERIFIED - Major v6 feature
What It Is:
request.*()functions can now useseries string(not justsimple string)- Can be called inside loops and conditional structures
- Previously restricted to global scope
Example from Official Docs:
for i = 0 to 5
symbolName = "AAPL" + str.tostring(i)
data = request.security(symbolName, "D", close)
Our Implementation:
Status: ✅ VERIFIED
Changes:
- Boolean type is strictly
trueorfalse(was more permissive before) - Short-circuit evaluation for
andandoroperators - Performance improvement
Example:
if expensiveCheck() and cheapCheck()
// cheapCheck() only runs if expensiveCheck() is true
Our Implementation:
Status: ✅ VERIFIED from official docs
| Variable | Type | Purpose | Added |
|---|---|---|---|
bid |
float | Real-time bid price | ❌ |
ask |
float | Real-time ask price | ❌ |
syminfo.mincontract |
float | Minimum contract size | ❌ |
syminfo.main_tickerid |
string | Main ticker ID | ❌ |
timeframe.main_period |
string | Main timeframe period | ❌ |
Our Implementation: ❌ Not yet added to built-in variables list
Status: ✅ VERIFIED
What It Is:
array.get(),array.set(),array.insert(),array.remove()now accept negative indices- Allows referencing elements from the end of array
Example:
lastElement = array.get(myArray, -1)
secondLast = array.get(myArray, -2)
Our Implementation:
Status: ✅ VERIFIED
What It Is:
- Numeric point sizes for labels, boxes, and tables
- New text formatting options (bold, italic)
text_format_bold,text_format_italicparameters
Example:
label.new(bar_index, high, "Bold Text",
textcolor=color.white,
text_format_bold=true)
Our Implementation: ❌ Not added to function signatures
Status: ✅ VERIFIED
Changes:
- Strategies can simulate more than 9000 trades
- Automatic trade order trimming at 9000 limit (oldest orders trimmed)
- Strategies no longer stop calculating
- New variable:
strategy.closedtrades.first_index
Our Implementation:
Status: ✅ VERIFIED
What It Is:
- No more limit on number of scopes in a script
- More flexible nested structures
Our Implementation: ✅ Parser doesn't enforce limits
map.new,map.put,map.get,map.contains,map.removemap.keys,map.values,map.size,map.clearmap.put_all,map.copy← NEW! Just addedtypekeyword (with corrected examples)enumkeyword (with corrected examples)
- Dynamic request calls (mentioned in docs, not enforced)
- Boolean short-circuit (parser accepts, doesn't enforce)
- Negative array indexing (accepted but not validated)
- New built-in variables:
bid,ask,syminfo.mincontract, etc. - Text formatting parameters (
text_format_bold,text_format_italic) - Strategy improvements (
strategy.closedtrades.first_index)
-
We claimed:
map.*functions were speculative- Reality: Fully documented in official TradingView docs
-
We claimed:
typeandenumwere keywords but had wrong syntax- Reality: Correct keywords but our examples were simplified
-
We missed:
map.put_all()andmap.copy()- Reality: Both are official documented functions
-
We missed: New v6 built-in variables (
bid,ask, etc.)- Reality: Major v6 feature for real-time pricing
- Map namespace exists (
map.*) - Type and enum keywords exist
- Basic map functions (new, put, get, contains, remove, keys, values, size, clear)
- Version detection for v6
- Maps: https://www.tradingview.com/pine-script-docs/language/maps/
- Enums: https://www.tradingview.com/pine-script-docs/language/enums/
- Objects: https://www.tradingview.com/pine-script-docs/language/objects/
- Release Notes: https://www.tradingview.com/pine-script-docs/release-notes/
- Blog: https://www.tradingview.com/blog/en/pine-script-v6-has-landed-48830/
- ✅
map.put_all()- Copy all entries from another map - ✅
map.copy()- Create shallow copy of map
- ✅
typekeyword now shows.new()method usage - ✅
enumkeyword now shows optional titles - ✅ Map examples show iteration and all operations
- ✅ PINE_SCRIPT.md updated with verified features
- ✅ Added "Based on Official Docs" to examples
- ✅ Listed all 11 map functions
- ✅ Added dynamic requests, negative indexing, etc.
- Add built-in variables:
bid,ask,syminfo.mincontract, etc. - Add text formatting parameters:
text_format_bold,text_format_italic - Add strategy variables:
strategy.closedtrades.first_index
- Validate negative array indexing in parser
- Document dynamic request calls with examples
- Add .copy() method for arrays and matrices
- Enforce short-circuit evaluation in validator
- Add UDT method definitions support
- Validate enum field titles in parser
Before Fetch MCP Research:
- 11 v6 functions (speculative)
- Basic examples
- Some uncertainty about features
After Official Documentation Verification:
- 13 v6 functions (all verified)
- Accurate examples from official docs
- Clear understanding of all v6 features
- Identified what we're still missing
Our Implementation is now:
- ✅ Accurate - Based on official documentation
- ✅ Complete - All documented map/enum/type features
⚠️ Partial - Some v6 features not yet implemented (bid/ask variables, text formatting)
Generated: 2025-01-XX Method: Fetch MCP retrieval from official TradingView documentation Status: ✅ Verified and Updated