I am trying to convert Chandelier Stop study script to strategy but getting Undeclared Identifier error in version=4
The original script can be found here - https://in.tradingview.com/script/mjBdRGXe-Chandelier-Stop/
//input variables Length2=input(title="Look Back Period", type=input.integer, defval=22) ATRPeriod=input(title="ATR Period", type=input.integer, defval=22) Mult=input(title="ATR Multiplier", type=input.integer, defval=3) //calculate stop value short_stop = lowest(Length2)+Mult*atr(ATRPeriod) long_stop = highest(Length2)-Mult*atr(ATRPeriod) shortvs=na(shortvs[1]) ? short_stop : iff(close>shortvs[1], short_stop , min(short_stop,shortvs[1])) longvs=na(longvs[1]) ? long_stop : iff(close<longvs[1], long_stop, max(long_stop,longvs[1])) longswitch=iff (close>=shortvs[1] and close[1]<shortvs[1] , 1 , 0) shortswitch=iff (close<=longvs[1] and close[1]>longvs[1] , 1 , 0) direction= iff(na(direction[1]), 0, iff (direction[1]<=0 and longswitch, 1, iff (direction[1]>=0 and shortswitch, -1, direction[1]))) pcup=direction>0?longvs : na pcdn=direction<0?shortvs : na plot(pcup, color=color.aqua, style=plot.style_circles, linewidth=2) plot(pcup, color=color.aqua, style=plot.style_linebr, linewidth=2) plot(pcdn, color=color.fuchsia, style=plot.style_circles, linewidth=2) plot(pcdn, color=color.fuchsia, style=plot.style_linebr, linewidth=2) Here is Error Log
Processing script... line 35: Undeclared identifier 'shortvs'; line 36: Undeclared identifier 'longvs'; line 38: Undeclared identifier 'shortvs'; line 39: Undeclared identifier 'longvs'; line 41: Undeclared identifier 'direction'; line 41: Undeclared identifier 'longswitch'; line 41: Undeclared identifier 'shortswitch'; line 43: Undeclared identifier 'direction'; line 43: Undeclared identifier 'longvs'; line 44: Undeclared identifier 'direction'; line 44: Undeclared identifier 'shortvs'; line 53: Undeclared identifier 'direction'; line 57: Undeclared identifier 'direction'; line 118: Undeclared identifier 'pcup'; line 119: Undeclared identifier 'pcup'; line 121: Undeclared identifier 'pcdn'; line 122: Undeclared identifier 'pcdn' https://stackoverflow.com/questions/66480550/undeclared-identifier-error-in-pinescript-while-translating-study-script-to-stra March 05, 2021 at 01:59AM
没有评论:
发表评论