Stuck migrating Pinescript v2 to v4

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

Stuck migrating Pinescript v2 to v4

问题

以下是您要翻译的部分:

Noob learning here!

after a couple of days trying to convert a pinescript V2 to V4 from a extended script..
I cannot make a clean migration for the next part of the while script.

When save and it’s compiling, The recursive error messages don’t stop and been reading many instructions there, but it’s persistent

What do you think?
Could anyone kingly help on this merge? Grateful enormously!!!

The errors are:

Undeclared identifier 'x';
Undeclared identifier 'x';
Undeclared identifier 'swap';
Undeclared identifier 'swap';
Undeclared identifier 'lime';
Undeclared identifier 'red';
Undeclared identifier 'lime';
Undeclared identifier 'red';
Undeclared identifier 'swap3';
Undeclared identifier 'swap2';
Undeclared identifier 'swap4';
Undeclared identifier 'lime';
Undeclared identifier 'red';
Undeclared identifier 'swap4';
Undeclared identifier 'red';
Undeclared identifier 'lime';
Undeclared identifier 'MA_s';

The source code is:

CCI = input(20, "Tend Magic:: Input for CCI")
CCI = input(20)
ATR = input(5, "Tend Magic:: Input for ATRc")
ATR = input(5)
Multiplier= input(1, "Tend Magic :: ATR Multiplier")
Multiplier=input(1,title='ATR Multiplier')
original=input(true,title='original coloring')
original= true
thisCCI = cci(close, CCI)
thisCCI = cci(close, CCI)
lastCCI = nz(thisCCI1)
lastCCI = nz(thisCCI1)
bufferDn= high + Multiplier * sma(tr,ATR)
bufferDn= high + Multiplier * sma(tr,ATR)
bufferUp= low - Multiplier * sma(tr,ATR)
bufferUp= low - Multiplier * sma(tr,ATR)
if (thisCCI >= 0 and lastCCI < 0)
if (thisCCI >= 0 and lastCCI < 0)
bufferUp := bufferDn1
bufferUp := bufferDn1
if (thisCCI <= 0 and lastCCI > 0)
if (thisCCI <= 0 and lastCCI > 0)
bufferDn := bufferUp1
bufferDn := bufferUp1
if (thisCCI >= 0)
if (thisCCI >= 0)
if (bufferUp < bufferUp1)
if (bufferUp < bufferUp1)
bufferUp := bufferUp1
bufferUp := bufferUp1
else
else
if (thisCCI <= 0)
if (thisCCI <= 0)
if (bufferDn > bufferDn1)
if (bufferDn > bufferDn1)
bufferDn := bufferDn1
bufferDn := bufferDn1
x=thisCCI >= 0 ?bufferUp:thisCCI <= 0 ?bufferDn:x1
x=thisCCI >= 0 ?bufferUp:thisCCI <= 0 ?bufferDn:x1
swap=x>x1?1:x<x1?-1:swap1
swap=x>x1?1:x<x1?-1:swap1
swap2=swap==1?lime:red
swap2=swap==1?lime:red
swap3=thisCCI >=0 ?lime:red
swap3=thisCCI >=0 ?lime:red
swap4=original?swap3:swap2
swap4=original?swap3:swap2
plot(x,color=swap4,transp=0,linewidth=3)
bullTrendMagic = swap4 == lime and swap41 == red
bearTrendMagic = swap4 == red and swap41 == lime

我已为您翻译了代码中的文字部分,不包括代码本身。希望这对您有所帮助。

英文:

Noob learning here!

after a couple of days trying to convert a pinescript V2 to V4 from a extended script..
I cannot make a clean migration for the next part of the while script.

When save and it’s compiling, The recursive error messages don’t stop and been reading many instructions there, but it’s persistent

What do you think?
Could anyone kingly help on this merge? Grateful enormously!!!

The errors are:

