Skip to content
ChartDeck ChartScript docs Account Open the terminal

link

Reading the values another script shares. link.script declares the other script once, at the top of the script.

#Functions

#link.scriptfunction

Links another script and gives a handle to what it shares: h.<id> is a shared series (with history), h.levels.<id> the levels active on this bar (array<level>, sorted by price), h.events.<id> the events delivered on this bar (array<link.event>), h.ready whether it has data for this bar and h.status "ok", "loading", "no access", "plan", "error" or "stale". Write it at the top level as a const; it may come before indicator(). Every value is point in time: on a bar you see what the other script knew on that bar.

link.script(path: const string, { inputs?: const T = na, at?: const string = link.live }): T
ParameterTypeDescription
pathconst stringThe script as "@handle/Name@8" (one version) or "@handle/Name@latest" (the newest version that still shares what this script reads). A constant text.
inputsconst Tdefault naSettings for the linked script as { name: value }: constants or this script's own inputs. Left out, it runs with its defaults.
atconst stringdefault link.livelink.live (default) or link.confirmed.

Returns T.

Example

ChartScriptFragmentOpen in editor
const nx = link.script("@handle/Levels@latest")
plot(nx.ready ? nx.trend : na, "Linked trend")

Since ChartScript 1

#Constants

NameTypeDescription
link.confirmedstringOn the live bar, read the linked script's values of the last closed bar (never repaints); on closed bars the same as link.live.
link.livestringRead the linked script's working values, the same as it shows (the default). On the live bar they can still change.

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