OPEN-SOURCE SCRIPT

Gold Trading Signals m.samimi

// Pine Script v5
//version=5
indicator("Gold Trading Signals", overlay=true)

// تنظیم اندیکاتورها
ema50 = ta.ema(close, 50)
ema200 = ta.ema(close, 200)
[macdLine, signalLine, _] = ta.macd(close, 12, 26, 9)
rsi = ta.rsi(close, 14)
atr = ta.atr(14)
stochRsi = ta.stoch(close, high, low, 14)
volumeProfile = ta.sma(volume, 50)

// محاسبه Bollinger Bands به صورت دستی
bb_middle = ta.sma(close, 20)
bb_upper = bb_middle + 2 * ta.stdev(close, 20)
bb_lower = bb_middle - 2 * ta.stdev(close, 20)

// شرط خرید (Buy Signal)
buyCondition = ta.crossover(macdLine, signalLine) and close > ema50 and close > ema200 and rsi > 50 and stochRsi < 20

// شرط فروش (Sell Signal)
sellCondition = ta.crossunder(macdLine, signalLine) and close < ema50 and close < ema200 and rsi < 50 and stochRsi > 80

// واگرایی‌ها
divBull = ta.lowest(close, 5) < ta.lowest(close, 10) and rsi > ta.lowest(rsi, 10) // واگرایی مثبت
divBear = ta.highest(close, 5) > ta.highest(close, 10) and rsi < ta.highest(rsi, 10) // واگرایی منفی

// بررسی شکست مقاومت و حمایت
breakoutUp = close > bb_upper and volume > volumeProfile
breakoutDown = close < bb_lower and volume > volumeProfile

// مدیریت ریسک با ATR
stopLoss = atr * 1.5
riskReward = stopLoss * 2

// نمایش سیگنال‌ها
plotshape(buyCondition or divBull or breakoutUp, location=location.belowbar, color=color.green, style=shape.labelup, title="Buy Signal")
plotshape(sellCondition or divBear or breakoutDown, location=location.abovebar, color=color.red, style=shape.labeldown, title="Sell Signal")

// نمایش خطوط EMA
plot(ema50, title="EMA 50", color=color.blue)
plot(ema200, title="EMA 200", color=color.orange)

// نمایش Bollinger Bands
plot(bb_upper, title="BB Upper", color=color.gray)
plot(bb_middle, title="BB Middle", color=color.gray)
plot(bb_lower, title="BB Lower", color=color.gray)

// نمایش ATR
plot(atr, title="ATR", color=color.purple)

Aviso legal