Posts

Showing posts with the label history reference operator

Pine Script Series Data Type Explained: How Time-Series Storage Works Bar-by-Bar

Image
In Pine Script, every value you work with — whether a price, a calculated indicator, or a boolean flag — is stored not as a single scalar, but as a continuous, ordered stream of values indexed by bar position. This architectural choice is what makes Pine Script fundamentally different from general-purpose languages, and understanding the series data type is the key to writing correct, efficient, and predictable indicators and strategies. ⚠️ Educational Disclaimer: All code examples in this article are for educational purposes only. Always test scripts on historical, non-live data before deploying them in any real environment. 1. What Is a Series? A series in Pine Script is a sequence of values, one per historical bar, stored in a contiguous buffer. Think of it as an implicit array where index 0 always refers to the current bar , index 1 refers to the previous bar , and so on. The built-in history-reference operator [] is the prima...