TradingView TERMINAL
DOC AUTOMATION Updated May 2026 · ~5 min · For TradingView desktop 3.2.1

Automation

Pine Script v6 Basics: Write Your First TradingView Indicator in 15 Minutes

Pine Script beginner illustration

Pine Script is TradingView's purpose-built language; the v6 engine compiles fast and the community has 150k+ public scripts. No programming background needed — every line below is explained.

Open the editor and paste

//@version=6
indicator("Dual EMA", overlay = true)

fast = ta.ema(close, 9)
slow = ta.ema(close, 21)

plot(fast, color = color.purple)
plot(slow, color = color.gray)

up = ta.crossover(fast, slow)
plotshape(up, style = shape.triangleup,
          location = location.belowbar, color = color.green)

Line by line

  • //@version=6: declares v6 syntax — don't omit it;
  • indicator(..., overlay=true): an indicator (not a strategy), drawn on the main chart;
  • ta.ema(close, 9): a 9-period EMA of close;
  • ta.crossover(fast, slow): true on the bar where fast crosses above slow; plotshape draws a green triangle below.

Click Add to chart to see the EMAs and cross markers; errors show a line number, usually a typo or indentation — Pine is indentation-sensitive. Save it and it joins your library, usable on any device.

Next: turn 9/21 into adjustable input.int() parameters; to test whether crosses make money, swap indicator for strategy — see reading the backtest report. On desktop, tear the editor onto a side screen.