Skip to main content
Besides its type, every value has a qualifier that says when it is known. It matters when a function demands a value that cannot change from bar to bar and you give it one that can.

The four qualifiers

From weakest to strongest: A value fits a parameter whose qualifier is the same as its own or stronger: a const fits every parameter, a series only a series one, and an input value does not fit a const parameter. An expression takes the strongest qualifier of its parts: 10 * 2 is const, input.int(5) * 2 is input, close * 2 is series. math.floor(x) keeps the qualifier of x.

Where each is required

  • const: every argument of indicator() and strategy(); the title of plot, plotshape, bgcolor, hline, alertcondition and the other output calls; the default, title, group and tooltip of every input.*.
  • input: plot(linewidth=...), hline(price, ...).
  • series: nearly everything else, so close can go to talib.sma, label.new and your own functions, and a moving-average length may change from bar to bar.
The compiler says: Cannot call plot with argument title=str.tostring(close). An argument of series string type was used but a const string is expected. The same message, with the other qualifier names, covers every mismatch; the editor’s check raises it. A parameter of your own function may start with const, simple or series (none means series; see Your own functions). A variable declaration takes no such word: const int x = 5 is a syntax error.

A const that becomes series

A variable reassigned inside a for or switch becomes series for the rest of the script, even if every value assigned is a constant; inside an if it takes the qualifier of the condition: under if true it stays const, under an input.bool it is input, under close > open it is series. So int width = 1, then if close > open { width := 3 }, then plot(close, linewidth=width) fails: Cannot call plot with argument linewidth=width. An argument of series int type was used but a input int is expected. c ? a : b takes the strongest of c, a and b (true ? 1 : 2 is const; close > open ? 1 : 2 is series and fails the same way). Use a literal or an input.int width, or draw one plot per case with na on the bars where it does not apply: plot(close > open ? close : na, linewidth=3).