Syntax error at input 'Tiny'
- User
Syntax error at input 'Tiny'
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Syntax error at input 'Tiny'
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
مشکل از این است که در Pine Script v5، نمیتوانیم از switch با case برای رشتهها استفاده کنیم. باید از if/else if استفاده کنیم.
در اینجا کد کامل اصلاح شده است:
//@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, group="Ichimoku Settings")
kijun_period = input.int(26, title="Kijun Sen Period", minval=1, group="Ichimoku Settings")
senkou_span_b_period = input.int(52, title="Senkou Span B Period", minval=1, group="Ichimoku Settings")
displacement = input.int(26, title="Displacement", minval=1, group="Ichimoku Settings")
// نمایش/عدم نمایش اجزا
show_tenkan = input.bool(true, title="Show Tenkan Sen", group="Display Options")
show_kijun = input.bool(true, title="Show Kijun Sen", group="Display Options")
show_chikou = input.bool(true, title="Show Chikou Span", group="Display Options")
show_cloud = input.bool(true, title="Show Cloud", group="Display Options")
show_signals_on_chart = input.bool(true, title="Show Buy/Sell Signals on Chart", group="Display Options")
// تنظیمات "Pane Labels" (شبیهسازی شده با label.new)
show_pane_signal_label = input.bool(true, title="Show Signal Status in Pane (Top)", group="Pane Signal Label")
pane_label_position_y_offset = input.float(1.02, title="Vertical Position Offset (e.g., 1.02 for slightly above high)", step=0.01, group="Pane Signal Label")
pane_label_text_color = input.color(color.white, title="Text Color", group="Pane Signal Label")
pane_label_size_str = input.string("Normal", title="Text Size", options=["Tiny", "Small", "Normal", "Large", "Huge"], group="Pane Signal Label")
// تبدیل رشته اندازه به مقدار واقعی
_size_actual = size.normal // مقدار پیشفرض
if pane_label_size_str == "Tiny"
_size_actual := size.tiny
else if pane_label_size_str == "Small"
_size_actual := size.small
else if pane_label_size_str == "Normal"
_size_actual := size.normal
else if pane_label_size_str == "Large"
_size_actual := size.large
else if pane_label_size_str == "Huge"
_size_actual := size.huge
// محاسبه خطوط ایچیموکو
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.new(color.blue, 0), title="Tenkan Sen", linewidth=2)
plot(show_kijun ? kijun_sen : na, color=color.new(color.red, 0), title="Kijun Sen", linewidth=2)
plot(show_chikou ? chikou_span : na, offset=-displacement, color=color.new(color.purple, 0), title="Chikou Span", linewidth=1)
// رسم ابر
p1 = plot(show_cloud ? senkou_span_a : na, offset=displacement, color=color.new(color.green, 100), title="Senkou Span A", display=display.none)
p2 = plot(show_cloud ? senkou_span_b : na, offset=displacement, color=color.new(color.red, 100), 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_senkou_a = senkou_span_a[displacement]
future_senkou_b = senkou_span_b[displacement]
future_cloud_top = math.max(future_senkou_a, future_senkou_b)
future_cloud_bottom = math.min(future_senkou_a, future_senkou_b)
price_above_future_cloud = close > future_cloud_top
price_below_future_cloud = close < future_cloud_bottom
price_inside_future_cloud = close >= future_cloud_bottom and close <= future_cloud_top
future_bullish_cloud = future_senkou_a > future_senkou_b
chikou_above_price = chikou_span > close[displacement]
chikou_below_price = chikou_span < close[displacement]
price_above_kijun = close > kijun_sen
price_below_kijun = close < kijun_sen
strong_buy = tk_cross_up and price_above_future_cloud and future_bullish_cloud and chikou_above_price and price_above_kijun
medium_buy = tk_cross_up and (price_above_future_cloud or price_inside_future_cloud) and tenkan_sen > kijun_sen
strong_sell = tk_cross_down and price_below_future_cloud and not future_bullish_cloud and chikou_below_price and price_below_kijun
medium_sell = tk_cross_down and (price_below_future_cloud or price_inside_future_cloud) and tenkan_sen < kijun_sen
// نمایش سیگنالها روی نمودار
if show_signals_on_chart
if strong_buy
label.new(bar_index, low - ta.atr(14) * 0.5, text="BUY++", color=color.new(color.green, 0), textcolor=color.white,
style=label.style_label_up, size=size.normal)
else if medium_buy and not strong_buy
label.new(bar_index, low - ta.atr(14) * 0.5, text="BUY", color=color.new(color.lime, 0), textcolor=color.black,
style=label.style_label_up, size=size.small)
if strong_sell
label.new(bar_index, high + ta.atr(14) * 0.5, text="SELL++", color=color.new(color.red, 0), textcolor=color.white,
style=label.style_label_down, size=size.normal)
else if medium_sell and not strong_sell
label.new(bar_index, high + ta.atr(14) * 0.5, text="SELL", color=color.new(color.orange, 0), textcolor=color.black,
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")
// نمایش وضعیت فعلی در گوشه نمودار
var label status_info_label = na
if barstate.islast
label.delete(status_info_label)
status_text = ""
current_signal_status = "⚪ NEUTRAL"
current_signal_color = color.new(color.gray, 30)
if strong_buy
current_signal_status := "🟢 STRONG BUY"
current_signal_color := color.new(color.green, 30)
else if medium_buy
current_signal_status := "🟢 BUY"
current_signal_color := color.new(color.lime, 30)
else if strong_sell
current_signal_status := "🔴 STRONG SELL"
current_signal_color := color.new(color.red, 30)
else if medium_sell
current_signal_status := "🔴 SELL"
current_signal_color := color.new(color.orange, 30)
status_text := current_signal_status
status_text += "\nTenkan/Kijun: " + (tenkan_sen > kijun_sen ? "Bullish ↑" : "Bearish ↓")
status_text += "\nPrice vs Cloud (Future): " + (price_above_future_cloud ? "Above ↑" : price_below_future_cloud ? "Below ↓" : "Inside ↔")
status_text += "\nFuture Cloud: " + (future_bullish_cloud ? "Bullish ☁↑" : "Bearish ☁↓")
status_text += "\nChikou vs Price (Past): " + (chikou_above_price ? "Above ↑" : chikou_below_price ? "Below ↓" : "Neutral/Crossing")
status_text += "\nPrice vs Kijun: " + (price_above_kijun ? "Above ↑" : price_below_kijun ? "Below ↓" : "On Kijun")
status_info_label := label.new(bar_index + 10, high, text=status_text,
xloc=xloc.bar_index, yloc=yloc.price,
color=current_signal_color,
textcolor=color.white,
style=label.style_label_left,
size=size.normal, textalign = text.align_left)
// هشدارها
alertcondition(strong_buy, title="Strong Buy Signal", message="Ichimoku Strong Buy Signal on {{ticker}} at {{close}}")
alertcondition(medium_buy, title="Medium Buy Signal", message="Ichimoku Medium Buy Signal on {{ticker}} at {{close}}")
alertcondition(strong_sell, title="Strong Sell Signal", message="Ichimoku Strong Sell Signal on {{ticker}} at {{close}}")
alertcondition(medium_sell, title="Medium Sell Signal", message="Ichimoku Medium Sell Signal on {{ticker}} at {{close}}")
alertcondition(tk_cross_up, title="Tenkan/Kijun Bullish Cross", message="Ichimoku TK Bullish Cross on {{ticker}}")
alertcondition(tk_cross_down, title="Tenkan/Kijun Bearish Cross", message="Ichimoku TK Bearish Cross on {{ticker}}")
// نمایش فلشهای کوچک برای تقاطعهای ساده
plotshape(tk_cross_up and not medium_buy and not strong_buy,
title="TK Simple Cross Up", location=location.belowbar,
color=color.new(color.blue, 30), style=shape.triangleup, size=size.tiny)
plotshape(tk_cross_down and not medium_sell and not strong_sell,
title="TK Simple Cross Down", location=location.abovebar,
color=color.new(color.maroon, 30), style=shape.triangledown, size=size.tiny)
// متغیر برای لیبل سیگنال در بالای نمودار
var label pane_top_signal_label = na
// نمایش سیگنال فعلی در بالای نمودار (شبیهسازی pane label)
if show_pane_signal_label and barstate.islast
label.delete(pane_top_signal_label)
string pane_signal_text = "NEUTRAL"
color pane_bg_color = color.new(color.gray, 50)
if strong_buy
pane_signal_text := "STRONG BUY"
pane_bg_color := color.new(color.green, 50)
else if medium_buy
pane_signal_text := "BUY"
pane_bg_color := color.new(color.lime, 50)
else if strong_sell
pane_signal_text := "STRONG SELL"
pane_bg_color := color.new(color.red, 50)
else if medium_sell
pane_signal_text := "SELL"
pane_bg_color := color.new(color.orange, 50)
pane_top_signal_label := label.new(
x=bar_index,
y=high * pane_label_position_y_offset,
text=pane_signal_text,
xloc=xloc.bar_index,
yloc=yloc.price,
color=pane_bg_color,
textcolor=pane_label_text_color,
style=label.style_label_center,
size=_size_actual
)
تغییرات کلیدی:
var string از خط تعریف _size_actualswitch/case با if/else if برای تبدیل رشته به اندازهstrategy() که در کد قبلی اشتباهاً استفاده شده بوداین کد اکنون باید بدون خطا کار کند و شما بتوانید اندازه متن لیبل را از تنظیمات تغییر دهید.
Mismatched input 'end of line without line continuation' expecting ')'
خطای Mismatched input 'end of line without line continuation' expecting ')' معمولاً به دلیل مشکل در syntax پارامترهای تابع است. در کد، احتمالاً مشکل در قسمت textalign = text.align_left است.
در اینجا کد کامل اصلاح شده است:
//@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, group="Ichimoku Settings")
kijun_period = input.int(26, title="Kijun Sen Period", minval=1, group="Ichimoku Settings")
senkou_span_b_period = input.int(52, title="Senkou Span B Period", minval=1, group="Ichimoku Settings")
displacement = input.int(26, title="Displacement", minval=1, group="Ichimoku Settings")
// نمایش/عدم نمایش اجزا
show_tenkan = input.bool(true, title="Show Tenkan Sen", group="Display Options")
show_kijun = input.bool(true, title="Show Kijun Sen", group="Display Options")
show_chikou = input.bool(true, title="Show Chikou Span", group="Display Options")
show_cloud = input.bool(true, title="Show Cloud", group="Display Options")
show_signals_on_chart = input.bool(true, title="Show Buy/Sell Signals on Chart", group="Display Options")
// تنظیمات "Pane Labels" (شبیهسازی شده با label.new)
show_pane_signal_label = input.bool(true, title="Show Signal Status in Pane (Top)", group="Pane Signal Label")
pane_label_position_y_offset = input.float(1.02, title="Vertical Position Offset (e.g., 1.02 for slightly above high)", step=0.01, group="Pane Signal Label")
pane_label_text_color = input.color(color.white, title="Text Color", group="Pane Signal Label")
pane_label_size_str = input.string("Normal", title="Text Size", options=["Tiny", "Small", "Normal", "Large", "Huge"], group="Pane Signal Label")
// تبدیل رشته اندازه به مقدار واقعی
_size_actual = size.normal
if pane_label_size_str == "Tiny"
_size_actual := size.tiny
else if pane_label_size_str == "Small"
_size_actual := size.small
else if pane_label_size_str == "Normal"
_size_actual := size.normal
else if pane_label_size_str == "Large"
_size_actual := size.large
else if pane_label_size_str == "Huge"
_size_actual := size.huge
// محاسبه خطوط ایچیموکو
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.new(color.blue, 0), title="Tenkan Sen", linewidth=2)
plot(show_kijun ? kijun_sen : na, color=color.new(color.red, 0), title="Kijun Sen", linewidth=2)
plot(show_chikou ? chikou_span : na, offset=-displacement, color=color.new(color.purple, 0), title="Chikou Span", linewidth=1)
// رسم ابر
p1 = plot(show_cloud ? senkou_span_a : na, offset=displacement, color=color.new(color.green, 100), title="Senkou Span A", display=display.none)
p2 = plot(show_cloud ? senkou_span_b : na, offset=displacement, color=color.new(color.red, 100), 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_senkou_a = senkou_span_a[displacement]
future_senkou_b = senkou_span_b[displacement]
future_cloud_top = math.max(future_senkou_a, future_senkou_b)
future_cloud_bottom = math.min(future_senkou_a, future_senkou_b)
price_above_future_cloud = close > future_cloud_top
price_below_future_cloud = close < future_cloud_bottom
price_inside_future_cloud = close >= future_cloud_bottom and close <= future_cloud_top
future_bullish_cloud = future_senkou_a > future_senkou_b
chikou_above_price = chikou_span > close[displacement]
chikou_below_price = chikou_span < close[displacement]
price_above_kijun = close > kijun_sen
price_below_kijun = close < kijun_sen
strong_buy = tk_cross_up and price_above_future_cloud and future_bullish_cloud and chikou_above_price and price_above_kijun
medium_buy = tk_cross_up and (price_above_future_cloud or price_inside_future_cloud) and tenkan_sen > kijun_sen
strong_sell = tk_cross_down and price_below_future_cloud and not future_bullish_cloud and chikou_below_price and price_below_kijun
medium_sell = tk_cross_down and (price_below_future_cloud or price_inside_future_cloud) and tenkan_sen < kijun_sen
// نمایش سیگنالها روی نمودار
if show_signals_on_chart
if strong_buy
label.new(bar_index, low - ta.atr(14) * 0.5, text="BUY++", color=color.new(color.green, 0), textcolor=color.white, style=label.style_label_up, size=size.normal)
else if medium_buy and not strong_buy
label.new(bar_index, low - ta.atr(14) * 0.5, text="BUY", color=color.new(color.lime, 0), textcolor=color.black, style=label.style_label_up, size=size.small)
if strong_sell
label.new(bar_index, high + ta.atr(14) * 0.5, text="SELL++", color=color.new(color.red, 0), textcolor=color.white, style=label.style_label_down, size=size.normal)
else if medium_sell and not strong_sell
label.new(bar_index, high + ta.atr(14) * 0.5, text="SELL", color=color.new(color.orange, 0), textcolor=color.black, 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")
// نمایش وضعیت فعلی در گوشه نمودار
var label status_info_label = na
if barstate.islast
label.delete(status_info_label)
status_text = ""
current_signal_status = "⚪ NEUTRAL"
current_signal_color = color.new(color.gray, 30)
if strong_buy
current_signal_status := "🟢 STRONG BUY"
current_signal_color := color.new(color.green, 30)
else if medium_buy
current_signal_status := "🟢 BUY"
current_signal_color := color.new(color.lime, 30)
else if strong_sell
current_signal_status := "🔴 STRONG SELL"
current_signal_color := color.new(color.red, 30)
else if medium_sell
current_signal_status := "🔴 SELL"
current_signal_color := color.new(color.orange, 30)
status_text := current_signal_status
status_text += "\nTenkan/Kijun: " + (tenkan_sen > kijun_sen ? "Bullish ↑" : "Bearish ↓")
status_text += "\nPrice vs Cloud (Future): " + (price_above_future_cloud ? "Above ↑" : price_below_future_cloud ? "Below ↓" : "Inside ↔")
status_text += "\nFuture Cloud: " + (future_bullish_cloud ? "Bullish ☁↑" : "Bearish ☁↓")
status_text += "\nChikou vs Price (Past): " + (chikou_above_price ? "Above ↑" : chikou_below_price ? "Below ↓" : "Neutral/Crossing")
status_text += "\nPrice vs Kijun: " + (price_above_kijun ? "Above ↑" : price_below_kijun ? "Below ↓" : "On Kijun")
status_info_label := label.new(bar_index + 10, high, text=status_text, xloc=xloc.bar_index, yloc=yloc.price, color=current_signal_color, textcolor=color.white, style=label.style_label_left, size=size.normal, textalign=text.align_left)
// هشدارها
alertcondition(strong_buy, title="Strong Buy Signal", message="Ichimoku Strong Buy Signal on {{ticker}} at {{close}}")
alertcondition(medium_buy, title="Medium Buy Signal", message="Ichimoku Medium Buy Signal on {{ticker}} at {{close}}")
alertcondition(strong_sell, title="Strong Sell Signal", message="Ichimoku Strong Sell Signal on {{ticker}} at {{close}}")
alertcondition(medium_sell, title="Medium Sell Signal", message="Ichimoku Medium Sell Signal on {{ticker}} at {{close}}")
alertcondition(tk_cross_up, title="Tenkan/Kijun Bullish Cross", message="Ichimoku TK Bullish Cross on {{ticker}}")
alertcondition(tk_cross_down, title="Tenkan/Kijun Bearish Cross", message="Ichimoku TK Bearish Cross on {{ticker}}")
// نمایش فلشهای کوچک برای تقاطعهای ساده
plotshape(tk_cross_up and not medium_buy and not strong_buy, title="TK Simple Cross Up", location=location.belowbar, color=color.new(color.blue, 30), style=shape.triangleup, size=size.tiny)
plotshape(tk_cross_down and not medium_sell and not strong_sell, title="TK Simple Cross Down", location=location.abovebar, color=color.new(color.maroon, 30), style=shape.triangledown, size=size.tiny)
// متغیر برای لیبل سیگنال در بالای نمودار
var label pane_top_signal_label = na
// نمایش سیگنال فعلی در بالای نمودار (شبیهسازی pane label)
if show_pane_signal_label and barstate.islast
label.delete(pane_top_signal_label)
string pane_signal_text = "NEUTRAL"
color pane_bg_color = color.new(color.gray, 50)
if strong_buy
pane_signal_text := "STRONG BUY"
pane_bg_color := color.new(color.green, 50)
else if medium_buy
pane_signal_text := "BUY"
pane_bg_color := color.new(color.lime, 50)
else if strong_sell
pane_signal_text := "STRONG SELL"
pane_bg_color := color.new(color.red, 50)
else if medium_sell
pane_signal_text := "SELL"
pane_bg_color := color.new(color.orange, 50)
pane_top_signal_label := label.new(x=bar_index, y=high * pane_label_position_y_offset, text=pane_signal_text, xloc=xloc.bar_index, yloc=yloc.price, color=pane_bg_color, textcolor=pane_label_text_color, style=label.style_label_center, size=_size_actual)
تغییرات کلیدی:
label.new() را در یک خط قرار دادماین کد اکنون باید بدون خطا کار کند.