OPEN-SOURCE SCRIPT

RSI MACD MA Strategy REZGAR

//version=5
indicator("RSI MACD MA Strategy", overlay=true)

// 🔹 پارامترهای قابل تنظیم توسط کاربر
rsi_length = input.int(14, title="RSI Length")
macd_fast_length = input.int(12, title="MACD Fast EMA")
macd_slow_length = input.int(26, title="MACD Slow EMA")
macd_signal_length = input.int(9, title="MACD Signal Length")
ma_length = input.int(50, title="Moving Average Length")

// 📊 محاسبه اندیکاتورها
rsi_value = ta.rsi(close, rsi_length)
macd_line = ta.ema(close, macd_fast_length) - ta.ema(close, macd_slow_length)
signal_line = ta.ema(macd_line, macd_signal_length)
ma_value = ta.sma(close, ma_length)

// 📈 نمایش MACD و RSI در زیر چارت برای بررسی
hline(70, "Overbought", color=color.red)
hline(30, "Oversold", color=color.green)
plot(rsi_value, title="RSI", color=color.blue)

// 🔥 سیگنال‌های خرید و فروش (شرایط بهینه‌تر)
buy_signal = ta.crossover(macd_line, signal_line) and rsi_value < 40 and close > ma_value
sell_signal = ta.crossunder(macd_line, signal_line) and rsi_value > 60 and close < ma_value

// 🔔 نمایش سیگنال‌ها در چارت
plotshape(buy_signal, location=location.belowbar, color=color.green, style=shape.labelup, title="Buy Signal")
plotshape(sell_signal, location=location.abovebar, color=color.red, style=shape.labeldown, title="Sell Signal")

// 🔊 تنظیمات هشدار (Alert)
alertcondition(buy_signal, title="Buy Alert", message="🔹 Buy Signal Detected!")
alertcondition(sell_signal, title="Sell Alert", message="🔻 Sell Signal Detected!")

Aviso legal