'Helpme from this code, but I can't get it to start in strategy tester

I changed this code, but I can't get it to start in strategy tester.

My entry request and when the price was a lv fibo I want to add 3 positions that open at 100 pips from the other, with a fixed stop at 400 pips.

I thank those who could help me complete it

Pine Script

//@version = 5 

strategy('Prova strategia new 00 array', overlay = true, 
max_bars_back = 5000 , pyramiding = 3 , initial_capital = 100.000 
, currency = currency.EUR) 
//------------------------------------------------------------- -- 
-------------------------// 
gHHLL = '----Struttura----' 

tffnew = input.timeframe(defval = '240' , title = 'Tf' , inline ='fft') 
prdfnew = input.int(defval = 2 , title = '', minval = 0 , maxval = 20 , inline = 'fft') 
showzigzagfnew = input(defval = false , title = 'Zig Zag' , inline = 'ffz') 
showHHLLfnew = input(defval = false , title = 'HHLL' , inline = 'ffh') 
showfibofnew = input(defval = false , title = 'Fibonacci' , inline = 'fff') 
labellocfnew = input.string(defval = 'Left', title = 'Location', options = ['Left', 'Right'] , inline = 'fff') 

bool newbarfnew = ta.change(time(tffnew)) != 0 

bifnew = ta.valuewhen(newbarfnew, bar_index, prdfnew - 1) 
lenfnew = bar_index - bifnew + 1 

float phfnew = na 
float plfnew = na  

phfnew := ta.highestbars(high, nz(lenfnew, 1)) == 0 ? high : na 
plfnew := ta.lowestbars(low, nz(lenfnew, 1)) == 0 ? low : na 

var dirfnew = 0 
iff_1 = plfnew and na(phfnew) ? -1 : dirfnew 
dirfnew := phfnew and na(plfnew) ? 1 : iff_1 
var max_array_sizefnew = 50 
var zigzagfnew = array.new_float(0) 

add_to_zigzagfnew(valuefnew, bindexfnew) => 
    array.unshift(zigzagfnew, bindexfnew) 
    array.unshift(zigzagfnew, valuefnew) 
    if array.size(zigzagfnew) > max_array_sizefnew 
        array.pop(zigzagfnew) 
        array.pop(zigzagfnew) 
update_zigzag(valuefnew, bindexfnew) => 
    if array.size(zigzagfnew) == 0 
         add_to_zigzagfnew(valuefnew, bindexfnew) 
else 
    if dirfnew == 1 and valuefnew > array.get(zigzagfnew, 0) or dirfnew == -1 and valuefnew < array.get(zigzagfnew, 0) 
        array.set(zigzagfnew, 0, valuefnew) 
        array.set(zigzagfnew, 1,bindexfnew) 
    0. 

dirchangedfnew = ta.change(dirfnew) 
if phfnew or plfnew 
    if dirchangedfnew 
       add_to_zigzagfnew(dirfnew == 1 ? phfnew : plfnew, bar_index) 
    else 
        update_zigzag(dirfnew == 1 ? phfnew : plfnew, bar_index) 
if showzigzagfnew and array.size(zigzagfnew) >= 4 
    var line zzlinefnew = na 
    float valfnew = array.get(zigzagfnew,0) 
    int pointfnew = math.round(array.get(zigzagfnew, 1)) 
    if ta.change(valfnew) or ta.change(pointfnew) 
       float val1fnew = array.get(zigzagfnew, 2) 
       int point1fnew = math.round(array.get(zigzagfnew, 3)) 
       if ta.change(val1fnew) == 0 and ta.change(point1fnew) == 0 
           line.delete(zzlinefnew) 
    zzlinefnew := line.new(x1 = pointfnew, y1 = valfnew, x2 =point1fnew, y2 = val1fnew, color = color.blue, width = 2) 
    zzlinefnew 
if not showzigzagfnew and array.size(zigzagfnew) >= 6 
    var line zzlinefnew = na  
    line.delete(zzlinefnew)

