Appearance
Pine or AmenoScript
Should you write Pine Script or AmenoScript? Write Pine Script v6 when the script must also run on TradingView. Write AmenoScript when you need something Pine doesn't have. You don't declare which one a text is: the engine reads it from what the text uses.
ameno
indicator("Last three closes, in ATRs from the mean")
mean = ta.sma(close, 20)
atr = ta.atr(14)
dist = array.from(close, close[1], close[2]).map(x => (x - mean) / atr) // a lambda: AmenoScript only
plot(dist.avg(), "Distance")Write the distances out without .map and its lambda, put //@version=6 on the first line, and the text is Pine Script.
Two dialects
| Pine Script v6 | AmenoScript | |
|---|---|---|
| Runs on TradingView | Yes | No |
| First line | //@version=6 | No version line |
| AmenoScript's own functions and syntax | Not used | Used |
A read that can see past its bar, such as lookahead_on | Runs, with a warning | Refused |
| An indicator on the bar still forming | Runs on it as it updates | Waits for the bar to close |
An AmenoScript text runs leak-safe: no value it reads comes from a bar that hadn't closed, so its backtest can't look ahead and its plots don't change after the bar closes, which is what repaint means. To hold to that, it refuses what could see past a bar: lookahead_on, varip, calc_on_every_tick and a few more. A Pine text that does the same runs as TradingView would run it, with a warning at each read that sees past its bar.
How the engine tells them apart
A text is Pine Script until it uses something TradingView's compiler doesn't accept. That covers AmenoScript's own features, such as a lambda, request.universe or book.target. It also covers syntax TradingView refuses, which the engine runs anyway: x == na, a second declaration of a name in one block, a literal / 0, a plot() inside an if, an untyped x = na, a ternary over several lines, a line starting with an operator, recursion, and the rest of the list.
From the first such use, the editor names the script with .ameno in place of .pine and its tag reads AmenoScript. A //@version line then shows a notice, Line 1 states a Pine version, with a button that removes it. The script still runs. AmenoScript has the rule in full.
One use changes the whole script
A text that becomes AmenoScript becomes leak-safe everywhere, not only on the line that did it, and nothing asks you first. A Pine script written for TradingView that gains if close == na changes in four ways:
- It no longer compiles on TradingView.
- A
request.securitywithlookahead_onstops the run with an error at the request, not at the line that made the change. - Its plots wait for each bar to close: the bar still forming draws nothing, and
barstate.islastandlast_bar_indexread the last closed bar. varip,calc_on_every_tickand the other leak-safe refusals stop it.
Write na(x), declare a name once, and keep plots at the top level, and the text stays Pine.
Hold a script to TradingView: strict Pine
The editor's menu has a check separate from the dialect the engine detects. AmenoScript, the default, runs any text, Pine or AmenoScript, and detects which it is. Pine v6 strict, which this site calls strict Pine, refuses everything TradingView's compiler would refuse, each at its place in the text:
text
Pine v6 strict (line 3): direct comparison with `na` (e.g. `x == na`) — TV requires `na(x)` functionSo a page that says strict Pine refuses something also means this: under the default check the text runs, and becomes AmenoScript. Turn strict Pine on while you write a script for TradingView, and you find each such use before TradingView does. Every Pine example on this site passes strict Pine.
See also
- AmenoScript: what it adds, feature by feature.
- Leak-safe AmenoScript: every refusal and what to write instead.
- Pine compatibility: where our engine and TradingView read differently.
- Your first script: the editor and the chart.