OPEN-SOURCE SCRIPT
Confirmed Entry Grid Pro

//version=5
indicator("Confirmed Entry Grid Pro", overlay=true)
// === المتوسطات ===
ma9 = ta.sma(close, 9)
ma21 = ta.sma(close, 21)
ma200 = ta.sma(close, 200)
// === الاتجاه ===
trendBull = close > ma200
trendBear = close < ma200
// === الزخم ===
rsi = ta.rsi(close, 14)
rsiBull = rsi > 50
rsiBear = rsi < 50
// === الحجم ===
volMA = ta.sma(volume, 20)
volHigh = volume > volMA
// === شموع ابتلاعية ===
bullEngulf = close > open and open < close[1] and close > open[1]
bearEngulf = close < open and open > close[1] and close < open[1]
// === بولنجر باند ===
basis = ta.sma(close, 20)
dev = ta.stdev(close, 20)
upper = basis + 2 * dev
lower = basis - 2 * dev
bbBreakUp = close > upper
bbBreakDown = close < lower
// === دعم / مقاومة ديناميكية ===
support = ta.lowest(low, 20)
resistance = ta.highest(high, 20)
nearSupport = math.abs(close - support) / close < 0.015
nearResistance = math.abs(close - resistance) / close < 0.015
// === تقاطع المتوسطات ===
crossUp = ta.crossover(ma9, ma21)
crossDown = ta.crossunder(ma9, ma21)
// === ATR ===
atr = ta.atr(14)
atrActive = atr > ta.sma(atr, 14)
// === SMC: BOS + CHOCH ===
bosUp = high > high[1] and low > low[1]
bosDown = low < low[1] and high < high[1]
chochUp = close > high[2] and close[1] < high[2]
chochDown = close < low[2] and close[1] > low[2]
smcBuy = bosUp and chochUp
smcSell = bosDown and chochDown
// === مناطق السيولة ===
liqHigh = ta.highest(high, 30)[1]
liqLow = ta.lowest(low, 30)[1]
liquidityBuyZone = close < liqLow
liquiditySellZone = close > liqHigh
// === حساب النقاط لكل صفقة ===
buyScore = (trendBull ? 1 : 0) + (rsiBull ? 1 : 0) + (volHigh ? 1 : 0) + (bullEngulf ? 1 : 0) + (smcBuy ? 1 : 0) + (bbBreakUp ? 1 : 0) + (nearSupport ? 1 : 0) + (crossUp ? 1 : 0) + (atrActive ? 1 : 0) + (liquidityBuyZone ? 1 : 0)
sellScore = (trendBear ? 1 : 0) + (rsiBear ? 1 : 0) + (volHigh ? 1 : 0) + (bearEngulf ? 1 : 0) + (smcSell ? 1 : 0) + (bbBreakDown ? 1 : 0) + (nearResistance ? 1 : 0) + (crossDown ? 1 : 0) + (atrActive ? 1 : 0) + (liquiditySellZone ? 1 : 0)
// === شروط الإشارات مع منع التكرار خلال آخر 5 شموع ===
var int lastBuyBar = na
var int lastSellBar = na
canBuy = buyScore >= 5 and (na(lastBuyBar) or bar_index - lastBuyBar > 5)
canSell = sellScore >= 5 and (na(lastSellBar) or bar_index - lastSellBar > 5)
if canBuy
lastBuyBar := bar_index
if canSell
lastSellBar := bar_index
showBuy = canBuy
showSell = canSell
// === طول الخطوط ===
var int lineLen = 5
// === رسم الإشارات ===
plotshape(showBuy, title="BUY", location=location.belowbar, style=shape.triangleup, size=size.small, color=color.green)
plotshape(showSell, title="SELL", location=location.abovebar, style=shape.triangledown, size=size.small, color=color.red)
// === خطوط الصفقة ===
var line[] buyLines = array.new_line(0)
var line[] sellLines = array.new_line(0)
if (showBuy)
entry = low
label.new(bar_index, entry, "Entry\n" + str.tostring(entry, format.mintick), style=label.style_label_left, textcolor=color.white, size=size.normal)
tpLevels = array.new_float(5)
array.set(tpLevels, 0, 0.618)
array.set(tpLevels, 1, 1.0)
array.set(tpLevels, 2, 1.272)
array.set(tpLevels, 3, 1.618)
array.set(tpLevels, 4, 2.0)
slLevel = -0.618
for i = 0 to 4
fibLabel = "TP" + str.tostring(i + 1) + " - Fib " + str.tostring(array.get(tpLevels, i))
tp = entry + array.get(tpLevels, i) * atr
line = line.new(bar_index, tp, bar_index + lineLen, tp, color=color.green)
label.new(bar_index + lineLen, tp, fibLabel + " (TP" + str.tostring(i + 1) + ")\n" + str.tostring(tp, format.mintick), style=label.style_label_right, textcolor=color.lime, size=size.normal)
array.push(buyLines, line)
sl = entry + slLevel * atr
slLine = line.new(bar_index, sl, bar_index + lineLen, sl, color=color.red)
label.new(bar_index + lineLen, sl, "SL\n" + str.tostring(sl, format.mintick), style=label.style_label_right, textcolor=color.red, size=size.normal)
array.push(buyLines, slLine)
if (showSell)
entry = high
label.new(bar_index, entry, "Entry\n" + str.tostring(entry, format.mintick), style=label.style_label_left, textcolor=color.white, size=size.normal)
tpLevels = array.new_float(5)
array.set(tpLevels, 0, -0.618)
array.set(tpLevels, 1, -1.0)
array.set(tpLevels, 2, -1.272)
array.set(tpLevels, 3, -1.618)
array.set(tpLevels, 4, -2.0)
slLevel = 0.618
for i = 0 to 4
fibLabel = "TP" + str.tostring(i + 1) + " - Fib " + str.tostring(math.abs(array.get(tpLevels, i)))
tp = entry + array.get(tpLevels, i) * atr
line = line.new(bar_index, tp, bar_index + lineLen, tp, color=color.green)
label.new(bar_index + lineLen, tp, fibLabel + " (TP" + str.tostring(i + 1) + ")\n" + str.tostring(tp, format.mintick), style=label.style_label_right, textcolor=color.green, size=size.normal)
array.push(sellLines, line)
sl = entry + slLevel * atr
slLine = line.new(bar_index, sl, bar_index + lineLen, sl, color=color.red)
label.new(bar_index + lineLen, sl, "SL\n" + str.tostring(sl, format.mintick), style=label.style_label_right, textcolor=color.red, size=size.normal)
array.push(sellLines, slLine)
// === متابعة نتائج الصفقة ===
// تحقق نجاح الصفقة (وصل أول TP)
buyHitTP = showBuy and high >= low + 0.618 * atr
sellHitTP = showSell and low <= high - 0.618 * atr
// تحقق فشل الصفقة (ضرب SL)
buyHitSL = showBuy and low <= low - 0.618 * atr
sellHitSL = showSell and high >= high + 0.618 * atr
// رسم الإشارة
plotshape(buyHitTP, title="Buy Success", style=shape.labelup, location=location.abovebar, color=color.green, size=size.small)
plotshape(sellHitTP, title="Sell Success", style=shape.labelup, location=location.abovebar, color=color.green, size=size.small)
plotshape(buyHitSL, title="Buy Failed", style=shape.labeldown, location=location.abovebar, color=color.red, size=size.small)
plotshape(sellHitSL, title="Sell Failed", style=shape.labeldown, location=location.abovebar, color=color.red, size=size.small)
indicator("Confirmed Entry Grid Pro", overlay=true)
// === المتوسطات ===
ma9 = ta.sma(close, 9)
ma21 = ta.sma(close, 21)
ma200 = ta.sma(close, 200)
// === الاتجاه ===
trendBull = close > ma200
trendBear = close < ma200
// === الزخم ===
rsi = ta.rsi(close, 14)
rsiBull = rsi > 50
rsiBear = rsi < 50
// === الحجم ===
volMA = ta.sma(volume, 20)
volHigh = volume > volMA
// === شموع ابتلاعية ===
bullEngulf = close > open and open < close[1] and close > open[1]
bearEngulf = close < open and open > close[1] and close < open[1]
// === بولنجر باند ===
basis = ta.sma(close, 20)
dev = ta.stdev(close, 20)
upper = basis + 2 * dev
lower = basis - 2 * dev
bbBreakUp = close > upper
bbBreakDown = close < lower
// === دعم / مقاومة ديناميكية ===
support = ta.lowest(low, 20)
resistance = ta.highest(high, 20)
nearSupport = math.abs(close - support) / close < 0.015
nearResistance = math.abs(close - resistance) / close < 0.015
// === تقاطع المتوسطات ===
crossUp = ta.crossover(ma9, ma21)
crossDown = ta.crossunder(ma9, ma21)
// === ATR ===
atr = ta.atr(14)
atrActive = atr > ta.sma(atr, 14)
// === SMC: BOS + CHOCH ===
bosUp = high > high[1] and low > low[1]
bosDown = low < low[1] and high < high[1]
chochUp = close > high[2] and close[1] < high[2]
chochDown = close < low[2] and close[1] > low[2]
smcBuy = bosUp and chochUp
smcSell = bosDown and chochDown
// === مناطق السيولة ===
liqHigh = ta.highest(high, 30)[1]
liqLow = ta.lowest(low, 30)[1]
liquidityBuyZone = close < liqLow
liquiditySellZone = close > liqHigh
// === حساب النقاط لكل صفقة ===
buyScore = (trendBull ? 1 : 0) + (rsiBull ? 1 : 0) + (volHigh ? 1 : 0) + (bullEngulf ? 1 : 0) + (smcBuy ? 1 : 0) + (bbBreakUp ? 1 : 0) + (nearSupport ? 1 : 0) + (crossUp ? 1 : 0) + (atrActive ? 1 : 0) + (liquidityBuyZone ? 1 : 0)
sellScore = (trendBear ? 1 : 0) + (rsiBear ? 1 : 0) + (volHigh ? 1 : 0) + (bearEngulf ? 1 : 0) + (smcSell ? 1 : 0) + (bbBreakDown ? 1 : 0) + (nearResistance ? 1 : 0) + (crossDown ? 1 : 0) + (atrActive ? 1 : 0) + (liquiditySellZone ? 1 : 0)
// === شروط الإشارات مع منع التكرار خلال آخر 5 شموع ===
var int lastBuyBar = na
var int lastSellBar = na
canBuy = buyScore >= 5 and (na(lastBuyBar) or bar_index - lastBuyBar > 5)
canSell = sellScore >= 5 and (na(lastSellBar) or bar_index - lastSellBar > 5)
if canBuy
lastBuyBar := bar_index
if canSell
lastSellBar := bar_index
showBuy = canBuy
showSell = canSell
// === طول الخطوط ===
var int lineLen = 5
// === رسم الإشارات ===
plotshape(showBuy, title="BUY", location=location.belowbar, style=shape.triangleup, size=size.small, color=color.green)
plotshape(showSell, title="SELL", location=location.abovebar, style=shape.triangledown, size=size.small, color=color.red)
// === خطوط الصفقة ===
var line[] buyLines = array.new_line(0)
var line[] sellLines = array.new_line(0)
if (showBuy)
entry = low
label.new(bar_index, entry, "Entry\n" + str.tostring(entry, format.mintick), style=label.style_label_left, textcolor=color.white, size=size.normal)
tpLevels = array.new_float(5)
array.set(tpLevels, 0, 0.618)
array.set(tpLevels, 1, 1.0)
array.set(tpLevels, 2, 1.272)
array.set(tpLevels, 3, 1.618)
array.set(tpLevels, 4, 2.0)
slLevel = -0.618
for i = 0 to 4
fibLabel = "TP" + str.tostring(i + 1) + " - Fib " + str.tostring(array.get(tpLevels, i))
tp = entry + array.get(tpLevels, i) * atr
line = line.new(bar_index, tp, bar_index + lineLen, tp, color=color.green)
label.new(bar_index + lineLen, tp, fibLabel + " (TP" + str.tostring(i + 1) + ")\n" + str.tostring(tp, format.mintick), style=label.style_label_right, textcolor=color.lime, size=size.normal)
array.push(buyLines, line)
sl = entry + slLevel * atr
slLine = line.new(bar_index, sl, bar_index + lineLen, sl, color=color.red)
label.new(bar_index + lineLen, sl, "SL\n" + str.tostring(sl, format.mintick), style=label.style_label_right, textcolor=color.red, size=size.normal)
array.push(buyLines, slLine)
if (showSell)
entry = high
label.new(bar_index, entry, "Entry\n" + str.tostring(entry, format.mintick), style=label.style_label_left, textcolor=color.white, size=size.normal)
tpLevels = array.new_float(5)
array.set(tpLevels, 0, -0.618)
array.set(tpLevels, 1, -1.0)
array.set(tpLevels, 2, -1.272)
array.set(tpLevels, 3, -1.618)
array.set(tpLevels, 4, -2.0)
slLevel = 0.618
for i = 0 to 4
fibLabel = "TP" + str.tostring(i + 1) + " - Fib " + str.tostring(math.abs(array.get(tpLevels, i)))
tp = entry + array.get(tpLevels, i) * atr
line = line.new(bar_index, tp, bar_index + lineLen, tp, color=color.green)
label.new(bar_index + lineLen, tp, fibLabel + " (TP" + str.tostring(i + 1) + ")\n" + str.tostring(tp, format.mintick), style=label.style_label_right, textcolor=color.green, size=size.normal)
array.push(sellLines, line)
sl = entry + slLevel * atr
slLine = line.new(bar_index, sl, bar_index + lineLen, sl, color=color.red)
label.new(bar_index + lineLen, sl, "SL\n" + str.tostring(sl, format.mintick), style=label.style_label_right, textcolor=color.red, size=size.normal)
array.push(sellLines, slLine)
// === متابعة نتائج الصفقة ===
// تحقق نجاح الصفقة (وصل أول TP)
buyHitTP = showBuy and high >= low + 0.618 * atr
sellHitTP = showSell and low <= high - 0.618 * atr
// تحقق فشل الصفقة (ضرب SL)
buyHitSL = showBuy and low <= low - 0.618 * atr
sellHitSL = showSell and high >= high + 0.618 * atr
// رسم الإشارة
plotshape(buyHitTP, title="Buy Success", style=shape.labelup, location=location.abovebar, color=color.green, size=size.small)
plotshape(sellHitTP, title="Sell Success", style=shape.labelup, location=location.abovebar, color=color.green, size=size.small)
plotshape(buyHitSL, title="Buy Failed", style=shape.labeldown, location=location.abovebar, color=color.red, size=size.small)
plotshape(sellHitSL, title="Sell Failed", style=shape.labeldown, location=location.abovebar, color=color.red, size=size.small)
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
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.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
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.