Posts

Showing posts with the label backtesting

Pine Script Learning Roadmap: From First Indicator to Advanced Strategy Backtesting

Image
Learning Pine Script efficiently requires a structured progression — jumping directly into complex strategies without mastering the execution model and type system leads to subtle bugs that are difficult to diagnose. This roadmap organizes the learning path into five discrete stages, each building on verified language mechanics, so every concept introduced is grounded in the official Pine Script v6 Reference Manual. 🗺️ Overview: The Five-Stage Learning Path graph TD S1["Stage 1 Language Foundations & Execution Model"] --> S2["Stage 2 Type System & Built-in Series"] S2 --> S3["Stage 3 TA Functions & Plotting"] S3 --> S4["Stage 4 Arrays, UDTs & Drawing Objects"] S4 --> S5["Stage 5 Strategy Backtesting & request.security()"] style S1 fill:#4a90d9,color:#fff,stroke:#2c6fad style S2 fill:#5ba85a,color:#fff,stroke:#3d7a3c style S3 fill:#e8a838,col...

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() ...