CS3201
error alert.on can only be used at the top level of the script.
#What it means
alert.on declares a named alert condition that appears in the "Create alert" dialog. The list is fixed when the script is compiled, so alert.on must be at the top level, not inside a condition, loop or function.
#Typical cause
alert.onplaced inside anifto fire only sometimes.
#How to fix it
Move it to the top level and put the condition in its first argument. To send a message from inside a condition, use alert.send. See Alerts.
#Example
//@chartscript 1
indicator("Up bar alert")
if (close > open) {
alert.on(true, "Up bar")
}
plot(close)Fixed
//@chartscript 1
indicator("Up bar alert")
alert.on(close > open, "Up bar")
plot(close)