Skip to content

runtime ​

How do you stop a script when its settings make no sense? Call runtime.error with a message. The run stops there, and the chart shows only the error, as TradingView does.

pine
//@version=6
indicator("Two lengths")
int fast = input.int(10, "Fast length")
int slow = input.int(30, "Slow length")
if fast >= slow
    runtime.error("Fast length has to be below Slow length")
plot(ta.sma(close, fast) - ta.sma(close, slow))

runtime.error ​

pine
runtime.error(message) → void

Stops the run with message as its error.

The run shows nothing but the error: no plots, no drawings and no report, on every engine. AmenoScript also has input.check(condition, message), which stops the run on the first bar unless its condition holds. See input.check.

ParameterDescription
message
series string
The error's text.

AmenoScript is compatible with Pine Script v6. Pine Script is a trademark of TradingView, Inc., which has no part in AmenoScript.