You're staring at the Pine Script editor. Line 37 has a red squiggle. The error panel says "undeclared identifier." Your indicator won't compile.
An undeclared identifier error in Pine Script means the compiler encountered a name it doesn't recognize -- a variable you never declared, a function you misspelled, or something you referenced outside its reachable scope. Every identifier must be declared before use, spelled correctly, and accessible from the line that references it.
I hit this error three times last week building a multi-timeframe screener for BTCUSD on the 15-minute chart. Each one had a different root cause: a typo on barssince instead of ta.barssince(), a variable trapped inside an if block, and a security() call written for Pine Script v3 that v5 flat-out rejected.
Here's the good news: this error is precise. Pine Script tells you exactly which name it cannot find and on which line. Three causes cover almost every case.
The 3 Causes of Undeclared Identifier Errors
1. Using a Variable Before Declaring It
You reference mySmaValue in a plot() call, but mySmaValue was never declared. Pine Script doesn't guess what you meant. It just tells you the name is unknown.
This is the most common cause. You wrote the plot line first, planned to fill the calculation later, and forgot. Or you declared the variable further down in the file where the compiler hadn't reached it yet. Pine Script compiles top to bottom -- the declaration must come before the first usage. If the concept of variable declaration is new, the beginners guide to Pine Script covers the absolute basics first.
2. Scope Boundaries
Variables declared inside a block -- an if statement, a for loop, a function -- live only inside that block. Reference them one line outside and Pine Script treats them as undeclared.
This trips me up constantly. Last November I was building an AAPL volatility tracker. I declared float atrValue = na at the top of the script. Inside an if block I wrote atrValue = ta.atr(14) using = instead of :=. Pine Script treated that as a brand new local variable, and the outer atrValue stayed na for every bar.
3. Version Mismatches
Pine Script v5 restructured how built-in functions and variables are named. study() became indicator(). security() became request.security(). sma() became ta.sma(). Color values went from bare red to color.red.
Copy-paste a 2019 forum post into a v5 editor and you'll get undeclared identifier errors on nearly every line. I've done this more times than I want to count. The code looks right because it worked in v3, but v5 simply doesn't ship those old function names.