Skip to content
ChartDeck ChartScript docs Account Open the terminal

CS2012

error This returns got values but expected names are given.

#What it means

A function returns several values (a tuple) and the [a, b, ...] on the left does not have the same number of names.

#Typical cause

  • Too few or too many names when unpacking, for example two names for ta.macd, which returns three values.

#How to fix it

Give one name per returned value. Use _ for a value you do not need. See Functions.

#Example

ChartScriptError: CS2012
//@chartscript 1
indicator("MACD")
const [macdLine, signalLine] = ta.macd(close, 12, 26, 9)
plot(macdLine)
plot(signalLine)

Fixed

ChartScriptOpen in editor
//@chartscript 1
indicator("MACD")
const [macdLine, signalLine, _] = ta.macd(close, 12, 26, 9)
plot(macdLine)
plot(signalLine)
  • CS2013 — This call returns no value.

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