How to apply a Pine Script to the chart
Updated
Zeal Terminal runs Pine Script in your browser, so you can try an indicator or write your own without installing anything or signing in. This guide takes a script from the editor to the chart: open the Pine editor, put a script in it, fix anything the compiler flags, and add it to the chart. It works for every Pine version, //@version=1 to //@version=6.
Steps
- Pine editor. Open the Pine editor. If you have closed it, bring it back from the windows icon in the rail.
- Code editor. Click in the editor and write or paste your script. This one draws a 20-bar simple moving average over the price.
- Add to chart. Click Add to chart. The script is compiled and drawn on the chart.
- Script settings. Your script now has a row in the chart legend. Use its settings to change inputs and colours, the eye to hide it, or the cross to remove it.
What the Add to chart button checks
Before anything is drawn, the script is compiled. If it does not compile, the button is greyed out and the editor shows the message directly under the line that failed, with a red squiggle under the token. Fix the line and the button comes back; there is no separate "check" step.
Common mistakes
- Missing version line. A script with no
//@version=comment is read as Pine v1, as on TradingView. Put//@version=6on the first line unless you mean an old script. - Mixing versions.
ta.smais v5 and v6 syntax; in v4 the same function issma. If a name is "undeclared", check the version line first. - Drawing in the wrong place. An indicator that is on the price scale needs
overlay=truein itsindicator()call; without it the plot goes to its own pane below the chart. - Expecting a strategy report from an indicator. The strategy tester only fills in for scripts that start with
strategy(rather thanindicator(.
Frequently asked questions
Do I need an account? No. The editor, the chart and the tester work signed out. An account is only needed to save scripts and layouts.
Is anything uploaded when I add a script? No. Scripts are compiled and run in your own browser tab.
Can I use a script from TradingView? Paste it into the editor. Pine v1 to v6 is supported; if a built-in is not yet available the compiler names it.
Related guides
This guide is replayed by an automated test on every release, so the steps here match the app as it is today.