--> pinefixer: Series vs Simple vs Const in Pine Script, Explained Simply
blog

Series vs Simple vs Const in Pine Script, Explained Simply

Series vs simple vs const in Pine Script

If you've ever hit an error like "cannot use series where simple is expected," you've run into Pine Script's type qualifier system. It's one of the more confusing parts of the language for people coming from other programming backgrounds, so here's a plain-English breakdown.

It's Not About the Data Type — It's About When the Value Is Known

Most languages care about *what kind* of value something is (a number, a string, a boolean). Pine Script adds a second dimension on top of that: *when* the value is determined. This is the qualifier, and it exists because Pine scripts run bar-by-bar, and some function parameters need to be locked in before the script starts running, while others are free to change on every bar.

The Four Qualifiers, Loosest to Strictest

  • const — known at compile time, before the script even runs. A literal like 14 or "close" typed directly into your code.
  • input — set by the user through an input widget, fixed for the entire run of the script (can't change bar-to-bar).
  • simple — determined once when the script starts running and never changes afterward, even though it wasn't a literal or an input.
  • series — can change on every single bar. Most price data (close, calculated indicator values, etc.) falls into this category.

Why This Matters in Practice

Some built-in functions require a parameter to be simple or stricter — commonly, the length/period argument in certain functions. If you try to pass a series value (something that changes bar-to-bar) into a slot that demands simple, you'll get a type-qualifier error, even if the value looks like a perfectly normal number.

len = close > open ? 10 : 20  // this is a SERIES int — it can change every bar
ta.sma(close, len)            // may error if this parameter requires 'simple'

The fix is almost always to use an input.int() value directly for these parameters instead of a calculated variable:

len = input.int(14, "Length")  // this is 'input' — fixed for the whole run
ta.sma(close, len)             // works fine

A Useful Mental Model

Think of it as a ladder: const is the most restrictive (least flexible, most predictable), and series is the most permissive (most flexible, changes freely). A value from a stricter tier can always be used where a looser tier is expected, but not the other way around — you can't pass something that changes every bar into a slot that needs a value fixed at the start.

Hit a qualifier error you can't parse?

Paste the exact error text into the free Pine Script Error Explainer for a plain-English explanation and fix.

Open the Error Explainer →