Undeclared identifier &#39;x&#39;;
Undeclared identifier &#39;x&#39;;
Undeclared identifier &#39;swap&#39;;
Undeclared identifier &#39;swap&#39;;
Undeclared identifier &#39;lime&#39;;
Undeclared identifier &#39;red&#39;;
Undeclared identifier &#39;lime&#39;;
Undeclared identifier &#39;red&#39;;
Undeclared identifier &#39;swap3&#39;;
Undeclared identifier &#39;swap2&#39;;
Undeclared identifier &#39;swap4&#39;;
Undeclared identifier &#39;lime&#39;;
Undeclared identifier &#39;red&#39;;
Undeclared identifier &#39;swap4&#39;;
Undeclared identifier &#39;red&#39;;
Undeclared identifier &#39;lime&#39;;
Undeclared identifier &#39;MA_s&#39;;

The source code is:

CCI = input(20, &quot;Tend Magic:: Input for CCI&quot;)
CCI = input(20)
ATR = input(5, &quot;Tend Magic:: Input for ATRc&quot;)
ATR = input(5)
Multiplier= input(1, &quot;Tend Magic :: ATR Multiplier&quot;)
Multiplier=input(1,title=&#39;ATR Multiplier&#39;)
original=input(true,title=&#39;original coloring&#39;)
original= true
thisCCI = cci(close, CCI)
thisCCI = cci(close, CCI)
lastCCI = nz(thisCCI[1])
lastCCI = nz(thisCCI[1])
bufferDn= high + Multiplier * sma(tr,ATR)
bufferDn= high + Multiplier * sma(tr,ATR)
bufferUp= low - Multiplier * sma(tr,ATR)
bufferUp= low - Multiplier * sma(tr,ATR)
if (thisCCI &gt;= 0 and lastCCI &lt; 0)
if (thisCCI &gt;= 0 and lastCCI &lt; 0)
    bufferUp := bufferDn[1]
    bufferUp := bufferDn[1]
if (thisCCI &lt;= 0 and lastCCI &gt; 0)
if (thisCCI &lt;= 0 and lastCCI &gt; 0)
    bufferDn := bufferUp[1]
    bufferDn := bufferUp[1]
if (thisCCI &gt;= 0)
if (thisCCI &gt;= 0)
    if (bufferUp &lt; bufferUp[1])
    if (bufferUp &lt; bufferUp[1])
        bufferUp := bufferUp[1]
        bufferUp := bufferUp[1]
else
else
    if (thisCCI &lt;= 0)
    if (thisCCI &lt;= 0)
        if (bufferDn &gt; bufferDn[1])
        if (bufferDn &gt; bufferDn[1])
            bufferDn := bufferDn[1]
            bufferDn := bufferDn[1]
x=thisCCI &gt;= 0 ?bufferUp:thisCCI &lt;= 0 ?bufferDn:x[1]
x=thisCCI &gt;= 0 ?bufferUp:thisCCI &lt;= 0 ?bufferDn:x[1]
swap=x&gt;x[1]?1:x&lt;x[1]?-1:swap[1]
swap=x&gt;x[1]?1:x&lt;x[1]?-1:swap[1]
swap2=swap==1?lime:red
swap2=swap==1?lime:red
swap3=thisCCI &gt;=0 ?lime:red
swap3=thisCCI &gt;=0 ?lime:red
swap4=original?swap3:swap2
swap4=original?swap3:swap2
plot(x,color=swap4,transp=0,linewidth=3)
bullTrendMagic = swap4 == lime and swap4[1] == red
bearTrendMagic = swap4 == red and swap4[1] == lime

I tried to understand the issue and try some instructions that I have read on many resources in order to merge the code to V4 without success Stuck migrating Pinescript v2 to v4

答案1

得分: 0

自引用变量 从 v3 开始不再允许。

所以像这样的:

//@version=2
//...
s = nz(s[1]) + close

将不再起作用,需要改成以下的形式:

//@version=3
//...
s = 0.0
s := nz(s[1]) + close

通过使用 这个 指南将其转换为 v3,然后使用自动转换工具。

英文:

Self referenced variables are not allowed anymore starting from v3.

So something like this:

//@version=2
//...
s = nz(s[1]) + close

Will not work anymore and needs to be written like below:

//@version=3
//...
s = 0.0
s := nz(s[1]) + close

Convert it to v3 by using this guide and then use the auto convert tool.

huangapple
  • 本文由 发表于 2023年3月1日 09:53:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/75598910.html
匿名

发表评论

匿名网友

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

确定