Pine Script Resources

Pine Script Learning Resources

A curated collection of the best Pine Script resources, documentation, tutorials, and tools to accelerate your trading automation journey.

Where can I find Pine Script strategy examples and reference?

Your language reference is TradingView's own Pine Script v6 User Manual, and it is free. For worked examples, three places pay off, and the largest of them is the least reliable. The manual is authoritative, the public script library is the biggest collection of real code, and the PineCoders community writes the conventions the other two mostly ignore.

TradingView gives a script two minutes to compile, and after three consecutive warnings it enforces a one-hour ban on compilation attempts.

TradingView Pine Script v6 User Manual, Limitations. Source checked 28 October 2026.

Pine Script Documentation Hub

Access comprehensive documentation for all Pine Script versions with version comparison and migration guides.

Pine Script v6 Documentation
Recommended
1/14/2024
Latest version with enhanced features and improved performance

Key Features

Enhanced Type System
Improved Performance
New Built-in Functions
Better Error Messages
Advanced Debugging Tools
Offline (37.0 MB)
Version Comparison
Pick a version to read its features and migration notes
V6
Latest
5 features
Released 2024
V5
5 features
Released 2021
V4
4 features
Released 2019
V3
3 features
Released 2018
Which features each version documents, from each version's own list.
FeatureV6V5V4V3
Enhanced Type System✓———
Improved Performance✓———
New Built-in Functions✓———
Better Error Messages✓———
Advanced Debugging Tools✓———
Objects and Methods—✓——
Libraries Support—✓——
Enhanced Arrays—✓——
Improved Maps—✓——
Type System Improvements—✓——
Core Pine Script Features——✓—
Basic Type System——✓—
Essential Built-ins——✓—
Standard Library——✓—
Basic Pine Script———✓
Simple Indicators———✓
Core Functions———✓

Interactive Reference Manual

All 935 entries of TradingView's Pine Script v6 reference, searchable here. Open any row to land on that entry in the official reference.

Search & filter
935 entries, v6

Bookmarks stay in this browser, under pss.pine.reference.bookmarks.

935 entries

operator
built-in
expr1 - expr2

Subtraction or unary minus. Applicable to numerical expressions.

Open in the official reference
operator
built-in
expr1 -= expr2

Subtraction assignment. Applicable to numerical expressions.

Open in the official reference
operator
built-in
<var_name> := <new_value>

Reassignment operator. It is used to assign a new value to a previously declared variable.

Open in the official reference
operator
built-in
expr1 != expr2

Inequality operator. Returns true if the operands are considered not equal, and false otherwise. This operator is compatible with all value types, including "int", "float", "bool", "color", and "string". The operator can also compare two line or label IDs.

Open in the official reference
operator
built-in
expr1 ? expr2 : expr3

Ternary conditional operator.

Open in the official reference
operator
built-in
expr1[expr2]

Series subscript. Provides access to previous values of series expr1. expr2 is the number of bars back, and must be numerical. Floats will be rounded down.

Open in the official reference
operator
built-in
expr1 * expr2

Multiplication. Applicable to numerical expressions.

Open in the official reference
operator
built-in
expr1 *= expr2

Multiplication assignment. Applicable to numerical expressions.

Open in the official reference
operator
built-in
expr1 / expr2

Division. Applicable to numerical expressions.

Open in the official reference
operator
built-in
expr1 /= expr2

Division assignment. Applicable to numerical expressions.

Open in the official reference
operator
built-in
expr1 % expr2

Modulo (integer remainder). Applicable to numerical expressions.

Open in the official reference
operator
built-in
expr1 %= expr2

Modulo assignment. Applicable to numerical expressions.

Open in the official reference
operator
built-in
expr1 + expr2

Addition or unary plus. Applicable to numerical expressions or strings.

Open in the official reference
operator
built-in
expr1 += expr2

Addition assignment. Applicable to numerical expressions or strings.

Open in the official reference
operator
built-in
expr1 < expr2

Less than. Applicable to numerical expressions.

Open in the official reference
operator
built-in
expr1 <= expr2

Less than or equal to. Applicable to numerical expressions.

