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.
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.
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!
//@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.
//@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).
The fastest way to learn Pine Script is reading professional code. StrongBuy Pro includes the complete source code with detailed comments explaining every section:
| Function | What 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 |
Instead of spending months learning from scattered tutorials, get StrongBuy Pro and learn from battle-tested, professional-grade Pine Script code: