I am wondering if i'm able to only load tickers under certain circumstances in pinescript so the whole script doesnt just break because one ticker doesnt exist anymore. I know this was not possible in v4 but is it possible in v5?
I have tried some basic if statements to no avail
You can use the ignore_invalid_symbol
parameter of the security()
.
ignore_invalid_symbol (input bool) Determines the behavior of the function if the specified symbol is not found: if false, the script will halt and throw a runtime error; if true, the function will return
na
and execution will continue. Optional. The default is false.
//@version=5
indicator("My script", overlay=true)
close_1 = request.security("BINANCE:ETHUSDT", "", close)
close_2 = request.security("ABC:DEF", "", close, ignore_invalid_symbol = true)
plot(close_1, color=color.green)
plot(close_2, color=color.red)