Open in the official reference
operator
built-in
<var_name> := <initial_value>

Assignment operator. Assigns an initial value or reference to a declared variable. It means this is a new variable, and it starts with this value.

Open in the official reference
operator
built-in
expr1 == expr2

Equality operator. Returns true if the operands are considered equal, and false otherwise. This operator is compatible with all value types, including "int", "float", "bool", "color", and "string". The operator can also compare two line or label IDs.

Open in the official reference
operator
built-in
<identifier>([<parameter_name>[=<default_value>]], ...) => <local_block> <function_result>

The '=>' operator is used in user-defined function declarations and in switch statements.

Open in the official reference
operator
built-in
expr1 > expr2

Greater than. Applicable to numerical expressions.

Open in the official reference
operator
built-in
expr1 >= expr2

Greater than or equal to. Applicable to numerical expressions.

Open in the official reference
variable
adjustment

Constant for dividends adjustment type (dividends adjustment is applied).

Open in the official reference
variable
adjustment

Constant for none adjustment type (no adjustment is applied).

Open in the official reference
variable
adjustment

Constant for splits adjustment type (splits adjustment is applied).

Open in the official reference
function
built-in
alert(message, freq) → void

Creates an alert trigger for an indicator or strategy, with a specified frequency, when called on the latest realtime bar. To activate alerts for a script containing calls to this function, open the "Create Alert" dialog box, then select the script name and "Any alert() function…

Open in the official reference
variable
alert

A named constant for use with the freq parameter of the alert() function.

Open in the official reference

A named constant for use with the freq parameter of the alert() function.

Open in the official reference

A named constant for use with the freq parameter of the alert() function.

Open in the official reference
function
built-in
alertcondition(condition, title, message) → void

Creates alert condition, that is available in Create Alert dialog. Please note, that alertcondition() does NOT create an alert, it just gives you more options in Create Alert dialog. Also, alertcondition() effect is invisible on chart.

Open in the official reference
keyword
built-in
expr1 and expr2

Logical AND. Applicable to boolean expressions.

Open in the official reference
type
built-in

Keyword used to explicitly declare the "array" type of a variable or a parameter. Array objects (or IDs) can be created with the array.new<type>(), array.from() function.

Open in the official reference
function
array
array.abs(id) → array<float>

Returns an array containing the absolute value of each element in the original array.

Open in the official reference
function
array
array.avg(id) → series float

The function returns the mean of an array's elements.

Open in the official reference
function
array
array.binary_search(id, val) → series int

Performs a binary search through a sorted array to locate an element corresponding to a target value. The function returns an element's index if the value from that element equals the target value. Otherwise, it returns -1.

Open in the official reference
array.binary_search_leftmost(id, val) → series int

Performs a binary search through a sorted array to locate an element corresponding to a target value. If the function locates the target value in the array's elements or referenced object fields, it returns the index of the first element whose retrieved value equals that value.

Open in the official reference
array.binary_search_rightmost(id, val) → series int

Performs a binary search through a sorted array to locate an element corresponding to a target value. If the function locates the target value in the array's elements or referenced object fields, it returns the index of the last element whose retrieved value equals that value.

Open in the official reference
function
array
array.clear(id) → void

The function removes all elements from an array.

Open in the official reference
function
array
array.concat(id1, id2) → array<type>

The function is used to merge two arrays. It pushes all elements from the second array to the first array, and returns the first array.

Open in the official reference
function
array
array.copy(id) → array<type>

The function creates a copy of an existing array.

Open in the official reference
function
array
array.covariance(id1, id2, biased) → series float

The function returns the covariance of two arrays.

Open in the official reference
function
array
array.every(id) → series bool

Returns true if all elements of the id array are true, false otherwise.

Open in the official reference
function
array
array.fill(id, value, index_from, index_to) → void

The function sets elements of an array to a single value. If no index is specified, all elements are set. If only a start index (default 0) is supplied, the elements starting at that index are set.

Open in the official reference
function
array
array.first(id) → series <type>

Returns the array's first element. Throws a runtime error if the array is empty.

