OPEN-SOURCE SCRIPT

Golden Cross RSI Daily Helper (US Stocks)

37
//version=5
indicator("Golden Cross RSI Daily Helper (US Stocks)", overlay=true, timeframe="D", timeframe_gaps=true)

//========= الإعدادات الأساسية =========//
emaFastLen = input.int(50, "EMA سريع (اتجاه قصير المدى)")
emaSlowLen = input.int(200, "EMA بطيء (اتجاه طويل المدى)")
rsiLen = input.int(14, "فترة RSI")
rsiMin = input.float(40.0, "حد RSI الأدنى للدخول", 0.0, 100.0)
rsiMax = input.float(60.0, "حد RSI الأعلى للدخول", 0.0, 100.0)
slBufferPerc = input.float(1.5, "نسبة البفر لوقف الخسارة (%) أسفل/أعلى EMA200", 0.1, 5.0)
rrRatio = input.float(2.0, "نسبة العائد إلى المخاطرة (R:R)", 1.0, 5.0)

//========= حساب المؤشرات =========//
emaFast = ta.ema(close, emaFastLen)
emaSlow = ta.ema(close, emaSlowLen)
rsiVal = ta.rsi(close, rsiLen)

// اتجاه السوق
trendUp = emaFast > emaSlow
trendDown = emaFast < emaSlow

// ارتداد السعر من EMA50 أو EMA200 تقريبياً
bounceFromEmaFast = close > emaFast and low <= emaFast
bounceFromEmaSlow = close > emaSlow and low <= emaSlow
bounceLong = bounceFromEmaFast or bounceFromEmaSlow

bounceFromEmaFastShort = close < emaFast and high >= emaFast
bounceFromEmaSlowShort = close < emaSlow and high >= emaSlow
bounceShort = bounceFromEmaFastShort or bounceFromEmaSlowShort

// فلتر RSI
rsiOk = rsiVal >= rsiMin and rsiVal <= rsiMax

//========= شروط الدخول =========//
// شراء
longSignal = trendUp and bounceLong and rsiOk

// بيع
shortSignal = trendDown and bounceShort and rsiOk

//========= حساب وقف الخسارة والأهداف =========//
// نستخدم سعر إغلاق شمعة الإشارة كسعر دخول افتراضي
entryPriceLong = close
entryPriceShort = close

// وقف الخسارة حسب EMA200 + البفر
slLong = emaSlow * (1.0 - slBufferPerc / 100.0)
slShort = emaSlow * (1.0 + slBufferPerc / 100.0)

// المسافة بين الدخول ووقف الخسارة
riskLong = math.max(entryPriceLong - slLong, syminfo.mintick)
riskShort = math.max(slShort - entryPriceShort, syminfo.mintick)

// هدف الربح حسب R:R
tpLong = entryPriceLong + rrRatio * riskLong
tpShort = entryPriceShort - rrRatio * riskShort

//========= الرسم على الشارت =========//
// رسم المتوسطات
plot(emaFast, title="EMA 50", color=color.new(color.blue, 0), linewidth=2)
plot(emaSlow, title="EMA 200", color=color.new(color.orange, 0), linewidth=2)

// تلوين الخلفية حسب الاتجاه
bgcolor(trendUp ? color.new(color.green, 92) : trendDown ? color.new(color.red, 92) : na)

// إشارة شراء
plotshape(
longSignal,
title = "إشارة شراء",
style = shape.triangleup,
location = location.belowbar,
size = size.large,
color = color.new(color.green, 0),
text = "BUY")

// إشارة بيع
plotshape(
shortSignal,
title = "إشارة بيع",
style = shape.triangledown,
location = location.abovebar,
size = size.large,
color = color.new(color.red, 0),
text = "SELL")

// رسم SL و TP عند ظهور الإشارة
slPlotLong = longSignal ? slLong : na
tpPlotLong = longSignal ? tpLong : na
slPlotShort = shortSignal ? slShort : na
tpPlotShort = shortSignal ? tpShort : na

plot(slPlotLong, title="وقف خسارة شراء", color=color.new(color.red, 0), style=plot.style_linebr)
plot(tpPlotLong, title="هدف شراء", color=color.new(color.green, 0), style=plot.style_linebr)
plot(slPlotShort, title="وقف خسارة بيع", color=color.new(color.red, 0), style=plot.style_linebr)
plot(tpPlotShort, title="هدف بيع", color=color.new(color.green, 0), style=plot.style_linebr)

//========= إعداد التنبيهات =========//
alertcondition(longSignal, title="تنبيه إشارة شراء", message="إشارة شراء: ترند صاعد + ارتداد من EMA + RSI في المنطقة المسموحة.")
alertcondition(shortSignal, title="تنبيه إشارة بيع", message="إشارة بيع: ترند هابط + ارتداد من EMA + RSI في المنطقة المسموحة.")

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.