gFibo = '----Fibo----' 
enable01 = input.bool(defval = false, title = '', inline = 'ff1', group = gFibo) 
fibb0 = input.float(1, '', step = 0.10, inline = 'ff1',group = gFibo) 
enable02 = input.bool(defval = true, title = '', inline = 'ff2', group = gFibo) 
fibb2 = input.float(0.55, '', step = 0.10, inline = 'ff2', group = gFibo) 
enable03 = input.bool(defval = true, title = '', inline = 'ff3', group = gFibo) 
fibb3 = input.float(0.50, '', step = 0.10, inline = 'ff3', group = gFibo) 
enable04 = input.bool(defval = false, title = '', inline = 'ff4', group = gFibo) 
fibb4 = 
input.float(0.60, '', step = 0.10, inline = 'ff4', group = 
gFibo) 
enable05 = input.bool(defval = false, title = '', inline = 'ff5', group = gFibo) 
fibb5 = input.float(0.0, '', step = 0.10, inline = 'ff5', group = gFibo)

var fibo_ratiosfnew = array.new_float(0) 
var fibo_colorsfnew = array.new_color(10) 
var shownlevelsfnew = 1  
if barstate.isfirst 
   array.push(fibo_ratiosfnew, 0.000) 
   if enable01 
      array.push(fibo_ratiosfnew, fibb0) 
      shownlevelsfnew += 1 
      shownlevelsfnew 
   if enable02 
      array.push(fibo_ratiosfnew, fibb2) 
      shownlevelsfnew += 1 
      shownlevelsfnew 
   if enable03 
      array.push(fibo_ratiosfnew, fibb3) 
      shownlevelsfnew += 1 
      shownlevelsfnew 
   if enable04 
      array.push(fibo_ratiosfnew, fibb4) 
      shownlevelsfnew += 1 
      shownlevelsfnew 
   if enable05 
      array.push(fibo_ratiosfnew, fibb5) 
      shownlevelsfnew += 1 
      shownlevelsfnew 

Round_itfnew(valuefnew) => 
    math.round(valuefnew / syminfo.mintick) * syminfo.mintick 

var fibolinesfnew = array.new_line(0) 
var fibolabelsfnew = array.new_label(0) 
if showfibofnew and array.size(zigzagfnew) >= 6 and barstate.islast 
   if array.size(fibolinesfnew) > 0 
      for xfnew = 0 to array.size(fibolinesfnew) - 1 by 1 
          line.delete(array.get(fibolinesfnew, xfnew)) 
          label.delete(array.get(fibolabelsfnew, xfnew))

   difffnew = array.get(zigzagfnew, 4) - array.get(zigzagfnew, 2) 
   stopitfnew = false 
   for xfnew = 0 to array.size(fibo_ratiosfnew) - 1 by 1 
       if stopitfnew and xfnew > shownlevelsfnew 
           break 

      array.unshift(fibolinesfnew, line.new(x1 =

math.round(array.get(zigzagfnew, 5)), y1 = array.get(zigzagfnew, 2) + difffnew * array.get(fibo_ratiosfnew, xfnew), x2 = bar_index, y2 = array.get(zigzagfnew, 2) + difffnew * array.get(fibo_ratiosfnew, xfnew), color = color.gray, extend = extend.none, style = line.style_dotted, width = 1)) label_x_locfnew = labellocfnew == 'Left' ? time[bar_index - (math.round(array.get(zigzagfnew, 5)) - 1)] : time txtfnew = labellocfnew == 'Right' ? '' : ' ' array.unshift(fibolabelsfnew, label.new(x = label_x_locfnew, y = array.get(zigzagfnew, 2) + difffnew * array.get(fibo_ratiosfnew, xfnew), text = txtfnew + str.tostring(array.get(fibo_ratiosfnew, xfnew), '#.###') + '(' + str.tostring(Round_itfnew(array.get(zigzagfnew, 2) + difffnew * array.get(fibo_ratiosfnew, xfnew))) + ')', xloc = xloc.bar_time, textcolor = color.gray, style = label.style_none)) if dirfnew == 1 and array.get(zigzagfnew, 2) + difffnew * array.get(fibo_ratiosfnew, xfnew) > array.get(zigzagfnew, 0) or dirfnew == -1 and array.get(zigzagfnew, 2) + difffnew * array.get(fibo_ratiosfnew, xfnew) < array.get(zigzagfnew, 0) stopitfnew := true stopitfnew