Open in the official reference
function
array
array.from(arg0, arg1, ...) → array<type>

The function takes a variable number of arguments with one of the types: int, float, bool, string, label, line, color, box, table, linefill, and returns an array of the corresponding type.

Open in the official reference
function
array
array.get(id, index) → series <type>

The function returns the value of the element at the specified index.

Open in the official reference
function
array
array.includes(id, value) → series bool

The function returns true if the value was found in an array, false otherwise.

Open in the official reference
function
array
array.indexof(id, value) → series int

The function returns the index of the first occurrence of the value, or -1 if the value is not found.

Open in the official reference
function
array
array.insert(id, index, value) → void

The function changes the contents of an array by adding new elements in place.

Open in the official reference
function
array
array.join(id, separator) → series string

The function creates and returns a new string by concatenating all the elements of an array, separated by the specified separator string.

Open in the official reference
function
array
array.last(id) → series <type>

Returns the array's last element. Throws a runtime error if the array is empty.

Open in the official reference
function
array
array.lastindexof(id, value) → series int

The function returns the index of the last occurrence of the value, or -1 if the value is not found.

Open in the official reference
function
array
array.max(id, nth) → series float

The function returns the greatest value, or the nth greatest value in a given array.

Open in the official reference
function
array
array.median(id) → series float

The function returns the median of an array's elements.

Open in the official reference
function
array
array.min(id, nth) → series float

The function returns the smallest value, or the nth smallest value in a given array.

Open in the official reference
function
array
array.mode(id) → series float

The function returns the mode of an array's elements. If there are several values with the same frequency, it returns the smallest value.

Open in the official reference
function
array
array.new_bool(size, initial_value) → array<bool>

The function creates a new array object of bool type elements.

Open in the official reference
function
array
array.new_box(size, initial_value) → array<box>

The function creates a new array object of box type elements.

Open in the official reference
function
array
array.new_color(size, initial_value) → array<color>

The function creates a new array object of color type elements.

Open in the official reference
function
array
array.new_float(size, initial_value) → array<float>

The function creates a new array object of float type elements.

Open in the official reference
function
array
array.new_int(size, initial_value) → array<int>

The function creates a new array object of int type elements.

Open in the official reference

Offline Downloads

TradingView's Pine Script manual, mirrored into a file you can read with no connection: every page, every figure, searchable. Fetched 29 October 2026, free, no account needed.

Pine Script v6 manual, offline
HTML
v6
37.0 MB
The whole v6 User Manual in one file: searchable, with every figure, readable with no connection and no server.
Manual fetched 29 October 2026
78 pages, 827 figures
Download HTML (37.0 MB)
Pine Script v6 manual, print edition
PDF
v6
21.1 MB
The same pages of text and code, set for print. The figures are left out to keep the file light; the HTML edition has every one.
Manual fetched 29 October 2026
78 pages, 827 figures
Download PDF (21.1 MB)
Pine Script v5 manual, offline
HTML
v5
16.2 MB
The v5 User Manual for legacy projects, in one searchable file with every figure, readable with no connection.
Manual fetched 29 October 2026
60 pages, 518 figures
Download HTML (16.2 MB)
Pine Script v5 manual, print edition
PDF
v5
12.8 MB
The same v5 pages of text and code, set for print, without the figures.
Manual fetched 29 October 2026
60 pages, 518 figures
Download PDF (12.8 MB)
Pine Script v4 manual, offline
HTML
v4
5.1 MB
The v4 User Manual, kept for scripts that still run on it, searchable and complete with its figures.
Manual fetched 29 October 2026
42 pages, 194 figures
Download HTML (5.1 MB)
Pine Script v4 manual, print edition
PDF
v4
2.5 MB
The same v4 pages of text and code, set for print, without the figures.
Manual fetched 29 October 2026
42 pages, 194 figures
Download PDF (2.5 MB)
About this mirror
Every page is searchable offline, and the bundle opens in any browser with no server and no internet.
Fetched page by page, dated on each card, so you can see how current the copy is.
Written by TradingView, content © TradingView, Inc. This site mirrors it for offline reading and is not affiliated with or endorsed by TradingView.