需要帮助将脚本修复为 Pinescript 版本 5 Tradingview

问题描述 投票:0回答:0

所以我有一个版本 2 的脚本,我试图将它转换为版本 5,但似乎仍然有 2 个错误,我个人似乎无法让它工作。我尝试在我自己的知识允许的范围内进行尽可能多的更改,现在我需要其他 2 个部分的帮助。如果有人可以帮助我,我将不胜感激。一旦你编译它,你会看到错误。

//@version=5
indicator(title="TESTING 1", shorttitle="TESTING 1", precision=0 )

src = close
vectorLen = input(34)
dispBull = input(false)
dispBear = input(false)
dispBullvsBear = input(true)
OS = -70.4
OB = 70.4

lowerBand = 10
PI = 3.14159265358979
ssFilter(price, lowerBand) =>
angle = math.sqrt(2) * PI / lowerBand
a1 = math.exp(-angle)
b1 = 2 * a1 * math.cos(angle)
c2 = b1
c3 = -a1 * a1
c1 = 1 - c2 - c3

filt = c1 * (price + nz(price[1])) / 2 + c2 * nz(filt[1]) + c3 * nz(filt[2])
filt

highestRef = ta.highest(src, vectorLen) 
lowestRef = ta.lowest(src, vectorLen)

// Bull Vector
bullVector = (src - lowestRef) * 100 / (highestRef - lowestRef)
ssBullVector = ssFilter(bullVector, lowerBand)
bullVectorColor = ta.change(ssBullVector) >= 0 ? color.lime : color.green
plot(dispBull ? ssBullVector * 2 - 100 : na, color = bullVectorColor, linewidth = 2)

// Bear Vector
bearVector = (highestRef - src) * 100 / (highestRef - lowestRef)
ssBearVector = ssFilter(bearVector, lowerBand)
bearVectorColor = ta.change(ssBearVector) >= 0 ? color.red : color.maroon
plot(dispBear ? ssBearVector * 2 - 100 : na, color = bearVectorColor, linewidth = 2)

bullVSbear = bullVector - bearVector
ssBullVSBear = ssFilter(bullVSbear, lowerBand)

bullVSBearHist = ta.change(ssBullVSBear, 1)
plot(dispBullvsBear ? ssBullVSBear : na, linewidth = 2, color = bullVSBearHist >= 0 ? 
color.green : color.red)
top = hline(110, color = color.red, linestyle = line.style_dotted)
bottom = hline(-110, color = color.lime, linestyle = line.style_dotted)
obLvl = hline(OB, color = color.red, linestyle = line.style_dotted)
hline(0, color = color.gray, linestyle = line.style_dotted)
osLvl = hline(OS, color = color.lime, linestyle = line.style_dotted)
fill(obLvl, top, color = color.red, transp = 80)
fill(osLvl, bottom, color = color.lime, transp = 80)
pine-script pine-script-v5 tradingview-api pine-script-v4 pinescript-v5
© www.soinside.com 2019 - 2024. All rights reserved.