متوجه شدم. مشکل از استفاده نادرست از plotshape است. در Pine Script v5، باید از فرمت صحیح برای plotshape استفاده کنیم. در زیر نسخه اصلاحشده کد آورده شده است:
//@version=5
indicator("Advanced Trading Strategy - Fixed Signals", overlay=true)
// ورودیهای کاربر
emaShortLength = input.int(9, title="EMA Short Length")
emaMediumLength = input.int(21, title="EMA Medium Length")
emaLongLength = input.int(50, title="EMA Long Length")
rsiLength = input.int(14, title="RSI Length")
rsiOverbought = input.int(70, title="RSI Overbought Level")
rsiOversold = input.int(30, title="RSI Oversold Level")
macdFastLength = input.int(12, title="MACD Fast Length")
macdSlowLength = input.int(26, title="MACD Slow Length")
macdSignalSmoothing = input.int(9, title="MACD Signal Smoothing")
// محاسبه اندیکاتورها
emaShort = ta.ema(close, emaShortLength)
emaMedium = ta.ema(close, emaMediumLength)
emaLong = ta.ema(close, emaLongLength)
rsi = ta.rsi(close, rsiLength)
[macdLine, signalLine, macdHistogram] = ta.macd(close, macdFastLength, macdSlowLength, macdSignalSmoothing)
// محاسبه حجم معاملات
avgVolume = ta.sma(volume, 20)
highVolume = volume > avgVolume * 1.2
// محاسبه سطوح حمایت و مقاومت
pivotHigh = ta.pivothigh(high, 5, 5)
pivotLow = ta.pivotlow(low, 5, 5)
var float supportLevel = na
var float resistanceLevel = na
if not na(pivotHigh)
resistanceLevel := pivotHigh
if not na(pivotLow)
supportLevel := pivotLow
// شرایط روند ساده
bullishTrend = emaShort > emaMedium and emaMedium > emaLong
bearishTrend = emaShort < emaMedium and emaMedium < emaLong
// سیگنالهای خرید (سادهتر و دقیقتر)
// سیگنال خرید قوی
strongBuySignal = ta.crossover(emaShort, emaMedium) and
rsi < 70 and
macdLine > signalLine and
close > open
// سیگنال خرید متوسط
mediumBuySignal = ta.crossover(emaShort, emaLong) and
rsi < 65 and
macdHistogram > 0
// سیگنال خرید در اصلاح
dipBuySignal = rsi < rsiOversold and
rsi > rsi[1] and
close > emaShort and
macdHistogram > macdHistogram[1]
// سیگنال خرید MACD
macdBuySignal = ta.crossover(macdLine, signalLine) and
rsi < 60 and
close > emaMedium
// سیگنالهای فروش (سادهتر و دقیقتر)
// سیگنال فروش قوی
strongSellSignal = ta.crossunder(emaShort, emaMedium) and
rsi > 30 and
macdLine < signalLine and
close < open
// سیگنال فروش متوسط
mediumSellSignal = ta.crossunder(emaShort, emaLong) and
rsi > 35 and
macdHistogram < 0
// سیگنال فروش در اشباع خرید
peakSellSignal = rsi > rsiOverbought and
rsi < rsi[1] and
close < emaShort and
macdHistogram < macdHistogram[1]
// سیگنال فروش MACD
macdSellSignal = ta.crossunder(macdLine, signalLine) and
rsi > 40 and
close < emaMedium
// ترکیب سیگنالها
anyBuySignal = strongBuySignal or mediumBuySignal or dipBuySignal or macdBuySignal
anySellSignal = strongSellSignal or mediumSellSignal or peakSellSignal or macdSellSignal
// رسم سیگنالها با اشکال مختلف
plotshape(strongBuySignal, title="STRONG BUY", location=location.belowbar, color=color.lime, style=shape.labelup, text="STRONG BUY", size=size.normal, textcolor=color.white)
plotshape(mediumBuySignal, title="BUY", location=location.belowbar, color=color.green, style=shape.triangleup, text="BUY", size=size.small, textcolor=color.white)
plotshape(dipBuySignal, title="DIP", location=location.belowbar, color=color.blue, style=shape.circle, text="DIP", size=size.tiny, textcolor=color.white)
plotshape(macdBuySignal, title="MACD BUY", location=location.belowbar, color=color.aqua, style=shape.square, text="MACD", size=size.tiny, textcolor=color.white)
plotshape(strongSellSignal, title="STRONG SELL", location=location.abovebar, color=color.red, style=shape.labeldown, text="STRONG SELL", size=size.normal, textcolor=color.white)
plotshape(mediumSellSignal, title="SELL", location=location.abovebar, color=color.orange, style=shape.triangledown, text="SELL", size=size.small, textcolor=color.white)
plotshape(peakSellSignal, title="PEAK", location=location.abovebar, color=color.purple, style=shape.circle, text="PEAK", size=size.tiny, textcolor=color.white)
plotshape(macdSellSignal, title="MACD SELL", location=location.abovebar, color=color.maroon, style=shape.square, text="MACD", size=size.tiny, textcolor=color.white)
// رسم EMAها
plot(emaShort, color=color.blue, linewidth=2, title="EMA 9")
plot(emaMedium, color=color.orange, linewidth=2, title="EMA 21")
plot(emaLong, color=color.red, linewidth=2, title="EMA 50")
// رسم سطوح حمایت و مقاومت
plot(supportLevel, color=color.green, linewidth=2, style=plot.style_line, title="Support", offset=0)
plot(resistanceLevel, color=color.red, linewidth=2, style=plot.style_line, title="Resistance", offset=0)
// رنگآمیزی پسزمینه بر اساس روند
bgcolor(bullishTrend ? color.new(color.green, 95) : bearishTrend ? color.new(color.red, 95) : na, title="Trend Background")
// نمایش اطلاعات در گوشه
var table infoTable = table.new(position.top_right, 2, 5, bgcolor=color.white, border_width=1)
if barstate.islast
table.cell(infoTable, 0, 0, "RSI", text_color=color.black, bgcolor=color.gray)
table.cell(infoTable, 1, 0, str.tostring(math.round(rsi, 1)), text_color=color.black)
table.cell(infoTable, 0, 1, "MACD", text_color=color.black, bgcolor=color.gray)
table.cell(infoTable, 1, 1, str.tostring(math.round(macdLine, 4)), text_color=color.black)
table.cell(infoTable, 0, 2, "Trend", text_color=color.black, bgcolor=color.gray)
table.cell(infoTable, 1, 2, bullishTrend ? "Bull" : bearishTrend ? "Bear" : "Side",
text_color=bullishTrend ? color.green : bearishTrend ? color.red : color.orange)
table.cell(infoTable, 0, 3, "Volume", text_color=color.black, bgcolor=color.gray)
table.cell(infoTable, 1, 3, highVolume ? "High" : "Normal",
text_color=highVolume ? color.green : color.gray)
table.cell(infoTable, 0, 4, "Signal", text_color=color.black, bgcolor=color.gray)
table.cell(infoTable, 1, 4, anyBuySignal ? "BUY" : anySellSignal ? "SELL" : "WAIT",
text_color=anyBuySignal ? color.green : anySellSignal ? color.red : color.orange)
// آلارمها
alertcondition(strongBuySignal, title="Strong Buy", message="Strong Buy Signal!")
alertcondition(strongSellSignal, title="Strong Sell", message="Strong Sell Signal!")
alertcondition(anyBuySignal, title="Any Buy", message="Buy Signal Generated!")
alertcondition(anySellSignal, title="Any Sell", message="Sell Signal Generated!")
// نمایش آمار در انتهای نمودار
if barstate.islast
label.new(bar_index, high,
"EMA9: " + str.tostring(math.round(emaShort, 2)) + "\n" +
"EMA21: " + str.tostring(math.round(emaMedium, 2)) + "\n" +
"RSI: " + str.tostring(math.round(rsi, 1)),
style=label.style_label_down,
color=color.blue,
textcolor=color.white,
size=size.small)
✅ تغییرات اصلی:
- اصلاح خطا Syntax: استفاده از فرمت صحیح برای
plotshape
- افزودن عنوان برای هر plotshape: برای جلوگیری از خطاهای احتمالی
- اصلاح جدول اطلاعات: بهبود نمایش جدول اطلاعات
- اصلاح لیبل نهایی: بهبود نمایش لیبل در انتهای نمودار
این نسخه باید بدون خطا کار کند و سیگنالها را به درستی روی چارت نمایش دهد. اگر هنوز مشکل وجود دارد، لطفاً به من بگویید تا بیشتر بررسی کنم.