TradingCharts

Undeclared Identifier

The compiler saw a name it does not recognise.

Common causes

1. Typo

rsi = ta.rsi(close, 14)
plot(xRsi)       // ⚠ typo

Rename or alias the reference.

2. Variable used before declaration

plot(rsi)                    // ⚠ not declared yet
rsi = ta.rsi(close, 14)

Move the declaration above its first use. ChartScript is single-pass — forward references to top-level identifiers are not allowed.

3. Namespaced function missing the prefix

m = sma(close, 20)   // v1-v4 alias — still works
m = sma(close, 20)   // but a UDT or variable named `sma` shadows it

If a local variable happens to share the name of a bare-alias built-in, the compiler will try to use the local. Rename the local or call the built-in through its namespace (ta.sma).

4. Reaching into a library whose import is missing

plot(sig.smooth(close, 5))   // ⚠ 'sig' is undeclared
// forgot the `import` line

Add:

import 1000000072/Signal/1 as sig

5. Enum member mistyped

enum Trend
    up
    down
    flat

plot(0, color = Trend.flst)      // ⚠ 'flst' is not a Trend member