Pine Script Tutorial for Beginners: Build Your First TradingView Indicator

Want to learn Pine Script but don't know where to start? This tutorial walks you through building your first TradingView indicator — from "Hello World" to a working signal system. Plus, see how professional Pine Script looks with StrongBuy Pro's source code.

Learn Pine Script Faster — Study professional-grade code
StrongBuy Pro includes full commented Pine Script source
£999 £1,999 — Best Pine Script learning resource

What Is Pine Script?

Pine Script is TradingView's programming language. It lets you create custom indicators, strategies, and alerts. The best part? It runs entirely in your browser — no downloads needed.

Lesson 1: Your First Indicator

Open TradingView, click "Pine Editor" at the bottom, and paste this:

//@version=5
indicator("My First Indicator", overlay=true)
plot(close, color=color.blue)

Click "Add to Chart." You just plotted the closing price as a blue line. Congratulations — you've written your first Pine Script!

Lesson 2: Moving Average

//@version=5
indicator("Simple MA", overlay=true)
ma = ta.sma(close, 20)
plot(ma, color=color.red, linewidth=2)

This plots a 20-period simple moving average. ta.sma() is the function, close is the price data, and 20 is the length.

Lesson 3: Buy/Sell Signals

//@version=5
indicator("MA Crossover", overlay=true)
fastMA = ta.sma(close, 10)
slowMA = ta.sma(close, 30)
buySignal = ta.crossover(fastMA, slowMA)
sellSignal = ta.crossunder(fastMA, slowMA)
plotshape(buySignal, "Buy", shape.triangleup, location.belowbar, color.green)
plotshape(sellSignal, "Sell", shape.triangledown, location.abovebar, color.red)

This creates green triangles when the fast MA crosses above the slow MA (buy), and red triangles when it crosses below (sell).

Lesson 4: Study Professional Code

The fastest way to learn Pine Script is reading professional code. StrongBuy Pro includes the complete source code with detailed comments explaining every section:

"I learned more about Pine Script from reading StrongBuy Pro's code than from 6 months of YouTube tutorials. The comments explain everything." — Sarah K., New York

Common Pine Script Functions

FunctionWhat It Does
ta.sma()Simple Moving Average
ta.ema()Exponential Moving Average
ta.rsi()Relative Strength Index
ta.macd()MACD indicator
ta.crossover()Detects when line A crosses above B
ta.highest()Highest value over N bars

Get StrongBuy Pro to Accelerate Your Learning

Instead of spending months learning from scattered tutorials, get StrongBuy Pro and learn from battle-tested, professional-grade Pine Script code:

Get StrongBuy Pro + Source Code — £999 →