Conversion Issue Pine script Version 2 to Version 5

huangapple go评论50阅读模式
英文:

Conversion Issue Pine script Version 2 to Version 5

问题

我找到了这段 Pine Script 版本 2 的代码;在第 9 行中声明了变量 k,它在同一行引用了自己!不知道如何转换这段代码;我会非常感激任何帮助。谢谢。

//@version=2
study("Pseudo Polynomial Channel",overlay=true)
length = input(14),morph = input(0.9,minval=0,maxval=1),mult = input(1.),flatten = input(1.)
//----
x = n
y = close
m(a,b) =>
    p = morph * a + (1-morph) * b
k = nz(m(k[length],y),y) + (x-x[length])/(x[length*2]-x[length]) * (nz(m(k[length*2],y),y) - 
     nz(m(k[length],y),y))/flatten
k1 = sma(k,length)
er = cum(abs(y-k1))/n * mult
//----
a = k1 + er
b = k1 - er
//----
A = plot(a,color=#2196f3,linewidth=2,transp=0)
plot(k1,color=#e65100,linewidth=2,transp=0)
B = plot(b,color=#ff1100,linewidth=2,transp=0)
fill(A,B,#2196f3,transp=95)

请注意,这段代码是 Pine Script 版本 2 的,如果需要将其转换为其他版本,可能需要进行一些适应性的修改。

英文:

I found this pine script Version 2 code; in line 9 of the code variable k is declared it references itself on same line! don't know how to convert this code; I would really appreciate any help. Thank You.

//@version=2
study("Pseudo Polynomial Channel",overlay=true)
length = input(14),morph = input(0.9,minval=0,maxval=1),mult = input(1.),flatten = input(1.)
//----
x = n
y = close
m(a,b) =>
    p = morph * a + (1-morph) * b
k = nz(m(k[length],y),y) + (x-x[length])/(x[length*2]-x[length]) * (nz(m(k[length*2],y),y) - 
     nz(m(k[length],y),y))/flatten
k1 = sma(k,length)
er = cum(abs(y-k1))/n * mult
//----
a = k1 + er
b = k1 - er
//----
A = plot(a,color=#2196f3,linewidth=2,transp=0)
plot(k1,color=#e65100,linewidth=2,transp=0)
B = plot(b,color=#ff1100,linewidth=2,transp=0)
fill(A,B,#2196f3,transp=95)

答案1

得分: 0

只需要首先定义它,然后使用 := 运算符赋予新值。

k = 0.0
k := nz(m(k[length],y),y) + (x-x[length])/(x[length*2]-x[length]) * (nz(m(k[length*2],y),y) - nz(m(k[length],y),y))/flatten
英文:

You just need to define it first then assign the new value with the := operator.

k = 0.0
k := nz(m(k[length],y),y) + (x-x[length])/(x[length*2]-x[length]) * (nz(m(k[length*2],y),y) - 
     nz(m(k[length],y),y))/flatten

huangapple
  • 本文由 发表于 2023年5月21日 00:47:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/76296324.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定