Glossary · Automation
Pine Script
Last updated:
Pine Script is TradingView’s own programming language for writing custom indicators, strategy backtests and alert conditions that run directly on TradingView charts. It is purpose-built and deliberately small: a few dozen lines can express an indicator that would take far more in a general-purpose language, because the platform supplies the data series, plotting and bar-by-bar execution model for you.
Pine has two main program types. An indicator computes and draws values (a custom moving average, a signal marker). A strategy additionally simulates entries and exits, producing TradingView’s built-in backtest report. Either can raise alerts — and an alert wired to a TradingView webhook is how Pine logic reaches a real broker, since Pine itself cannot place orders at Indian brokers.
Example
A minimal strategy: go long NIFTY when the 9 EMA crosses above the 21 EMA.
//@version=6
strategy("EMA Cross", overlay = true)
fast = ta.ema(close, 9)
slow = ta.ema(close, 21)
if ta.crossover(fast, slow)
strategy.entry("Long", strategy.long)
Applied to a NIFTY futures chart, the built-in tester shows hypothetical trades and P&L in points; converting to rupees means multiplying by the lot size of 75 and subtracting realistic Indian costs — which TradingView’s defaults do not know about.
Why it matters
Pine Script lowered the barrier to systematic trading for a generation of Indian retail traders: strategy logic becomes explicit, shareable and testable. Its limits matter equally — backtests use TradingView’s data and simplified fill assumptions, costs like STT need manual configuration, and execution still requires an external bridge.
In INDfolio AI, Pine-based signals arrive via webhook for execution — or you can skip code entirely with the no-code strategy builder.