Problem to convert to pinescript V4 or V5

It's not a v4 indicator, it's written in Pine v1, hence why it works without specifying the version at the beginning. Migration guides from earlier Pine versions to the newer ones can be found in the User Manual.

Working v5 code:

//@version=5
indicator(title='Wolf Trade', overlay=true)
adverupgrade = input(defval=true, title='instagram.com/wolftrade_official')
showsignal = input(defval=true, title='Signal')
showStop = input(defval=false, title='Stop Loss')
a = input(2, title='Sensitive 1 Or 2')
RSILENGTH = input(14, title='14')
RSICENTERLINE = input(52, title='52')
MACDFASTLENGTH = input(7, title='7')
MACDSLOWLENGTH = input(12, title='12')
MACDSIGNALSMOOTHING = input(12, title='12')
SmoothK = input(3, title='3')
SmoothD = input(3, title='3')
LengthRSI = input(14, title='14')
LengthStoch = input(14, title='14')
c = input(10, title='10')
xATR = ta.atr(c)
nLoss = a * xATR
float xATRTrailingStop = na
iff_1 = close > nz(xATRTrailingStop[1], 0) ? close - nLoss : close + nLoss
iff_2 = close < nz(xATRTrailingStop[1], 0) and close[1] < nz(xATRTrailingStop[1], 0) ? math.min(nz(xATRTrailingStop[1]), close + nLoss) : iff_1
xATRTrailingStop := close > nz(xATRTrailingStop[1], 0) and close[1] > nz(xATRTrailingStop[1], 0) ? math.max(nz(xATRTrailingStop[1]), close - nLoss) : iff_2
float pos = na
iff_3 = close[1] > nz(xATRTrailingStop[1], 0) and close < nz(xATRTrailingStop[1], 0) ? -1 : nz(pos[1], 0)
pos := close[1] < nz(xATRTrailingStop[1], 0) and close > nz(xATRTrailingStop[1], 0) ? 1 : iff_3
color = pos == -200 ? color.red : pos == 1 ? color.yellow : color.yellow
ema = ta.ema(close, 1)
above = ta.crossover(ema, xATRTrailingStop)
below = ta.crossover(xATRTrailingStop, ema)
buy = close > xATRTrailingStop and above
sell = close < xATRTrailingStop and below
barbuy = close > xATRTrailingStop
barsell = close < xATRTrailingStop
plotshape(showsignal and buy, title='Buy', text='Buy', style=shape.triangleup, location=location.belowbar, color=color.new(#00bcd4, 0), textcolor=color.new(#00bcd4, 0), size=size.tiny)
plotshape(showsignal and sell, title='Sell', text='Sell', style=shape.triangledown, location=location.abovebar, color=color.new(#e91c1c, 0), textcolor=color.new(#e91c1c, 0), size=size.tiny)
barcolor(showsignal and barbuy ? #26a69a : na)
barcolor(showsignal and barsell ? #ef5350 : na)
alertcondition(showsignal and buy, title='Buy', message='Buy')
alertcondition(showsignal and sell, title='Sell', message='Sell')
Length = input(title='22', defval=22)
ATRPeriod = input(title='22', defval=22)
Mult = input(title='3', defval=3)
RSISource = input(close, title='close')
SOURCE = input(hlc3, title='hlc3')
short_stop = ta.lowest(Length) + Mult * ta.atr(ATRPeriod)
long_stop = ta.highest(Length) - Mult * ta.atr(ATRPeriod)
float shortvs = na
float longvs = na
shortvs := na(shortvs[1]) ? short_stop : close > shortvs[1] ? short_stop : math.min(short_stop, shortvs[1])
longvs := na(longvs[1]) ? long_stop : close < longvs[1] ? long_stop : math.max(long_stop, longvs[1])
longswitch = close >= shortvs[1] and close[1] < shortvs[1] ? 1 : 0
shortswitch = close <= longvs[1] and close[1] > longvs[1] ? 1 : 0
float direction = na
iff_4 = direction[1] >= 0 and shortswitch ? -1 : direction[1]
iff_5 = direction[1] <= 0 and longswitch ? 1 : iff_4
direction := na(direction[1]) ? 0 : iff_5
pc = direction > 0 ? longvs : shortvs
plot(showStop and pc ? pc : na, color=direction > 0 ? color.new(#26a69a, 70) : color.new(#ef5350, 70), title='Stop Lines', style=plot.style_line, linewidth=2)