Skip to main content
ATK Pine Script®

array, barstate, log, and State Helpers

Utility namespaces for array manipulation, bar state inspection, logging, alerts, and script-level state variables.

array, barstate, log, and State Helpers#

array.*#

Practical subset includes: new, new_float, new_int, new_bool, new_string, get, set, push, pop, shift, unshift, insert, remove, slice, join, from_, concat, copy, includes, indexof, lastindexof, size, and clear.

barstate#

Runtime snapshot with fields like isfirst, islast, isconfirmed, ishistory, and isrealtime. Useful for object lifecycle management and last-bar updates.

State helpers#

HelperPurpose
na()Returns a NA sentinel value.
nz()Replaces NA with a fallback value.
var(name, default)Declares a persistent script-level variable.
varip(name, default)Declares a persistent intrabar variable.
set_var(name, value, intrabar=False)Updates a persistent variable.

log.*#

Use log.info, log.warning, and log.error to record module-scoped diagnostics into runtime context. Messages preserve module name, line, and function information.

Alerts#

FunctionPurpose
alert(message, freq="once_per_bar_close")Fire a runtime alert with a message.
alertcondition(condition, title="", message="", key=None, **kwargs)Register a named alert condition into module context for runtime handling.