Appearance
The guide
Which page answers your question? Each page below takes one thing a script author asks, answers it first, and gives a script you can paste. Read them in order to learn the language, or go straight to the page your question names.
pine
//@version=6
indicator("Where each line is explained", overlay = true)
int len = input.int(20, "Length", minval = 1) // Inputs
var int crosses = 0 // var and varip
float avg = ta.sma(close, len) // Functions
bool up = ta.crossover(close, avg) // Operators
if up // Control flow
crosses += 1
plot(avg, "Average", color.orange) // Plots and colours
float d = request.security(syminfo.tickerid, "W",
close[1], lookahead = barmerge.lookahead_on) // Other symbols
plot(d, "Last week's close", color.gray)The example is Pine Script. Its last request reads last week's close from each week's first bar with lookahead_on, which AmenoScript refuses: Other symbols has what to write there instead.
Running scripts
- How a script runs: once a bar, and again on each update of the forming bar.
- var and varip: keep a value from one bar, or one update, to the next.
Language
- Script structure: lines, blocks, wrapping, comments and
//@version. - Types, qualifiers and na: what a value can be, what na is, and why a bool is never na.
- Variables: declaring, reassigning, scope and shadowing.
- Operators: compares within 1e-10, division by zero, and
x[k]. - Control flow:
if,switch, the loops, and blocks that give a value. - Functions and methods: writing your own, and calling them as methods.
- State in functions and branches: why
ta.smain a function or anifreads differently. - Types and enums: your own types, objects, copies and enums.
- Collections: arrays, matrices and maps, and when two names share one.
- Strings and formatting: turning numbers into text, and how na and infinity print.
Inputs and data
- Inputs: every input kind, and how a saved setting finds its input.
- Time and sessions: bar times, sessions, time zones and holidays.
- Other symbols and timeframes: another symbol or timeframe, without looking ahead.
Output
- Plots and colours: plots, fills, background and bar colours.
- Drawings and tables: labels, lines, boxes, polylines and tables, and their limits.
- Alerts:
alert()andalertcondition().
Strategies
- Strategies: orders, exits, sizing, costs and the Strategy Tester's report.
Working with scripts
- Libraries: share code between scripts.
- Errors and debugging: why a run stopped, and how to see what it's doing.
- Performance: what makes a script fast or slow here.
- Pine compatibility: where a TradingView script reads differently.
See also
- Get started
- AmenoScript: what the terminal adds to Pine
- Reference