Import the library before calling rma2
The complete Pine v6 example below pins TradingView/ta/9 and names it tvta. Library version 9 migrated to Pine v6; the number in the import path identifies the library release, not the Pine language version. If existing code calls ta.rma2, inspect its import declaration before changing the function name. A script can use ta as a library alias, which makes an imported call look like a built-in.
- If no import exists, ta.rma2 is not a built-in call. Add the intended library import or use ta.rma with a compatible length.
- If an import exists, match the call prefix to its alias and use a release that exports rma2.
- The 10/28 switch demonstrates a series argument. It is not a trading rule or a claim of better signals.
//@version=6
import TradingView/ta/9 as tvta
indicator("RMA with a series length", overlay = true)
int fixedLength = input.int(14, "Fixed length", minval = 1)
float changingLength = close >= open ? 10.0 : 28.0
float fixedRma = ta.rma(close, fixedLength)
float changingRma = tvta.rma2(close, changingLength)
plot(fixedRma, "Built-in RMA", color.blue)
plot(changingRma, "Library RMA with changing length", color.orange)