Compilation error

Fix “Could not find function or function reference”

Replace the unknown call with a function that exists in the namespace and Pine version you declared. `ta.average()` is not a Pine Script v6 built-in, while `ta.sma()` accepts a source and length for this calculation. Check spelling, the `ta.` namespace, argument types, imported library names, and the Reference Manual before choosing a replacement. Similar names do not prove that two functions have the same behavior.

This link opens the Pine Script AI Coding Agent overview. It does not run or change code on this page.

Before and after

Make the smallest reviewable change

Both artifacts include the version declaration and the code needed to inspect the stated problem. The diff lists the lines that change between them.

Broken code.pine
//@version=6
indicator("Function lookup demo")
float average = ta.average(close, 14)
plot(average)
Fixed code.pine
//@version=6
indicator("Function lookup demo")
float average = ta.sma(close, 14)
plot(average)
Diff.pine
--- broken.pine
+++ fixed.pine
@@
-float average = ta.average(close, 14)
+float average = ta.sma(close, 14)

Root causes

  • The function name does not exist in the declared Pine version.
  • A built-in is missing its namespace, such as `ta.`, `math.`, or `request.`.
  • A library was not imported, its alias changed, or the function is not exported.
  • The intended replacement has a different signature or calculation.

How the fix was verified

Method
Pineify UAT grammar checker via check-pine-script-grammar.mjs
Broken result
Returned a missing-function diagnostic at line 3, column 17.
Fixed result
Returned no grammar diagnostics.
Limit
The replacement is correct for a simple moving average. A similarly named function may not preserve another script’s intent.

Bring the actual script, not just the message

Open the Coding Agent overview to paste editable Pine Script, explain the intended behavior, and request a review. Compile and test the result in TradingView before using it.

Paste your code to fix this error