میشه کاری کرد که در کد بالا خطوط  نمایشی ورود و خروج هر ابر از انتهای ابر شروع بشه و تا کراس بعدی تشکیل نشده ادامه داشته باش  
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © golshantashan

//@version=6
indicator(title="Ichimoku", shorttitle="Ichimoku", overlay=true)

// Input parameters
conversionPeriods = input.int(9, minval=1, title="Conversion Line Length")
basePeriods = input.int(26, minval=1, title="Base Line Length")
laggingSpan2Periods = input.int(52, minval=1, title="Leading Span B Length")
displacement = input.int(26, minval=1, title="Lagging Span")

// Donchian function
donchian(len) => math.avg(ta.lowest(len), ta.highest(len))

// Calculate lines
conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = math.avg(conversionLine, baseLine)
leadLine2 = donchian(laggingSpan2Periods)

// Plot Leading Span A and B with offset
p1 = plot(leadLine1, offset=displacement - 1, color=#A5D6A7, title="Leading Span A")
p2 = plot(leadLine2, offset=displacement - 1, color=#EF9A9A, title="Leading Span B")

// Detect crossover and crossunder
cross_up = ta.crossover(leadLine1, leadLine2)
cross_down = ta.crossunder(leadLine1, leadLine2)

// Variables for red cloud
var int red_last_cross_bar = 0
var float red_max_leadLine2 = na
var float red_min_leadLine1 = na
var bool is_red_cloud = false
var int red_candle_count = 0
var int red_cross_bar_index = na
var int red_cloud_length_at_cross = 0
var float red_pip_diff_at_cross = 0.0

// Variables for green cloud
var int green_last_cross_bar = 0
var float green_max_leadLine1 = na
var float green_min_leadLine2 = na
var bool is_green_cloud = false
var int green_candle_count = 0
var int green_cross_bar_index = na
var int green_cloud_length_at_cross = 0
var float green_pip_diff_at_cross = 0.0

// Update red and green cloud states
if cross_down
    is_red_cloud := true
    is_green_cloud := false
    red_max_leadLine2 := leadLine2
    red_min_leadLine1 := leadLine1
    red_last_cross_bar := bar_index
    red_candle_count := 0
    red_cross_bar_index := bar_index
    red_cloud_length_at_cross := green_candle_count
    red_pip_diff_at_cross := (green_max_leadLine1 - green_min_leadLine2) / syminfo.mintick * 0.1
else if cross_up
    is_red_cloud := false
    is_green_cloud := true
    green_max_leadLine1 := leadLine1
    green_min_leadLine2 := leadLine2
    green_last_cross_bar := bar_index
    green_candle_count := 0
    green_cross_bar_index := bar_index
    green_cloud_length_at_cross := red_candle_count
    green_pip_diff_at_cross := (red_max_leadLine2 - red_min_leadLine1) / syminfo.mintick * 0.1

// Update values during red cloud
if is_red_cloud
    red_candle_count := red_candle_count + 1
    red_max_leadLine2 := na(red_max_leadLine2) ? leadLine2 : math.max(red_max_leadLine2, leadLine2)
    red_min_leadLine1 := na(red_min_leadLine1) ? leadLine1 : math.min(red_min_leadLine1, leadLine1)

// Update values during green cloud
if is_green_cloud
    green_candle_count := green_candle_count + 1
    green_max_leadLine1 := na(green_max_leadLine1) ? leadLine1 : math.max(green_max_leadLine1, leadLine1)
    green_min_leadLine2 := na(green_min_leadLine2) ? leadLine2 : math.min(green_min_leadLine2, leadLine2)

// strategy input
var long_entry = 0.0
var long_tp1 = 0.0
var long_tp2 = 0.0
var long_sl = 0.0

var short_entry = 0.0
var short_tp1 = 0.0
var short_tp2 = 0.0
var short_sl = 0.0

entry_type = input.string("max_min_price", "entry type", ["max_min_price", "cross_candle"])


// Display combined label with OHLC and cloud info when reaching cross points
if not na(red_cross_bar_index) and bar_index == red_cross_bar_index + displacement - 1
    higher_high = 0.0
    for i = 1 to red_cloud_length_at_cross
        if high[i] > higher_high
            higher_high := high[i]
    lower_low = 10000000.0
    for i = 1 to red_cloud_length_at_cross
        if low[i] < lower_low
            lower_low := low[i]
    
    //position {
    long_entry := entry_type=="max_min_price" ? higher_high : high
    short_entry := entry_type=="max_min_price" ? lower_low : low
    //}

    // محاسبه تارگت و حد سودها برای پوزیشن لانگ و شورت
    target = red_pip_diff_at_cross + red_cloud_length_at_cross
    pip = syminfo.mintick * 10 // تبدیل پیپ به قیمت
    long_tp1 := long_entry + (target / 2) * pip
    long_tp2 := long_entry + target * pip
    short_tp1 := short_entry - (target / 2) * pip
    short_tp2 := short_entry - target * pip

    // label {
    red_combined_label_text = 
      "GreenCloud Length(candle): " + str.tostring(red_cloud_length_at_cross) + "\n" +
      "GreenCloud Height(pips): " + str.tostring(red_pip_diff_at_cross, "#.##") + "\n" +
      "Target: " + str.tostring(target, "#.##") + "\n" +
      "CrossCandle High: " + str.tostring(high, "#.##") + "\n" +
      "CrossCandle Low: " + str.tostring(low, "#.##") + "\n" +
      "GreenCloud HigherHigh: " + str.tostring(higher_high, "#.##") + "\n" +
      "GreenCloud LowerLow: " + str.tostring(lower_low, "#.##") + "\n" 
    //   "Long TP1: " + str.tostring(long_tp1, "#.##") + "\n" +
    //   "Long TP2: " + str.tostring(long_tp2, "#.##") + "\n" +
    //   "Short TP1: " + str.tostring(short_tp1, "#.##") + "\n" +
    //   "Short TP2: " + str.tostring(short_tp2, "#.##")
    label.new(
      bar_index,
      high + (high - low) * 0.5,
      red_combined_label_text,
      color=#13c3e26e,
      style=label.style_label_down,
      textcolor=color.white
      )
    // خطوط ورود و خروج لانگ و شورت برای ابر قرمز
    line.new(bar_index - red_cloud_length_at_cross, long_entry, bar_index, long_entry, color=color.yellow, width=2, style=line.style_solid) // نقطه ورود لانگ
    line.new(bar_index - red_cloud_length_at_cross, long_tp1, bar_index, long_tp1, color=color.lime, width=2, style=line.style_dotted) // حد سود 1 لانگ
    line.new(bar_index - red_cloud_length_at_cross, long_tp2, bar_index, long_tp2, color=color.maroon, width=2, style=line.style_dotted) // حد سود 2 لانگ
    line.new(bar_index - red_cloud_length_at_cross, short_entry, bar_index, short_entry, color=color.orange, width=2, style=line.style_solid) // نقطه ورود شورت
    line.new(bar_index - red_cloud_length_at_cross, short_tp1, bar_index, short_tp1, color=color.lime, width=2, style=line.style_dotted) // حد سود 1 شورت
    line.new(bar_index - red_cloud_length_at_cross, short_tp2, bar_index, short_tp2, color=color.maroon, width=2, style=line.style_dotted) // حد سود 2 شورت
    // لیبل قیمت‌ها و عنوان روی خطوط
    mid_bar = bar_index - math.floor(red_cloud_length_at_cross / 2)
    label.new(mid_bar, long_entry, "Entry Long\n" + str.tostring(long_entry, "#.##"), color=color.yellow, style=label.style_label_left, textcolor=color.black, size=size.small)
    label.new(mid_bar, long_tp1, "TP1 Long\n" + str.tostring(long_tp1, "#.##"), color=color.lime, style=label.style_label_left, textcolor=color.black, size=size.small)
    label.new(mid_bar, long_tp2, "TP2 Long\n" + str.tostring(long_tp2, "#.##"), color=color.maroon, style=label.style_label_left, textcolor=color.white, size=size.small)
    label.new(mid_bar, short_entry, "Entry Short\n" + str.tostring(short_entry, "#.##"), color=color.orange, style=label.style_label_left, textcolor=color.black, size=size.small)
    label.new(mid_bar, short_tp1, "TP1 Short\n" + str.tostring(short_tp1, "#.##"), color=color.lime, style=label.style_label_left, textcolor=color.black, size=size.small)
    label.new(mid_bar, short_tp2, "TP2 Short\n" + str.tostring(short_tp2, "#.##"), color=color.maroon, style=label.style_label_left, textcolor=color.white, size=size.small)
else if not na(green_cross_bar_index) and bar_index == green_cross_bar_index + displacement - 1
    higher_high = 0.0
    for i = 1 to green_cloud_length_at_cross
        if high[i] > higher_high
            higher_high := high[i]
    lower_low = 10000000.0
    for i = 1 to green_cloud_length_at_cross
        if low[i] < lower_low
            lower_low := low[i]
    
    //position {
    long_entry := entry_type=="max_min_price" ? higher_high : high
    short_entry := entry_type=="max_min_price" ? lower_low : low
    //}

    // محاسبه تارگت و حد سودها برای پوزیشن لانگ و شورت
    target = green_pip_diff_at_cross + green_cloud_length_at_cross
    pip = syminfo.mintick * 10 // تبدیل پیپ به قیمت
    long_tp1 := long_entry + (target / 2) * pip
    long_tp2 := long_entry + target * pip
    short_tp1 := short_entry - (target / 2) * pip
    short_tp2 := short_entry - target * pip

    // label {
    green_combined_label_text = "RedCloud Length(candle): " + str.tostring(green_cloud_length_at_cross) + "\n" +
      "RedCloud Height(pips): " + str.tostring(green_pip_diff_at_cross, "#.##") + "\n" +
      "Target: " + str.tostring(target, "#.##") + "\n" +
      "CrossCandle High: " + str.tostring(high, "#.##") + "\n" +
      "CrossCandle Low: " + str.tostring(low, "#.##") + "\n" +
      "RedCloud HigherHigh: " + str.tostring(higher_high, "#.##") + "\n" +
      "RedCloud LowerLow: " + str.tostring(lower_low, "#.##") + "\n" 
    //   "Long TP1: " + str.tostring(long_tp1, "#.##") + "\n" +
    //   "Long TP2: " + str.tostring(long_tp2, "#.##") + "\n" +
    //   "Short TP1: " + str.tostring(short_tp1, "#.##") + "\n" +
    //   "Short TP2: " + str.tostring(short_tp2, "#.##")
    label.new(
      bar_index,
      low - (high - low) * 0.5,
      green_combined_label_text,
      color=#ff52a370,
      style=label.style_label_up,
      textcolor=color.white
      )
    // خطوط ورود و خروج لانگ و شورت برای ابر سبز
    line.new(bar_index - green_cloud_length_at_cross, long_entry, bar_index, long_entry, color=color.yellow, width=2, style=line.style_solid) // نقطه ورود لانگ
    line.new(bar_index - green_cloud_length_at_cross, long_tp1, bar_index, long_tp1, color=color.lime, width=2, style=line.style_dotted) // حد سود 1 لانگ
    line.new(bar_index - green_cloud_length_at_cross, long_tp2, bar_index, long_tp2, color=color.maroon, width=2, style=line.style_dotted) // حد سود 2 لانگ
    line.new(bar_index - green_cloud_length_at_cross, short_entry, bar_index, short_entry, color=color.orange, width=2, style=line.style_solid) // نقطه ورود شورت
    line.new(bar_index - green_cloud_length_at_cross, short_tp1, bar_index, short_tp1, color=color.lime, width=2, style=line.style_dotted) // حد سود 1 شورت
    line.new(bar_index - green_cloud_length_at_cross, short_tp2, bar_index, short_tp2, color=color.maroon, width=2, style=line.style_dotted) // حد سود 2 شورت
    // لیبل قیمت‌ها و عنوان روی خطوط
    mid_bar = bar_index - math.floor(green_cloud_length_at_cross / 2)
    label.new(mid_bar, long_entry, "Entry Long\n" + str.tostring(long_entry, "#.##"), color=color.yellow, style=label.style_label_left, textcolor=color.black, size=size.small)
    label.new(mid_bar, long_tp1, "TP1 Long\n" + str.tostring(long_tp1, "#.##"), color=color.lime, style=label.style_label_left, textcolor=color.black, size=size.small)
    label.new(mid_bar, long_tp2, "TP2 Long\n" + str.tostring(long_tp2, "#.##"), color=color.maroon, style=label.style_label_left, textcolor=color.white, size=size.small)
    label.new(mid_bar, short_entry, "Entry Short\n" + str.tostring(short_entry, "#.##"), color=color.orange, style=label.style_label_left, textcolor=color.black, size=size.small)
    label.new(mid_bar, short_tp1, "TP1 Short\n" + str.tostring(short_tp1, "#.##"), color=color.lime, style=label.style_label_left, textcolor=color.black, size=size.small)
    label.new(mid_bar, short_tp2, "TP2 Short\n" + str.tostring(short_tp2, "#.##"), color=color.maroon, style=label.style_label_left, textcolor=color.white, size=size.small)