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}}")
Script open-source
Dans l'esprit de TradingView, le créateur de ce script l'a rendu open-source, afin que les traders puissent examiner et vérifier sa fonctionnalité. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script open-source
Dans l'esprit de TradingView, le créateur de ce script l'a rendu open-source, afin que les traders puissent examiner et vérifier sa fonctionnalité. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.