OPEN-SOURCE SCRIPT

MACD+RSI Divergence Pro v2

81
//version=5
indicator("MACD+RSI Divergence Pro v2", overlay=true)

// 1. إعداد MACD
[macdLine, signalLine, _] = ta.macd(close, 12, 26, 9)
macdBullish = ta.crossover(macdLine, signalLine)
macdBearish = ta.crossunder(macdLine, signalLine)

// 2. إعداد RSI
rsiValue = ta.rsi(close, 14)
rsiOverbought = rsiValue >= 70
rsiOversold = rsiValue <= 30

// 3. كشف الاختلافات المصحح
// → استخدمنا الدالة `ta.valuewhen()` لتحديد القمم/القيعان بدقة
swingLow = ta.lowest(low, 5)
swingHigh = ta.highest(high, 5)
rsiAtSwingLow = ta.valuewhen(swingLow == low, rsiValue, 0)
rsiAtSwingHigh = ta.valuewhen(swingHigh == high, rsiValue, 0)

bullishDiv = low < low[1] and rsiAtSwingLow > rsiAtSwingLow[1] and rsiOversold
bearishDiv = high > high[1] and rsiAtSwingHigh < rsiAtSwingHigh[1] and rsiOverbought

// 4. مرشح الاتجاه (EMA 200)
marketTrend = ta.ema(close, 200)
isUptrend = close > marketTrend

// 5. الإشارات النهائية
buySignal = bullishDiv and macdBullish and isUptrend
sellSignal = bearishDiv and macdBearish and not isUptrend

// 6. العرض على الرسم
plotshape(buySignal, title="شراء", text="▲", style=shape.labelup, location=location.belowbar, color=color.new(#00FF00, 0), textcolor=color.white)
plotshape(sellSignal, title="بيع", text="▼", style=shape.labeldown, location=location.abovebar, color=color.new(#FF0000, 0), textcolor=color.white)

// 7. تنبيهات
alertcondition(buySignal, "إشارة شراء", "Bullish Divergence + MACD Crossover")
alertcondition(sellSignal, "إشارة بيع", "Bearish Divergence + MACD Crossunder")

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.