TradingView Download Center

Indicators & Strategy

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

Pine Script beginner tutorial illustration with code and a purple glow curve

Pine Script is TradingView's purpose-built language for trading; the v6 engine compiles fast, and the community already has 150k+ public scripts. You don't need a programming background — every line below is explained; copy it and it runs.

Open the editor

Open the Pine Editor from the bottom panel, create a blank indicator, and replace the default with:

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

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

plot(fast, color = color.purple, title = "EMA 9")
plot(slow, color = color.gray,   title = "EMA 21")

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

Line by line

Run and save

  1. Click Add to chart — the two EMAs and cross markers appear immediately;
  2. Errors show a line number, usually a typo or indentation — Pine is indentation-sensitive;
  3. Save and name it; the script joins your indicator library, usable on any device you sign in on.

Next

Turning 9/21 into adjustable input.int() parameters is the natural second lesson; to test whether EMA crosses actually make money, swap indicator for strategy — see the backtesting guide.

Tip: on desktop you can tear the Pine Editor into its own window on a second screen — code on the left, result on the right, far comfier than a top/bottom split.