Posts

Showing posts with the label programming basics

Pine Script v6 Data Types Explained: bool, float, and int — When and How to Use Each

Image
Understanding the three fundamental scalar data types in Pine Script v6 — bool , float , and int — is essential for writing correct, predictable indicators and strategies. Each type has distinct memory representation, arithmetic rules, and v6-specific constraints that differ meaningfully from prior versions. 1. Overview of the Three Types Pine Script v6 is a statically-typed language with type inference . Every variable has a resolved type at compile time. The three primitive numeric/logical types are: Type Value Domain Can Hold na ? Typical Use Case bool true or false only ❌ No (v6 breaking change) Conditions, flags, signal gates int 64-bit signed integer or na ✅ Yes Bar counts, indices, loop counters float 64-bit IEEE 754 double or na ✅ Yes Prices, ratios, indicator values ...