Я пытаюсь переместить свой стоп-лосс, когда первый тейк-профит выводится в безубыток, или цену входа, с которой я вошел, когда снимается 1/2

#pine-script #pine-script-v4 #pinescript-v5

Вопрос:

я не могу переместить стоп-лосс к цене входа, когда я продаю половину позиции, у меня работает цена входа, и я могу получить цену за стоп-лосс, но я хочу, чтобы она двигалась к безубыточности, как только цель прибыли будет достигнута

 //@version=5 strategy('Renko', overlay=true, currency=currency.USD, initial_capital=500,  process_orders_on_close=false, default_qty_type=strategy.percent_of_equity,  default_qty_value=200, margin_long=1, margin_short=1)  entry_atr = float(0.0) //set float entry_price = float(0.0) //set float entry_atr := strategy.position_size == 0 or entry_long ? atr : entry_atr[1] entry_price := strategy.position_size == 0 or entry_long ? close : entry_price[1]  enter code here`if entry_long  strategy.entry(id='Long Entry', direction=strategy.long) if entry_short  strategy.entry(id='Short Entry', direction=strategy.short)  nLoss = entry_atr * atrMulti_Loss nProfit = entry_atr * atrMulti_Profit  long_profit_level = float(0.0) //set float long_stop_level = float(0.0) //set float long_profit_level := entry_price   nProfit long_stop_level := entry_price - nLoss  short_profit_level = float(0.0) //set float short_stop_level = float(0.0) //set float short_profit_level := entry_price - nProfit short_stop_level := entry_price   nLoss   plot(strategy.position_size lt;= 0 or entry_long or entry_short ? na : long_stop_level,  color=color.new(color.red, 0), style=plot.style_linebr, linewidth=2) plot(strategy.position_size lt;= 0 or entry_long or entry_short ? na : long_profit_level,  color=color.new(color.green, 0), style=plot.style_linebr, linewidth=2) plot(strategy.position_size gt;= 0 or entry_long or entry_short ? na : short_stop_level,  color=color.new(color.red, 0), style=plot.style_linebr, linewidth=2) plot(strategy.position_size gt;= 0 or entry_long or entry_short ? na : short_profit_level,  color=color.new(color.green, 0), style=plot.style_linebr, linewidth=2)  strategy.close(id='Long Entry', comment='Exit 1 L1', when=ta.crossunder(renko_close,  renko_open) or long_stop_level) strategy.close(id='Short Entry', comment='Exit 1 S1', when=ta.crossover(renko_open,  renko_close))  strategy.exit('TP/SL 1', from_entry='Long Entry', stop=long_stop_level,  limit=long_profit_level, qty_percent=50) strategy.exit('TP/SL 2', from_entry='TP/SL 1', stop=entry_price) //, qty_percent=100)  strategy.exit('TP/SL 1', 'Short Entry', stop=short_stop_level, limit=short_profit_level,  qty_percent=50) strategy.exit('TP/SL 2', 'Short Entry', stop=short_stop_level) //, qty_percent=100)