英文:
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 '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(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 >= 0 and lastCCI < 0)
if (thisCCI >= 0 and lastCCI < 0)
bufferUp := bufferDn[1]
bufferUp := bufferDn[1]
if (thisCCI <= 0 and lastCCI > 0)
if (thisCCI <= 0 and lastCCI > 0)
bufferDn := bufferUp[1]
bufferDn := bufferUp[1]
if (thisCCI >= 0)
if (thisCCI >= 0)
if (bufferUp < bufferUp[1])
if (bufferUp < bufferUp[1])
bufferUp := bufferUp[1]
bufferUp := bufferUp[1]
else
else
if (thisCCI <= 0)
if (thisCCI <= 0)
if (bufferDn > bufferDn[1])
if (bufferDn > bufferDn[1])
bufferDn := bufferDn[1]
bufferDn := bufferDn[1]
x=thisCCI >= 0 ?bufferUp:thisCCI <= 0 ?bufferDn:x[1]
x=thisCCI >= 0 ?bufferUp:thisCCI <= 0 ?bufferDn:x[1]
swap=x>x[1]?1:x<x[1]?-1:swap[1]
swap=x>x[1]?1:x<x[1]?-1:swap[1]
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 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
答案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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论