Below code gives error. PinescriptVersion4
TrendUp :=close[1]>TrendUp[1]? max(Up,TrendUp[1]) : Up
TrendDown :=close[1]
Trend := close > TrendDown[1] ? 1: close< TrendUp[1]? -1: nz(Trend[1],1)
Tsl := Trend==1? TrendUp: TrendDown
Trend1 = security(syminfo.tickerid,"1",Trend)
You have to wrap your code in a function and pass that to the security call instead. https://www.tradingview.com/pine-script-docs/en/v4/appendix/Pine_version_3_migration_guide.html#resolving-a-problem-with-a-mutable-variable-in-a-security-expression
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.