//version=5 indicator("MOATH EMAD", overlay=true) enableIndicator = input.bool(true, title="تشغيل EMA") enableIndicator2 = input.bool(true, title="تشغيل RSI") // حساب EMA 200 ema200 = ta.ema(close, 200) rsi = request.security(syminfo.tickerid, "5", ta.rsi(close, 14)) // المسافة المطلوبة بين الافتتاح والـ EMA pointDistance = 2 // عدّلها حسب السوق (مثلاً 0.2 للعملات الرقمية)
// التحقق من الشرط isAbove = open > ema200 + pointDistance isBelow = open < ema200 - pointDistance
// تحديد اللون بناءً على الشرط
// رسم EMA 200
plotrealclosedots = input(true, title = 'Show real close dots') realclosecolour = input(color.new(#41ffb0, 1), title = 'Real close dot color') // بدون شفافية
// رسم النقاط باستخدام plot مع تكبير النقطة plot(series = plotrealclosedots ? real_close : na, title = 'Real close dots', color = realclosecolour, linewidth = 3, // زيادة حجم النقطة style = plot.style_circles)
// Input variables lowhigh_long_prop = input.float(10, title="Low / High Proportion") body_prop_size = input.float(7, title="Body Proportion Size") waveLength = input(6, title="Minimum Wave Length") // Number of candles required to determine wave colorUp = color.new(color.green, 100) // Bullish wave color colorDown = color.new(color.red, 100) // Bearish wave color dojiBoxColor = color.new(color.yellow, 90) // Doji box color defineDojiExtension = 6 // Number of candles to extend the doji box
// Bar calculations bar_size_h = high - close bar_size_l = math.max(open, close) - math.min(close, open) body_size_h = high - low
low_body_prop = close - low high_body_prop = high - close
// حساب خصائص الشمعة upper_tail = high - math.max(open, close) // طول الذيل العلوي lower_tail = math.min(open, close) - low // طول الذيل السفلي total_tails = upper_tail + lower_tail // مجموع الذيول
// نسبة كل ذيل بالنسبة إلى مجموع الذيول upper_tail_ratio = (upper_tail / total_tails) * 100 lower_tail_ratio = (lower_tail / total_tails) * 100
// Wave Detection isBullish = close > open isBearish = close < open bullishStreak = ta.barssince(not isBullish) bearishStreak = ta.barssince(not isBearish) isWaveUp = isBullish and bullishStreak >= waveLength - 1 isWaveDown = isBearish and bearishStreak >= waveLength - 1
// شرط شمعة التوقف (الذيل الحالي أصغر من الذيل السابق في الاتجاه الصاعد أو أكبر في الاتجاه الهابط) previous_upper_tail = high[3] previous_lower_tail = low[3]
is_stop_candle_up = isWaveUp[1] and (high[2] < high[3] or high[3] < high[4] )// شمعة توقف في الاتجاه الصاعد is_stop_candle_down = isWaveDown[1] and (low[2] > low[3] or low[3] > low[4]) // شمعة توقف في الاتجاه الهابط
// Boxes for waves var box bullishBox = na var box bearishBox = na
if isWaveUp if na(bullishBox) bullishBox := box.new(bar_index[bullishStreak], high[bullishStreak], bar_index, low, border_color=na, bgcolor=colorUp) else box.set_right(bullishBox, bar_index) box.set_top(bullishBox, math.max(box.get_top(bullishBox), high)) box.set_bottom(bullishBox, math.min(box.get_bottom(bullishBox), low)) if not isWaveUp and not na(bullishBox) bullishBox := na
if isWaveDown if na(bearishBox) bearishBox := box.new(bar_index[bearishStreak], high[bearishStreak], bar_index, low, border_color=na, bgcolor=colorDown) else box.set_right(bearishBox, bar_index) box.set_top(bearishBox, math.max(box.get_top(bearishBox), high)) box.set_bottom(bearishBox, math.min(box.get_bottom(bearishBox), low)) if not isWaveDown and not na(bearishBox) bearishBox := na
// Doji Box Conditions isDoji = (upper_tail_ratio >= 40 and upper_tail_ratio <= 60) and (lower_tail_ratio >= 40 and lower_tail_ratio <= 60)
// خطوط الدوجي بناءً على الاتجاه السابق var line dojiLineUp = na var line dojiLineDown = na var int dojiLineUpBarIndex = na var int dojiLineDownBarIndex = na var bool labelPlacedUp = false var bool labelPlacedDown = false var line dojiLineUp2 = na var line dojiLineDown2 = na var int dojiLineUpBarIndex2 = na var int dojiLineDownBarIndex2 = na var bool labelPlacedUp2 = false var bool labelPlacedDown2 = false
if isDoji if isWaveUp[1] // إذا كان الاتجاه السابق صاعدًا dojiLineUp := line.new(bar_index, low, bar_index + defineDojiExtension, low, color=color.white, width=1) line.set_color(dojiLineUp,color.new(color.red,100)) dojiLineUpBarIndex := bar_index labelPlacedUp := false // إعادة تعيين الإشارة للخط الجديد if isWaveDown[1] // إذا كان الاتجاه السابق هابطًا dojiLineDown := line.new(bar_index, high, bar_index + defineDojiExtension, high, color=color.white, width=1) line.set_color(dojiLineDown,color.new(color.red,100)) dojiLineDownBarIndex := bar_index labelPlacedDown := false // إعادة تعيين الإشارة للخط الجديد
if isDoji if isWaveUp[1] // إذا كان الاتجاه السابق صاعدًا dojiLineUp2 := line.new(bar_index, low, bar_index + defineDojiExtension, low, color=color.white, width=1) line.set_color(dojiLineUp2,color.new(color.red,100)) dojiLineUpBarIndex2 := bar_index labelPlacedUp2 := false // إعادة تعيين الإشارة للخط الجديد if isWaveDown[1] // إذا كان الاتجاه السابق هابطًا dojiLineDown2 := line.new(bar_index, high, bar_index + defineDojiExtension, high, color=color.white, width=1) line.set_color(dojiLineDown2,color.new(color.red,100)) dojiLineDownBarIndex2 := bar_index labelPlacedDown2 := false // إعادة تعيين الإشارة للخط الجديد
// تحديد الشروط للتلامس مع الخطوط touchesGreenLine = not na(dojiLineUp) and (low <= line.get_y1(dojiLineUp) and high >= line.get_y1(dojiLineUp)) and (open > line.get_y1(dojiLineUp) and close < line.get_y1(dojiLineUp)) and // تفتح فوق الخط وتغلق تحته (real_close < line.get_y1(dojiLineUp)) and // إضافة شرط السعر الحقيقي تحت الخط الأخضر (bar_index - dojiLineUpBarIndex <= 5) and // فقط خلال 5 شموع not labelPlacedUp and // التأكد من أن الإشارة لم توضع مسبقًا (((close < ema200 - pointDistance)and enableIndicator)or not enableIndicator) and (((rsi >70 )and enableIndicator2)or not enableIndicator2) and not is_stop_candle_up // الشرط الجديد: الشمعة تحت الـ EMA بمقدار نقطتين
touchesRedLine = not na(dojiLineDown) and (low <= line.get_y1(dojiLineDown) and high >= line.get_y1(dojiLineDown)) and (open < line.get_y1(dojiLineDown) and close > line.get_y1(dojiLineDown)) and // تفتح تحت الخط وتغلق فوقه (real_close > line.get_y1(dojiLineDown)) and // إضافة شرط السعر الحقيقي فوق الخط الأحمر (bar_index - dojiLineDownBarIndex <= 5) and // فقط خلال 5 شموع not labelPlacedDown and // التأكد من أن الإشارة لم توضع مسبقًا (((close > ema200 + pointDistance)and enableIndicator)or not enableIndicator) and (((rsi<30 )and enableIndicator2)or not enableIndicator2) and not is_stop_candle_down // الشرط الجديد: الشمعة فوق الـ EMA بمقدار نقطتين
// تحديد الشروط للتلامس مع الخطوط touchesGreenLine2 = not na(dojiLineUp2) and (low <= line.get_y1(dojiLineUp2) and high >= line.get_y1(dojiLineUp2)) and (open > line.get_y1(dojiLineUp2) and close < line.get_y1(dojiLineUp2)) and // تفتح فوق الخط وتغلق تحته (real_close < line.get_y1(dojiLineUp2)) and // إضافة شرط السعر الحقيقي تحت الخط الأخضر (bar_index - dojiLineUpBarIndex2 <= 5) and // فقط خلال 5 شموع not labelPlacedUp and // التأكد من أن الإشارة لم توضع مسبقًا (((close < ema200 - pointDistance)and enableIndicator)or not enableIndicator) and (((rsi >70 )and enableIndicator2)or not enableIndicator2)and is_stop_candle_up // الشرط الجديد: الشمعة تحت الـ EMA بمقدار نقطتين
touchesRedLine2 = not na(dojiLineDown2) and (low <= line.get_y1(dojiLineDown2) and high >= line.get_y1(dojiLineDown2)) and (open < line.get_y1(dojiLineDown2) and close > line.get_y1(dojiLineDown2)) and // تفتح تحت الخط وتغلق فوقه (real_close > line.get_y1(dojiLineDown2)) and // إضافة شرط السعر الحقيقي فوق الخط الأحمر (bar_index - dojiLineDownBarIndex2 <= 5) and // فقط خلال 5 شموع not labelPlacedDown and // التأكد من أن الإشارة لم توضع مسبقًا (((close > ema200 + pointDistance)and enableIndicator)or not enableIndicator) and (((rsi<30 )and enableIndicator2)or not enableIndicator2) and is_stop_candle_down// الشرط الجديد: الشمعة فوق الـ EMA بمقدار نقطتين
if touchesRedLine label.new(bar_index, low, text="Buy", color=color.blue, textcolor=color.white, size=size.small, style=label.style_label_up) labelPlacedDown := true // تم وضع الإشارة if touchesGreenLine2 label.new(bar_index, high, text="Sell", color=color.orange, textcolor=color.white, size=size.small, style=label.style_label_down) labelPlacedUp := true
if touchesRedLine2 label.new(bar_index, low, text="Buy", color=color.blue, textcolor=color.white, size=size.small, style=label.style_label_up) labelPlacedDown := true // تم وضع الإشارة alertcondition(touchesGreenLine or touchesRedLine or touchesGreenLine2 or touchesRedLine2 , title="Buy/Sell Alert", message="Signal detected: Buy or Sell")
In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publications is governed by House rules. 您可以收藏它以在圖表上使用。