Skip to content
ChartDeck ChartScript docs Account Open the terminal

CS4101

error A link is declared once, at the top level, as a const: const h = link.script("@handle/Name@latest"). detail

#What it means

A link to another script is a declaration, not a call the script makes while it runs. link.script and input.script are written once, at the top level, as a const of their own, with a constant path. The name you give the link (its handle) is then used only to read what the other script shares. The end of the message says what is wrong with this one.

#Typical cause

  • The link is inside an if, a loop or a function.
  • It is declared with let or state, or written inside a larger expression.
  • The path is worked out while the script runs, or is not written "@handle/Name@8" or "@handle/Name@latest".
  • The handle itself is used as a value: stored in a variable or an array, or passed into a function. Passing a handle into a function is not available in this release.

#How to fix it

Declare the link at the top level, const h = link.script("@handle/Name@8"), and read its shares with a dot: h.trend, h.levels.pivots, h.events.pivot, h.ready. A function may read a handle declared above it directly. See Linking scripts.

#Example

ChartScriptError: CS4101
//@chartscript 1
indicator("Trend filter")
if (close > open) {
    const piv = link.script("@user/Pivot Levels@1")
}
plot(close)

Fixed

ChartScriptOpen in editor
//@chartscript 1
const piv = link.script("@user/Pivot Levels@1")
indicator("Trend filter")
plot(close > open ? piv.trend : na, "Trend on up bars")
  • CS4110 — Cannot link path: reason.
  • CS4104 — script does not share what called 'id'. It shares list.hint
  • CS4112 — share.series("id") detail.

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