I'm working on a script that includes a Fibonacci projection to determine the duration and end of the operation, calculating the projection levels by the highest bottom among 20 bars prior to the order entry and using the entry price as a parameter 0.38 of the Fibonacci projection to calculate the other values and ok, I've done that, but I would like the values of the lines not to be changed until the end of the operation. I managed to create the lines, but throughout the operation, they change their original values, ruining the objective. I need to keep these values until the end of a condition that closes the operation. I've tried with Hline and Line.new but I couldn't. this is my code:
var bool longing := false
var float longentryprice := na
var float stoploss := na
var float longbottom := na
var distafibo61a := na
var distafibo100a := na
var distafibo161 := na
longentry = longing== false and ta.crossover(ema21, ema64)
if longentry
longing := true
longentryprice := ta.valuewhen(longentry, close, 0)
longbottom := (ta.lowest(close, 20)[1]
distafibo61a := longbottom + (((longentryprice - longbottom) * 61.8) / 38.2)
distafibo100a := longbottom + (((longentryprice - longbottom) * 100) / 38.2)
distafibo161a := distafibo100a + (((longentryprice - longbottom) * 61.8) / 38.2)
strategy.entry("long") ////make entry long /////
stoploss := longbottom ////define primary stoploss////
plot(distafibo61a, color=color.rgb(186, 255, 88), title="Fibo 61")
plot(distafibo100a,color=color.rgb(81, 188, 84), title="Fibo 100")
plot(longbottom, color=color.rgb(96, 96, 96), title="long bottom")
plot(distafibo161a,color=#54bbad, title="fibo161")
if close > distafibo100a //define firt stopgain//
stoploss := distafibo61a
if close > distafibo161a //define maximum stopgain//
strategy.exit("long") //close operation maximum profit//
if close < stoploss //close operation and reset variables///
longing := false
var bool longing := false
longentryprice := na
stoploss := na
longbottom := na
distafibo61a := na
distafibo100a := na
distafibo161a := na
strategy.exit("long")
enter image description here