برای قسمت pane labels  تنظیمات اضافه شود

//@version=5
indicator("Ichimoku Cloud with Buy/Sell Signals", overlay=true, shorttitle="Ichimoku Signals")

// تنظیمات ورودی
tenkan_period = input.int(9, title="Tenkan Sen Period", minval=1)
kijun_period = input.int(26, title="Kijun Sen Period", minval=1)
senkou_span_b_period = input.int(52, title="Senkou Span B Period", minval=1)
displacement = input.int(26, title="Displacement", minval=1)

// نمایش/عدم نمایش اجزا
show_tenkan = input.bool(true, title="Show Tenkan Sen")
show_kijun = input.bool(true, title="Show Kijun Sen")
show_chikou = input.bool(true, title="Show Chikou Span")
show_cloud = input.bool(true, title="Show Cloud")
show_signals = input.bool(true, title="Show Buy/Sell Signals")

// محاسبه خطوط ایچیکامو
tenkan_sen = (ta.highest(high, tenkan_period) + ta.lowest(low, tenkan_period)) / 2
kijun_sen = (ta.highest(high, kijun_period) + ta.lowest(low, kijun_period)) / 2
senkou_span_a = (tenkan_sen + kijun_sen) / 2
senkou_span_b = (ta.highest(high, senkou_span_b_period) + ta.lowest(low, senkou_span_b_period)) / 2
chikou_span = close

// رسم خطوط
plot(show_tenkan ? tenkan_sen : na, color=color.blue, title="Tenkan Sen", linewidth=2)
plot(show_kijun ? kijun_sen : na, color=color.red, title="Kijun Sen", linewidth=2)
plot(show_chikou ? chikou_span : na, offset=-displacement, color=color.purple, title="Chikou Span", linewidth=1)

// رسم ابر
p1 = plot(show_cloud ? senkou_span_a : na, offset=displacement, color=color.green, title="Senkou Span A", display=display.none)
p2 = plot(show_cloud ? senkou_span_b : na, offset=displacement, color=color.red, title="Senkou Span B", display=display.none)
fill(p1, p2, color=senkou_span_a > senkou_span_b ? color.new(color.green, 80) : color.new(color.red, 80), title="Cloud")

// شرایط سیگنال‌ها
// تقاطع تنکان و کیجون
tk_cross_up = ta.crossover(tenkan_sen, kijun_sen)
tk_cross_down = ta.crossunder(tenkan_sen, kijun_sen)

// موقعیت قیمت نسبت به ابر
future_cloud_top = math.max(senkou_span_a[displacement], senkou_span_b[displacement])
future_cloud_bottom = math.min(senkou_span_a[displacement], senkou_span_b[displacement])
price_above_cloud = close > future_cloud_top
price_below_cloud = close < future_cloud_bottom

// ابر صعودی یا نزولی
bullish_cloud = senkou_span_a[displacement] > senkou_span_b[displacement]

// موقعیت چیکو اسپن
chikou_above = chikou_span > close[displacement]

// موقعیت قیمت نسبت به کیجون
price_above_kijun = close > kijun_sen

// سیگنال‌های خرید قوی
strong_buy = tk_cross_up and price_above_cloud and bullish_cloud and chikou_above and price_above_kijun

// سیگنال‌های خرید متوسط  
medium_buy = tk_cross_up and not price_below_cloud and tenkan_sen > kijun_sen

// سیگنال‌های فروش قوی
strong_sell = tk_cross_down and price_below_cloud and not bullish_cloud and not chikou_above and not price_above_kijun

// سیگنال‌های فروش متوسط
medium_sell = tk_cross_down and not price_above_cloud and tenkan_sen < kijun_sen

// نمایش سیگنال‌ها روی نمودار
if show_signals
    if strong_buy
        label.new(bar_index, low, text="BUY++", color=color.green, textcolor=color.white, 
                 style=label.style_label_up, size=size.normal)
    else if medium_buy and not strong_buy
        label.new(bar_index, low, text="BUY", color=color.lime, textcolor=color.white, 
                 style=label.style_label_up, size=size.small)
    
    if strong_sell
        label.new(bar_index, high, text="SELL++", color=color.red, textcolor=color.white, 
                 style=label.style_label_down, size=size.normal)
    else if medium_sell and not strong_sell
        label.new(bar_index, high, text="SELL", color=color.orange, textcolor=color.white, 
                 style=label.style_label_down, size=size.small)

// رنگ پس‌زمینه بر اساس قدرت سیگنال
bgcolor(strong_buy ? color.new(color.green, 90) : na, title="Strong Buy Background")
bgcolor(strong_sell ? color.new(color.red, 90) : na, title="Strong Sell Background")

// خط‌های افقی برای سطوح کلیدی
hline_tenkan = plot(tenkan_sen, color=color.new(color.blue, 100), display=display.data_window)
hline_kijun = plot(kijun_sen, color=color.new(color.red, 100), display=display.data_window)

// نمایش وضعیت فعلی در گوشه نمودار
var label status_label = na
label.delete(status_label)

if barstate.islast
    status_text = ""
    
    if strong_buy
        status_text := "🟢 STRONG BUY SIGNAL"
    else if medium_buy
        status_text := "🟢 BUY SIGNAL"
    else if strong_sell
        status_text := "🔴 STRONG SELL SIGNAL"
    else if medium_sell  
        status_text := "🔴 SELL SIGNAL"
    else
        status_text := "⚪ NEUTRAL"
    
    // اضافه کردن اطلاعات بیشتر
    status_text := status_text + "\n"
    status_text := status_text + "\nTenkan/Kijun: " + (tenkan_sen > kijun_sen ? "Bullish ↑" : "Bearish ↓")
    status_text := status_text + "\nPrice/Cloud: " + (price_above_cloud ? "Above ↑" : price_below_cloud ? "Below ↓" : "Inside →")
    status_text := status_text + "\nCloud: " + (bullish_cloud ? "Bullish ☁↑" : "Bearish ☁↓")
    
    status_label := label.new(bar_index + 5, close, text=status_text, 
                             color=color.new(color.black, 80), 
                             textcolor=color.white,
                             style=label.style_label_left,
                             size=size.normal)

// هشدارها
alertcondition(strong_buy, title="Strong Buy Signal", message="Ichimoku Strong Buy Signal on {{ticker}}!")
alertcondition(medium_buy, title="Buy Signal", message="Ichimoku Buy Signal on {{ticker}}")
alertcondition(strong_sell, title="Strong Sell Signal", message="Ichimoku Strong Sell Signal on {{ticker}}!")
alertcondition(medium_sell, title="Sell Signal", message="Ichimoku Sell Signal on {{ticker}}")

// نمایش فلش‌های کوچک برای تقاطع‌های ساده
plotshape(tk_cross_up and not medium_buy and not strong_buy, 
         title="TK Cross Up", location=location.belowbar, 
         color=color.new(color.blue, 50), style=shape.triangleup, size=size.tiny)

plotshape(tk_cross_down and not medium_sell and not strong_sell, 
         title="TK Cross Down", location=location.abovebar, 
         color=color.new(color.blue, 50), style=shape.triangledown, size=size.tiny)