Skip to content
ChartDeck ChartScript docs Account Open the terminal

CS4112

error share.series("id") detail.

#What it means

share.series declares one shared value per bar, like a plot. The list of shared series is fixed when the script is compiled, so each one is written once, at the top level, not inside a condition, loop or function.

#Typical cause

  • share.series inside an if, to share only on some bars.
  • Two share.series lines with the same id.

#How to fix it

Move it to the top level and put the condition in the value: share na on the bars that have nothing. For something that happens now and then, use share.event. See Linking scripts.

#Example

ChartScriptError: CS4112
//@chartscript 1
indicator("Shares")
if (close > open) {
    share.series("up_close", close)
}
plot(close)

Fixed

ChartScriptOpen in editor
//@chartscript 1
indicator("Shares")
share.series("up_close", close > open ? close : na)
plot(close)
  • CS4111 — The share id 'id' is already used for kind; one id has one kind.
  • CS4114 — A script can share at most max what.
  • CS3201 — alert.on can only be used at the top level of the script.

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