Skip to content
ChartDeck ChartScript docs Account Open the terminal

CS3120

error Plots, inputs, drawings and alerts cannot be used inside a request expression.

#What it means

The expression of a request runs on the requested bars, not on the chart. Plots, inputs, drawings and alerts belong to the chart, so they cannot appear inside it.

#Typical cause

  • An input.* call written inside the request.
  • A drawing or plot created inside a function that is called inside a request.

#How to fix it

Create the input (or plot, or drawing) at the top level, and only use its value inside the request.

#Example

ChartScriptError: CS3120
//@chartscript 1
indicator("Daily average", { overlay: true })
plot(request.tf("1D", ta.sma(close, input.int(20, "Length"))))

Fixed

ChartScriptOpen in editor
//@chartscript 1
indicator("Daily average", { overlay: true })
const len = input.int(20, "Length")
plot(request.tf("1D", ta.sma(close, len)))
  • CS3121 — A request cannot sit inside another request’s expression.
  • CS3007 — name can only be used at the top level of the script, not inside a condition, loop or function.

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