if showHHLLfnew and array.size(zigzagfnew) >= 4 
var line zzlinefnew = na 
float valfnew = array.get(zigzagfnew, 0) 
int pointfnew = math.round(array.get(zigzagfnew, 1)) 
if ta.change(valfnew) or ta.change(pointfnew) 
    float val1fnew = array.get(zigzagfnew, 2)
    int point1fnew = math.round(array.get(zigzagfnew, 3)) 
    if ta.change(val1fnew) == 0 and ta.change(point1fnew) == 0 
        line.delete(zzlinefnew) 


if array.size(zigzagfnew) >= 6 
   var line zzline1fnew = na 
   var label zzlabel1fnew = na 
   float valfnew = array.get(zigzagfnew, 0) 
   int pointfnew = math.round(array.get(zigzagfnew, 1)) 
   if ta.change(valfnew) or ta.change(pointfnew) 
       float val1fnew = array.get(zigzagfnew, 2) 
       int point1fnew = math.round(array.get(zigzagfnew, 3)) 
       if ta.change(val1fnew) == 0 and ta.change(point1fnew) == 0 
       line.delete(zzline1fnew) 
       label.delete(zzlabel1fnew) 
   if showHHLLfnew == true 
      hhlltxt = dirfnew == 1 ? array.get(zigzagfnew, 0) > array.get(zigzagfnew, 4) ? 'HH' : 'LH' : array.get(zigzagfnew, 0) < array.get(zigzagfnew, 4) ? 'LL' : 'HL' 
      labelcol = dirfnew == 1 ? array.get(zigzagfnew, 0) > array.get(zigzagfnew, 4) ? color.lime : color.red : array.get(zigzagfnew, 0) < array.get(zigzagfnew, 4) ? color.red : color.lime 
      zzlabel1fnew := label.new(x = pointfnew, y = valfnew, text = hhlltxt, color = labelcol, textcolor = color.black, size = size.small, style = dirfnew ==  1 ? label.style_label_down : label.style_label_up) 
      zzlabel1fnew 
//------------------------------------------------------------- 
gStrat = '----Strategia----' 
target01_active = input.bool(title='Target 2 - Active?', defval=false) 
target02_active = input.bool(title='Target 2 - Active?', defval=false) 
target03_active = input.bool(title='Target 2 - Active?', defval=false) 
tp = input.float(title='Target:', defval = 50 , inline = 'ord0', group = gStrat) 
stop = input.float(title='Stop:', defval = 300 , inline = 'ord0', group = gStrat)

entry_size1 = input.float(title='Size1:', defval =0.05 , inline = 'ord1', group = gStrat) 
entry_size2 = input.float(title='Size2:', defval =0.10 , inline = 'ord2', group = gStrat) 
entry_size3 = input.float(title='Size3:', defval =0.20 , inline = 'ord3', group = gStrat)

target01_ew_rate = input.float(title='Target 1 - Fib. Rate to use for Entry Window:',defval=0.236) 
tp_rate = input.float(title='Target 1 - Fib. Rate to use for TP:', defval=0.618) 
target01_sl_rate = input.float(title='Target 1 - Fib. Rate to use for SL:', defval=-0.236) 


buy_entry = low  == fibb4 
buy_close = low  == fibb0

sel_entry = high == fibb4 
sel_close = high == fibb0

strategy.entry(id = 'long' , direction = strategy.long , qty = 
 entry_size1 , comment ='long' , when = buy_entry) 
strategy.entry(id = 'short' , direction = strategy.short, qty = entry_size1 , comment ='short' , when = sel_entry) 

strategy.exit (id = 'exit' , from_entry = 'long' , profit = tp , loss = stop) 
strategy.exit (id = 'exit' , from_entry = 'short' , profit = tp , loss = stop) 


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source