Skip to content
ChartDeck ChartScript docs Account Open the terminal

CS5202

error name[...] reached offset bars back; raise max_bars_back to suggest in indicator().

#What it means

The script looked further back in a series than it keeps. When an offset changes from bar to bar, a series keeps max_bars_back bars (500 unless you set it). The message gives the offset that was reached and a setting that would be enough.

#Typical cause

  • A changing offset that grows beyond the window, for example "bars since an event".

#How to fix it

Raise max_bars_back in indicator() to the suggested value (at most 10,000), or limit the offset. See Limits.

#Example

ChartScriptOpen in editor
//@chartscript 1
indicator("Far back", { max_bars_back: 100 })
const price: float = close
const back = bar_index > 200 ? 200 : 0
plot(price[back])

Fixed

ChartScriptOpen in editor
//@chartscript 1
indicator("Far back", { max_bars_back: 250 })
const price: float = close
const back = bar_index > 200 ? 200 : 0
plot(price[back])
  • CS3005 — max_bars_back must be between min and max.
  • CS5201 — A history offset cannot be negative or na (got offset).
  • CS2102 — The length changes from bar to bar, so name keeps max_bars_back (n) values.

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