Skip to main content
On this page

What Language Is Pine Script? Indicators, Strategies, and Execution

· 3 min read
Pineify Team
Pine Script and AI trading workflow research team

Pine Script is TradingView's domain-specific programming language for indicators, strategies, and reusable libraries. It is its own language, with a time-series execution model and APIs designed for TradingView data and charts.

What you can build​

Indicators calculate and display values, drawings, or signal conditions. Strategies add simulated orders and performance analysis through TradingView's broker emulator. Libraries expose reusable functions and types for other scripts. Alerts can notify you when configured conditions occur.

TradingView's first steps guide provides an introduction to the editor and scripts. You can start in the supported web or desktop chart interface without installing a local Pine compiler. Do not assume the same editing workflow is available on every mobile surface.

A small complete example​

This retained Pine v5 indicator calculates a 20-bar simple moving average:

//@version=5
indicator("My Moving Average")
ma = ta.sma(close, 20)
plot(ma, color=color.blue)

//@version=5 selects the language version. indicator() declares the program type. ta.sma() calculates the average and plot() displays it. Because the example does not specify overlay=true, its plot belongs in a separate pane rather than directly over the candles.

For new development, follow the current v6 documentation and its script structure guide. Older examples require version-aware migration; changing only the version comment is not a complete migration procedure.

How execution differs from a normal loop​

Pine evaluates a script across the available historical bars. Indicators can then execute repeatedly as the realtime bar changes. Strategies normally evaluate at bar close but have settings that alter recalculation. A realtime value is therefore not necessarily final.

Types such as float and bool describe values. Qualifiers such as series describe when values may change; “series” is not a separate numeric base type. History references such as close[1] read earlier bar values. The execution model explains the details.

Simulation is different from order routing​

A strategy's entries and exits simulate orders. TradingView's automation support page states that native automated strategy trading with a brokerage account is unavailable. This does not mean TradingView lacks manual broker connections.

External alert/webhook integrations are a separate execution workflow. They require symbol mapping, sizing, authentication, rejection handling, and monitoring. Backtest fills do not verify those integrations or guarantee equivalent live results.

Choose the language for the job​

Pine is useful when your task belongs inside TradingView's charts, alerts, or strategy testing. Python and other general-purpose languages offer broader choices for datasets, libraries, and infrastructure; their setup can be local or hosted. There is no measured speed comparison in this tutorial.

Pine has limits on requests, execution, memory, plots, and other resources. It also supports user-defined types and methods, so describing it as lacking all object-oriented features is misleading. Read the relevant API before assuming it supports arbitrary external database or network access.

Start with a small indicator, inspect its output on historical and realtime bars, and then add one feature at a time. The earlier AAPL/TSLA trading anecdotes and claimed beginner completion times are not evidence of what you should expect.