Cannot call 'ta.sma' with argument 'length'='series int'. The argument 'length' of 'ta.sma' should be of type 'simple int'.You passed a series int where ta.sma expects a simple int length that cannot change bar to bar. Educational only — this reference explains Pine's type qualifiers; no profitability is implied.
Pine values carry a type qualifier: const, input, simple, or series (weakest to strongest). Many ta.* length parameters require simple int — a value fixed for the whole dataset — because the function allocates its internal buffer once. Feeding a length derived from a bar-varying value (bar_index, close, a var counter, or a request.security() result) yields a series int, which is a stronger qualifier than the parameter accepts, so the call is rejected.
Make the length simple. Use a literal (ta.sma(close, 14)) or an input (input.int(...)) — inputs qualify as simple. If the length must vary at runtime, you cannot pass it to ta.sma; instead pick from a set of precomputed fixed-length calls (a switch over several simple lengths), or use a function such as ta.sma implemented over a bounded loop with a constant cap. Never coerce a series into the length slot.
//@version=6
indicator("Series length", overlay = true)
// bar_index is a series int, so this length is 'series int' -> rejected.
dynLen = bar_index % 50 + 1
plot(ta.sma(close, dynLen))✓ Validated clean by our own engine
//@version=6
indicator("Simple length", overlay = true)
// input.int() qualifies as 'simple int', which ta.sma accepts.
len = input.int(20, "Length", minval = 1, maxval = 200)
plot(ta.sma(close, len), "SMA", color = color.orange)
// If you must switch length at runtime, precompute fixed-length calls
// (each with a simple/const length) and select between the results.
fast = ta.sma(close, 10)
slow = ta.sma(close, 50)
chosen = close > open ? fast : slow
plot(chosen, "Selected SMA", color = color.purple)Educational, code-correctness reference only — not financial advice. Trading involves substantial risk of loss.