Skip to content
ChartDeck ChartScript docs Account Open the terminal

CS3005

error max_bars_back must be between min and max.

#What it means

max_bars_back sets how many past bars a series keeps for history (x[n]). It must be a whole number between the two limits in the message: 1 and 10,000. The same limit applies to a constant history offset.

#Typical cause

  • max_bars_back set above 10,000, below 1 or to a fraction.
  • A constant offset larger than 10,000, as in close[20000].

#How to fix it

Use a value from 1 to 10,000. If you need statistics over a very long window, keep a running sum or an array instead of reading far back. See Limits.

#Example

ChartScriptError: CS3005
//@chartscript 1
indicator("Long look-back", { max_bars_back: 20000 })
plot(close - close[5000])

Fixed

ChartScriptOpen in editor
//@chartscript 1
indicator("Long look-back", { max_bars_back: 6000 })
plot(close - close[5000])
  • CS5202 — name[...] reached offset bars back; raise max_bars_back to suggest in indicator().
  • CS2302 — A history offset must be a whole number of 0 or more.

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