Limits
How far back a script can look
A script can look back at most 500 bars. Asking for a bar outside that range is an error, and the error names the function that asked for it.
The range is checked while the script runs, not when it is checked for errors. A script that reaches too far back therefore validates cleanly and then fails during evaluation.
This reaches past the limit:
plot(close[600])This stays inside it:
indicator("Prior close")
plot(close[1])In practice the limit is generous
If you are working over a moving window of recent bars, you are unlikely to meet this limit at all.
Design for it anyway when you write something that walks back a variable number of bars, because the failure arrives at run time rather than at validation.
How limits are enforced
Resource limits are enforced by the interpreter rather than offered as guidance. Exceeding one produces a diagnostic. It does not produce a truncated result or a partial answer that looks like a real one.
What this page does not tell you
The 500-bar lookback is the only limit this page names. No other limit is documented here, and none is asserted. If the interpreter enforces a limit this page does not name, you will meet it as a diagnostic rather than as a wrong number on a chart.