plot() inside if — “Cannot use ‘plot’ in local scope” fixed · Pine Script Bug 01 #shorts
Writing plot() inside an if block makes the Pine Editor refuse the script (the error reads “Cannot use ‘plot’ in local scope.”). The Pine Script v6 manual: plot() must always be in the script’s global scope — at the beginning of a non-indented line — and scripts cannot use plot() inside if blocks, for loops or any other local scope, because the compiler needs to know about all plots during…








