Trying To Convert a Pinescript Function From V4 to V5 But Stumped

437 Views Asked by At

I am trying to convert what seems like a simple function in V4 to V5 but getting nowhere. The docs seem relatively vague. Any ideas?

V4

bcwsma(s,l,m) => 
_s = s
_l = l
_m = m
_bcwsma = (_m*_s+(_l-_m)*nz(_bcwsma[1]))/_l
_bcwsma

V5

bcwsma(s,l,m) => 
_s = s
_l = l
_m = m
_bcwsma = (_m*_s+(_l-_m)*nz(_bcwsma[1]))/_l
_bcwsma

The readback in v5 is the infamous undeclared identifier error.

line 14: Undeclared identifier '_bcwsma'
1

There are 1 best solutions below

0
peterparker69 On

Try this:

 bcwsma(s, l, m) =>
_bcwsma = float(na)
_s = s
_l = l
_m = m
_bcwsma := (_m * _s + (_l - _m) * nz(_bcwsma[1])) / _l
_bcwsma