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| Parameter | Type | Description |
|---|---|---|
path | const string | The script as "@handle/Name@8" (one version) or "@handle/Name@latest" (the newest version that still shares what this script reads). A constant text. |
inputs | const Tdefault na | Settings for the linked script as { name: value }: constants or this script's own inputs. Left out, it runs with its defaults. |
at | const stringdefault link.live | link.live (default) or link.confirmed. |
Returns T.
Example
const nx = link.script("@handle/Levels@latest")
plot(nx.ready ? nx.trend : na, "Linked trend")Since ChartScript 1
#Constants
| Name | Type | Description |
|---|---|---|
link.confirmed | string | On 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.live | string | Read the linked script's working values, the same as it shows (the default). On the live bar they can still change. |