Skip to content
ChartDeck ChartScript docs Account Open the terminal

CS2102

hint The length changes from bar to bar, so name keeps max_bars_back (n) values.

#What it means

This is a hint, not an error. The length you passed changes from bar to bar. The function supports that, but it has to keep a window as long as max_bars_back (the number in the message) because it cannot know the longest length in advance.

#Typical cause

  • A length computed per bar passed to one of the functions that accept it, such as ta.sma, ta.ema, ta.highest or ta.lowest.

#How to fix it

Nothing is required. If the length is really fixed, pass a constant or an input to drop the hint. If you know the longest length, setting max_bars_back in indicator() close to it saves memory. See Series and qualifiers.

#Example

ChartScriptWarning: CS2102
//@chartscript 1
indicator("Adaptive average", { overlay: true })
const len = close > open ? 10 : 20
plot(ta.sma(close, len))

Fixed

ChartScriptOpen in editor
//@chartscript 1
indicator("Adaptive average", { overlay: true })
const len = input.int(20, "Length", { minval: 1 })
plot(ta.sma(close, len))
  • CS2101 — The argument param of name must be the same on every bar (needed), but this value is got.
  • CS5202 — name[...] reached offset bars back; raise max_bars_back to suggest in indicator().

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