OPEN-SOURCE SCRIPT
RSI Divergence & Momentum Color

//version=5
// هذا مؤشر موحد يحدد الدايفرجنس (العادي والمخفي) ويقوم بتلوين الشموع حسب زخم RSI.
indicator(title="RSI Divergence & Momentum Color", shorttitle="RSI Divergence & MOM", overlay=true)
// --- 1. الإعدادات والمتغيرات (Inputs) ---
// إعدادات RSI
rsiLength = input.int(14, title="RSI Length", minval=1)
// إعدادات تحديد القمم والقيعان (Pivots)
pivotLeft = input.int(5, title="Pivot Lookback Left", minval=1)
pivotRight = input.int(5, title="Pivot Lookback Right", minval=1)
// --- 2. حساب مؤشر القوة النسبية (RSI Calculation) ---
rsi = ta.rsi(close, rsiLength)
// --- 3. تلوين الشموع حسب الزخم (RSI Momentum Color) ---
// فحص: هل RSI الحالي أكبر من RSI السابق؟
isRSIUp = rsi > rsi[1]
// تحديد اللون بناءً على الشرط
var color colorRSI = na
// تلوين الشمعة باللون الأخضر إذا كان RSI صاعداً، وبالأحمر إذا كان هابطاً
if isRSIUp
colorRSI := color.new(color.green, 60) // أخضر فاتح
else
colorRSI := color.new(color.red, 60) // أحمر فاتح
// تطبيق تلوين الشمعة على الشارت الرئيسي
barcolor(colorRSI)
// --- 4. تحديد الدايفرجنس (Divergence Detection) ---
// تحديد القمم والقيعان على السعر
price_high_pivot = ta.pivothigh(high, pivotLeft, pivotRight)
price_low_pivot = ta.pivotlow(low, pivotLeft, pivotRight)
// تحديد القمم والقيعان على RSI
rsi_high_pivot = ta.pivothigh(rsi, pivotLeft, pivotRight)
rsi_low_pivot = ta.pivotlow(rsi, pivotLeft, pivotRight)
// *** المنطق المباشر للدايفرجنس (تظهر الإشارة عند القمة/القاع المكتملة) ***
// 🔵 الدايفرجنس العادي الصعودي (Regular Bullish Div)
isRegBull = price_low_pivot and rsi_low_pivot and low < low[pivotRight] and rsi > rsi[pivotRight]
// 🔴 الدايفرجنس العادي الهبوطي (Regular Bearish Div)
isRegBear = price_high_pivot and rsi_high_pivot and high > high[pivotRight] and rsi < rsi[pivotRight]
// 🟪 الدايفرجنس المخفي الصعودي (Hidden Bullish Div)
isHiddenBull = price_low_pivot and rsi_low_pivot and low > low[pivotRight] and rsi < rsi[pivotRight]
// 🟧 الدايفرجنس المخفي الهبوطي (Hidden Bearish Div)
isHiddenBear = price_high_pivot and rsi_high_pivot and high < high[pivotRight] and rsi > rsi[pivotRight]
// --- 5. رسم إشارات الدايفرجنس على السعر (Plotting Shapes) ---
// رسم الإشارات على الشارت الرئيسي (لتحديد مناطق الانعكاس/الاستمرار)
// 1. عادي صعودي (انعكاس)
plotshape(isRegBull, title="Regular Bullish Div", location=location.belowbar, style=shape.triangleup, color=color.green, size=size.small)
// 2. عادي هبوطي (انعكاس)
plotshape(isRegBear, title="Regular Bearish Div", location=location.abovebar, style=shape.triangledown, color=color.red, size=size.small)
// 3. مخفي صعودي (استمرار)
plotshape(isHiddenBull, title="Hidden Bullish Div", location=location.belowbar, style=shape.diamond, color=color.blue, size=size.small)
// 4. مخفي هبوطي (استمرار)
plotshape(isHiddenBear, title="Hidden Bearish Div", location=location.abovebar, style=shape.diamond, color=color.orange, size=size.small)
// --- 6. عرض مؤشر RSI في نافذة فرعية (Sub-Window) ---
// يجب إضافة مؤشر RSI بشكل منفصل لترى الدايفرجنس على منحنى RSI
// لكي تظهر الخطوط على منحنى RSI، يجب عليك إضافة كود المؤشر السابق (RSI Divergence Detector (Full))
// على نافذة RSI، ولكن هذا يتعارض مع طلبك دمج كل شيء.
// أفضل طريقة هي: قم بإضافة هذا المؤشر إلى الشارت، ثم أضف مؤشر RSI الافتراضي إلى نافذة جديدة.
// أو يمكنك إنشاء مؤشر RSI منفصل خاص بك في نافذة فرعية:
plot(rsi, title="RSI Value", color=color.rgb(100, 150, 200), display=display.none) // لا تعرض في الشارت الرئيسي
// لعرض RSI في نافذة فرعية، قم بإنشاء مؤشر جديد واضبط overlay=false
// أو استخدم المؤشر التالي (بما أن هذا المؤشر يحتوي على overlay=true، لن يرسم RSI أسفل الشارت).
// --- ملاحظة أخيرة: لرسم الخطوط على RSI أسفل الشارت ---
// لتحقيق ذلك بالضبط، يجب كتابة مؤشر ثانٍ بـ (overlay=false)
// يحتوي على نفس منطق الدايفرجنس. لتجنب ذلك، يكتفي هذا الكود برسم الإشارات
// على السعر (overlay=true) وتلوين الشموع.
// هذا مؤشر موحد يحدد الدايفرجنس (العادي والمخفي) ويقوم بتلوين الشموع حسب زخم RSI.
indicator(title="RSI Divergence & Momentum Color", shorttitle="RSI Divergence & MOM", overlay=true)
// --- 1. الإعدادات والمتغيرات (Inputs) ---
// إعدادات RSI
rsiLength = input.int(14, title="RSI Length", minval=1)
// إعدادات تحديد القمم والقيعان (Pivots)
pivotLeft = input.int(5, title="Pivot Lookback Left", minval=1)
pivotRight = input.int(5, title="Pivot Lookback Right", minval=1)
// --- 2. حساب مؤشر القوة النسبية (RSI Calculation) ---
rsi = ta.rsi(close, rsiLength)
// --- 3. تلوين الشموع حسب الزخم (RSI Momentum Color) ---
// فحص: هل RSI الحالي أكبر من RSI السابق؟
isRSIUp = rsi > rsi[1]
// تحديد اللون بناءً على الشرط
var color colorRSI = na
// تلوين الشمعة باللون الأخضر إذا كان RSI صاعداً، وبالأحمر إذا كان هابطاً
if isRSIUp
colorRSI := color.new(color.green, 60) // أخضر فاتح
else
colorRSI := color.new(color.red, 60) // أحمر فاتح
// تطبيق تلوين الشمعة على الشارت الرئيسي
barcolor(colorRSI)
// --- 4. تحديد الدايفرجنس (Divergence Detection) ---
// تحديد القمم والقيعان على السعر
price_high_pivot = ta.pivothigh(high, pivotLeft, pivotRight)
price_low_pivot = ta.pivotlow(low, pivotLeft, pivotRight)
// تحديد القمم والقيعان على RSI
rsi_high_pivot = ta.pivothigh(rsi, pivotLeft, pivotRight)
rsi_low_pivot = ta.pivotlow(rsi, pivotLeft, pivotRight)
// *** المنطق المباشر للدايفرجنس (تظهر الإشارة عند القمة/القاع المكتملة) ***
// 🔵 الدايفرجنس العادي الصعودي (Regular Bullish Div)
isRegBull = price_low_pivot and rsi_low_pivot and low < low[pivotRight] and rsi > rsi[pivotRight]
// 🔴 الدايفرجنس العادي الهبوطي (Regular Bearish Div)
isRegBear = price_high_pivot and rsi_high_pivot and high > high[pivotRight] and rsi < rsi[pivotRight]
// 🟪 الدايفرجنس المخفي الصعودي (Hidden Bullish Div)
isHiddenBull = price_low_pivot and rsi_low_pivot and low > low[pivotRight] and rsi < rsi[pivotRight]
// 🟧 الدايفرجنس المخفي الهبوطي (Hidden Bearish Div)
isHiddenBear = price_high_pivot and rsi_high_pivot and high < high[pivotRight] and rsi > rsi[pivotRight]
// --- 5. رسم إشارات الدايفرجنس على السعر (Plotting Shapes) ---
// رسم الإشارات على الشارت الرئيسي (لتحديد مناطق الانعكاس/الاستمرار)
// 1. عادي صعودي (انعكاس)
plotshape(isRegBull, title="Regular Bullish Div", location=location.belowbar, style=shape.triangleup, color=color.green, size=size.small)
// 2. عادي هبوطي (انعكاس)
plotshape(isRegBear, title="Regular Bearish Div", location=location.abovebar, style=shape.triangledown, color=color.red, size=size.small)
// 3. مخفي صعودي (استمرار)
plotshape(isHiddenBull, title="Hidden Bullish Div", location=location.belowbar, style=shape.diamond, color=color.blue, size=size.small)
// 4. مخفي هبوطي (استمرار)
plotshape(isHiddenBear, title="Hidden Bearish Div", location=location.abovebar, style=shape.diamond, color=color.orange, size=size.small)
// --- 6. عرض مؤشر RSI في نافذة فرعية (Sub-Window) ---
// يجب إضافة مؤشر RSI بشكل منفصل لترى الدايفرجنس على منحنى RSI
// لكي تظهر الخطوط على منحنى RSI، يجب عليك إضافة كود المؤشر السابق (RSI Divergence Detector (Full))
// على نافذة RSI، ولكن هذا يتعارض مع طلبك دمج كل شيء.
// أفضل طريقة هي: قم بإضافة هذا المؤشر إلى الشارت، ثم أضف مؤشر RSI الافتراضي إلى نافذة جديدة.
// أو يمكنك إنشاء مؤشر RSI منفصل خاص بك في نافذة فرعية:
plot(rsi, title="RSI Value", color=color.rgb(100, 150, 200), display=display.none) // لا تعرض في الشارت الرئيسي
// لعرض RSI في نافذة فرعية، قم بإنشاء مؤشر جديد واضبط overlay=false
// أو استخدم المؤشر التالي (بما أن هذا المؤشر يحتوي على overlay=true، لن يرسم RSI أسفل الشارت).
// --- ملاحظة أخيرة: لرسم الخطوط على RSI أسفل الشارت ---
// لتحقيق ذلك بالضبط، يجب كتابة مؤشر ثانٍ بـ (overlay=false)
// يحتوي على نفس منطق الدايفرجنس. لتجنب ذلك، يكتفي هذا الكود برسم الإشارات
// على السعر (overlay=true) وتلوين الشموع.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.