0

So I have a script that was version 2, and I tried to convert it to version 5, but it seems like there are still 2 errors, and I personally can not seem to get it to work. I tried to change as much as my own knowledge allowed me, and now I need help with the remaining 2 parts. If someone can help me I would greatly appreciate it. Once you compile it you will see the errors.

//@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)
LJ2
  • 11
  • 2

1 Answers1

0

You need to indent the code in your function block by 4 spaces or a tab.

Other than that, the line style of hline() starts with hline.* and not with line.*.

//@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 = 0.0
    filt := c1 * (price + nz(price[1])) / 2 + c2 * nz(filt[1]) + c3 * nz(filt[2])

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 = hline.style_dotted)
bottom = hline(-110, color = color.lime, linestyle = hline.style_dotted)
obLvl = hline(OB, color = color.red, linestyle = hline.style_dotted)
hline(0, color = color.gray, linestyle = hline.style_dotted)
osLvl = hline(OS, color = color.lime, linestyle = hline.style_dotted)
fill(obLvl, top, color = color.red, transp = 80)
fill(osLvl, bottom, color = color.lime, transp = 80)
vitruvius
  • 15,740
  • 3
  • 16
  • 26