Posts

Showing posts with the label indicator()

Pine Script v6: indicator() vs strategy() — Core Functional Differences Explained

Image
In Pine Script v6, every script must declare its type using either indicator() or strategy() as its first executable statement. Understanding the precise functional boundary between these two declarations is essential for building reliable tools — one is designed purely for visual analysis, while the other drives a full backtesting and order-execution engine. 1. Architectural Overview At the compiler level, indicator() and strategy() are mutually exclusive script-type declarations. They share the same bar-by-bar execution model but expose entirely different namespaces and capabilities. The table below summarizes the top-level differences: Feature indicator() strategy() Primary Purpose Visual overlays & signal drawing Backtesting & order simulation Order Functions ❌ Not available ✅ strategy.entry() , strategy.exit() , strategy.close() ...