Quoc Doan
Quoc Doan

Reputation: 3

Pinescript - Convert Wells Wilders MA v2 to v4

I have a function to calculate Well Wilders MA for v2.

It's used for calculate DMI Stochastic Extreme

wwma(l,p) =>
wwma = (nz(wwma[1]) * (l - 1) + p) / l

I'm going to convert it to v4

And I got error: Undeclared identifier 'wwma'.

Pinescript v4 doesn't allow recursive function.

Do you have any suggestion

Upvotes: 0

Views: 315

Answers (1)

alexgrover
alexgrover

Reputation: 1043

When using recursion in the v4, you first need to declare your wwma variable. In your case this would lead to:

wwma = 0. 
wwma := (nz(wwma[1]) * (l - 1) + p) / l

Here you declare wwma as a decimal by assigning 0. as value.

Upvotes: 1

Related Questions