Search code examples
pine-scriptpine-script-v5

Pinescript 2 to Pinescript 5


Is anyone familiar with Pinescript 5.I mean,I can't figure out why this work in Pinescript 2 and not in Pinescript 5

buying = l3_0 > threshold ? true : l3_0 < -threshold ? false : buying[1]

Error : Undeclared identifier 'buying'


Solution

  • It is because Self-referenced variables are removed in v3.

    You need to declare the variable first.

    buying = false
    buying := l3_0 > threshold ? true : l3_0 < -threshold ? false : buying[1]