Skip to content
ChartDeck ChartScript docs Account Open the terminal

CS2101

error The argument param of name must be the same on every bar (needed), but this value is got.

#What it means

This argument must keep the same value on every bar (the message says which qualifier is needed, usually simple), but the value you passed can change from bar to bar (series).

#Typical cause

  • A length that depends on the bar, such as close > open ? 10 : 20, passed to a function whose length must be fixed (for example ta.rsi).
  • A request's market or timeframe computed per bar while dynamic_requests: false.

#How to fix it

Pass a constant, an input, or a value computed only from them. If the value really has to change per bar, use a function that accepts a changing length (ta.sma, ta.ema, ta.highest and a few others do). See Series and qualifiers.

#Example

ChartScriptError: CS2101
//@chartscript 1
indicator("RSI")
const len = close > open ? 10 : 20
plot(ta.rsi(close, len))

Fixed

ChartScriptOpen in editor
//@chartscript 1
indicator("RSI")
const len = input.int(14, "Length", { minval: 1 })
plot(ta.rsi(close, len))
  • CS2102 — The length changes from bar to bar, so name keeps max_bars_back (n) values.
  • CS2103 — The argument param of name must be a constant.
  • CS2104 — The argument param of name must be a constant or an input.

The ChartScript documentation is in English for now; translations will follow.