OPEN-SOURCE SCRIPT
Pro Trend Buy/Sell/Exit [Copilot]

//version=5
indicator("Pro Trend Buy/Sell/Exit [Copilot]", overlay=true, max_labels_count=500)
// إعدادات قابلة للتخصيص
emaLength = input.int(55, "EMA Length")
rsiLength = input.int(14, "RSI Length")
rsiOverbought = input.float(70, "RSI Overbought")
rsiOversold = input.float(30, "RSI Oversold")
macdFastLen = input.int(12, "MACD Fast Length")
macdSlowLen = input.int(26, "MACD Slow Length")
macdSignalLen = input.int(9, "MACD Signal Length")
supertrendFactor = input.float(3, "Supertrend Factor")
supertrendATRlen = input.int(10, "Supertrend ATR Length")
showBuySellLabels = input.bool(true, "Show Buy/Sell Labels")
showExitLabels = input.bool(true, "Show Exit Labels")
// المؤشرات
ema = ta.ema(close, emaLength)
rsi = ta.rsi(close, rsiLength)
macdLine = ta.ema(close, macdFastLen) - ta.ema(close, macdSlowLen)
macdSignal = ta.ema(macdLine, macdSignalLen)
[supertrend, direction] = ta.supertrend(supertrendFactor, supertrendATRlen)
// حساب DMI (بديل ADX)
len = input.int(14, "DMI Length")
up = ta.change(high)
down = -ta.change(low)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
trur = ta.rma(ta.tr, len)
plusDI = 100 * ta.rma(plusDM, len) / trur
minusDI = 100 * ta.rma(minusDM, len) / trur
adx = ta.rma(math.abs(plusDI - minusDI) / (plusDI + minusDI) * 100, len)
// شروط الترند
trendUp = close > ema and adx > 25 and macdLine > macdSignal and direction == 1
trendDown = close < ema and adx > 25 and macdLine < macdSignal and direction == -1
// إشارات الدخول
buySignal = trendUp and ta.crossover(macdLine, macdSignal) and rsi > rsiOversold
sellSignal = trendDown and ta.crossunder(macdLine, macdSignal) and rsi < rsiOverbought
// إشارات الخروج
exitLong = buySignal[1] and (ta.crossunder(close, ema) or adx < 20 or ta.crossunder(rsi, 50) or direction == -1)
exitShort = sellSignal[1] and (ta.crossover(close, ema) or adx < 20 or ta.crossover(rsi, 50) or direction == 1)
// رسم الإشارات على الرسم البياني
plotshape(buySignal and showBuySellLabels, style=shape.labelup, location=location.belowbar, color=color.green, text="BUY", size=size.large)
plotshape(sellSignal and showBuySellLabels, style=shape.labeldown, location=location.abovebar, color=color.red, text="SELL", size=size.large)
plotshape(exitLong and showExitLabels, style=shape.xcross, location=location.abovebar, color=color.orange, text="Exit Long", size=size.large)
plotshape(exitShort and showExitLabels, style=shape.xcross, location=location.belowbar, color=color.purple, text="Exit Short", size=size.large)
// إشعارات للبوت
alertcondition(buySignal, title="Buy Signal", message="BUY Signal on {{ticker}} at {{close}}")
alertcondition(sellSignal, title="Sell Signal", message="SELL Signal on {{ticker}} at {{close}}")
alertcondition(exitLong, title="Exit Long", message="EXIT LONG on {{ticker}} at {{close}}")
alertcondition(exitShort, title="Exit Short", message="EXIT SHORT on {{ticker}} at {{close}}")
indicator("Pro Trend Buy/Sell/Exit [Copilot]", overlay=true, max_labels_count=500)
// إعدادات قابلة للتخصيص
emaLength = input.int(55, "EMA Length")
rsiLength = input.int(14, "RSI Length")
rsiOverbought = input.float(70, "RSI Overbought")
rsiOversold = input.float(30, "RSI Oversold")
macdFastLen = input.int(12, "MACD Fast Length")
macdSlowLen = input.int(26, "MACD Slow Length")
macdSignalLen = input.int(9, "MACD Signal Length")
supertrendFactor = input.float(3, "Supertrend Factor")
supertrendATRlen = input.int(10, "Supertrend ATR Length")
showBuySellLabels = input.bool(true, "Show Buy/Sell Labels")
showExitLabels = input.bool(true, "Show Exit Labels")
// المؤشرات
ema = ta.ema(close, emaLength)
rsi = ta.rsi(close, rsiLength)
macdLine = ta.ema(close, macdFastLen) - ta.ema(close, macdSlowLen)
macdSignal = ta.ema(macdLine, macdSignalLen)
[supertrend, direction] = ta.supertrend(supertrendFactor, supertrendATRlen)
// حساب DMI (بديل ADX)
len = input.int(14, "DMI Length")
up = ta.change(high)
down = -ta.change(low)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
trur = ta.rma(ta.tr, len)
plusDI = 100 * ta.rma(plusDM, len) / trur
minusDI = 100 * ta.rma(minusDM, len) / trur
adx = ta.rma(math.abs(plusDI - minusDI) / (plusDI + minusDI) * 100, len)
// شروط الترند
trendUp = close > ema and adx > 25 and macdLine > macdSignal and direction == 1
trendDown = close < ema and adx > 25 and macdLine < macdSignal and direction == -1
// إشارات الدخول
buySignal = trendUp and ta.crossover(macdLine, macdSignal) and rsi > rsiOversold
sellSignal = trendDown and ta.crossunder(macdLine, macdSignal) and rsi < rsiOverbought
// إشارات الخروج
exitLong = buySignal[1] and (ta.crossunder(close, ema) or adx < 20 or ta.crossunder(rsi, 50) or direction == -1)
exitShort = sellSignal[1] and (ta.crossover(close, ema) or adx < 20 or ta.crossover(rsi, 50) or direction == 1)
// رسم الإشارات على الرسم البياني
plotshape(buySignal and showBuySellLabels, style=shape.labelup, location=location.belowbar, color=color.green, text="BUY", size=size.large)
plotshape(sellSignal and showBuySellLabels, style=shape.labeldown, location=location.abovebar, color=color.red, text="SELL", size=size.large)
plotshape(exitLong and showExitLabels, style=shape.xcross, location=location.abovebar, color=color.orange, text="Exit Long", size=size.large)
plotshape(exitShort and showExitLabels, style=shape.xcross, location=location.belowbar, color=color.purple, text="Exit Short", size=size.large)
// إشعارات للبوت
alertcondition(buySignal, title="Buy Signal", message="BUY Signal on {{ticker}} at {{close}}")
alertcondition(sellSignal, title="Sell Signal", message="SELL Signal on {{ticker}} at {{close}}")
alertcondition(exitLong, title="Exit Long", message="EXIT LONG on {{ticker}} at {{close}}")
alertcondition(exitShort, title="Exit Short", message="EXIT SHORT on {{ticker}} at {{close}}")
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。