الأحد، 12 أكتوبر 2025

ORB Screener

📘 شرح ORB Screener

أداة ORB Screener صُممت لتساعد المتداول في متابعة نطاق الافتتاح (Opening Range Breakout) بطريقة آلية وواضحة، خصوصًا خلال أول ربع ساعة من السوق الأمريكي (من 16:30 إلى 16:45 بتوقيت السعودية).


⚙️ فكرة الأداة

تقوم الأداة بحساب:

  • أعلى وأدنى سعر خلال فترة ORB (نطاق الافتتاح).
  • تُقارن السعر الحالي مع هذا النطاق لتحدد الحالة:
    • 📈 فوق أعلى ORB → السعر اخترق النطاق للأعلى (إشارة صعود محتملة).
    • 📉 تحت أدنى ORB → السعر كسر النطاق للأسفل (إشارة هبوط محتملة).
    • 〰️ بين النطاقين → السعر يتحرك داخل النطاق (منطقة تذبذب).


📊 الفلاتر المستخدمة

كل سهم يتم فحصه بناءً على مجموعة من المؤشرات الفنية:

  • RSI – مؤشر القوة النسبية، يقيس زخم الحركة.
  • VWAP – المتوسط المرجّح بالحجم، يُستخدم لتحديد موقع السعر الحقيقي بالنسبة لحجم التداول.
  • ADX – يقيس قوة الاتجاه الحالي لتصفية الإشارات الضعيفة.
  • MACD Histogram – يوضح التقاطع والزخم السعري.
  • Vol Surge – يكتشف الاندفاع في السيولة مقارنة بمتوسط الحجم.

🧮 Score النهائي

النظام يعطي تقييم رقمي (Score) يجمع كل العوامل السابقة:

  • 75 فأكثر = إشارة قوية (شراء أو بيع)
  • 50 – 74 = منطقة مراقبة
  • أقل من 50 = تجاهل الإشارة

ويظهر التقييم في الجدول بلون:

  • 🟩 أخضر = صفقة قوية
  • 🟧 برتقالي = متوسطة
  • 🟥 أحمر = ضعيفة

📈 طريقة الاستخدام

  1. أضف الكود إلى TradingView كمؤشر جديد.
  2. اختر الفاصل الزمني 1 دقيقة أو 5 دقائق.
  3. فعّل الأداة وقت جلسة الافتتاح لمتابعة اختراق النطاق.
  4. استخدمها مع تأكيداتك الخاصة (Volume – Trend – Zones ...).

💡 ملاحظات

  • الأداة لا تعطي توصيات شراء أو بيع مباشرة، بل تعرض إشارات تحليلية تساعدك في اتخاذ القرار.
  • يمكن تعديل توقيت ORB من الكود حسب السوق أو الجلسة.
//@version=5
indicator("ORB Screener-Multiple Indicators", title="ORB Screener", overlay = true)

inputMax = timeframe.multiplier
tz = input.string("UTC+3", title = "Timezone", group = "Indicator", inline = "Custom", options = ["UTC-10", "UTC-8", "UTC-7", "UTC-6", "UTC-5", "UTC-4", "UTC-3", "UTC+0", "UTC+1", "UTC+2", "UTC+3", "UTC+3:30", "UTC+4", "UTC+5", "UTC+5:30", "UTC+5:45", "UTC+6","UTC+6:30", "UTC+7", "UTC+8", "UTC+9", "UTC+9:30", "UTC+10", "UTC+11", "UTC+12", "UTC+12:45", "UTC+13"])
sess = input.session("1630-1645", title="ORB Session Time", group = "Indicator") 
t = time(timeframe.period, sess + ":1234567")

conf = input.string("CLOSE", "Signal Configure", ["CLOSE", "TOUCH"], group = "Indicator")
// longTrailPerc = input.float(title = "ATR (%)", defval = 0.38, step = 0.1, inline = '1', group = "Indicator") * 0.01
// enable3 = input.bool(true, "", inline = '1', group = "Indicator")
rsi_len = input.int(14, title = "RSI Length", group = "Indicator")
adx_len    = input.int(14,  title="ADX Length", group="Indicator")
adx_thresh = input.float(20, title="ADX Threshold (x)", group="Indicator")
[macdLine, signalLine, hist] = ta.macd(close, 12, 26, 9)
macd_ok = hist > 0 and hist > hist[1]
y_coordinate = input.string(defval="Middle", title="Table Position", options=["Top", "Middle", "Bottom"], inline = 'pos', group = "Indicator")
x_coordinate = input.string(defval="Right", title="", options=["Left", "Center", "Right"], inline = 'pos', group = "Indicator")
size_option = input.string(defval="Small", title="Select Size", options=["Auto", "Huge", "Large", "Normal", "Small", "Tiny"], group = "Indicator")
size = size_option == "Auto" ? size.auto : size_option == "Huge" ? size.huge : size_option == "Large" ? size.large : size_option == " Normal" ? size.normal : size_option == "Small" ? size.small : size_option == "Tiny" ? size.tiny : size.auto

// hide = timeframe.isintraday and timeframe.multiplier <= inputMax
// is_newbar(res) => ta.change(time(res)) != 0
// in_session = not na(t)
// is_first = in_session and not in_session[1]

// orb_high = float(na)
// orb_low = float(na)

// if is_first
//     orb_high := high
//     orb_low := low
// else
//     orb_high := orb_high[1]
//     orb_low := orb_low[1]
// if high > orb_high and in_session
//     orb_high := high
// if low < orb_low and in_session 
//     orb_low := low

// plot(hide and not in_session ? orb_high : na , style=plot.style_circles, color=orb_high[1] != orb_high ? na : color.green, title="ORB High", linewidth=2)
// plot(hide and not in_session ? orb_low : na , style=plot.style_circles, color=orb_low[1] != orb_low ? na : color.red, title="ORB Low", linewidth=2)

// crossOver = ta.crossover(conf == "CLOSE" ? close : high, orb_high)
// crossUnder = ta.crossunder(conf == "CLOSE" ? close : low, orb_low)
// var bflag = false 
// var sflag = false 
// var new_flag = false 
// var long1_bo = false 
// var short1_bo = false 
// if dayofmonth[1] != dayofmonth 
//     bflag := true 
//     sflag := true 
//     new_flag := false 
//     long1_bo := false 
//     short1_bo := false
// if is_first
//     new_flag := true
// if crossOver and bflag and new_flag
//     label.new(bar_index, low - (close * 0.001), "", color = color.green, textcolor = color.white, size = size.large, style = label.style_arrowup)
//     bflag := false 
//     long1_bo := true 
//     short1_bo := false 
// if crossUnder and sflag and new_flag
//     label.new(bar_index, high + (close * 0.001), "", color = color.red, textcolor = color.white, size = size.large, style = label.style_arrowdown)
//     sflag := false
//     long1_bo := false 
//     short1_bo := true  

// shortTrailPerc = longTrailPerc 
// longStopPrice = 0.0, shortStopPrice = 0.0

// longStopPrice := if (long1_bo)
//     stopValue = close[1] * (1 - longTrailPerc)
//     math.max(stopValue, longStopPrice[1]) 
// else
//     0

// shortStopPrice := if (short1_bo)
//     stopValue = close[1] * (1 + shortTrailPerc)
//     math.min(stopValue, shortStopPrice[1])
// else
//     999999

// plot(long1_bo and enable3 ? longStopPrice : na, color = color.green, style = plot.style_linebr)
// plot(short1_bo and enable3 ? shortStopPrice : na, color = color.red, style = plot.style_linebr)

Screener() =>
    t_screener = time(timeframe.period, sess + ":1234567",tz)
    hide_screener = timeframe.isintraday and timeframe.multiplier <= inputMax
    
    in_session_screener = not na(t_screener)
    is_first_screener = in_session_screener and not in_session_screener[1]

    orb_high_screener = float(na)
    orb_low_screener = float(na)

    if is_first_screener
        orb_high_screener := high
        orb_low_screener := low
    else
        orb_high_screener := orb_high_screener[1]
        orb_low_screener := orb_low_screener[1]
    
    if high > orb_high_screener and in_session_screener
        orb_high_screener := high
    if low < orb_low_screener and in_session_screener 
        orb_low_screener := low
    
    crossOver_screener = ta.crossover(conf == "CLOSE" ? close : high, orb_high_screener)
    crossUnder_screener = ta.crossunder(conf == "CLOSE" ? close : low, orb_low_screener)
    var bflag_screener = false 
    var sflag_screener = false 
    var new_flag_screener = false 
    var long1_bo_screener = false 
    var short1_bo_screener = false 

    if dayofmonth[1] != dayofmonth 
        bflag_screener := true 
        sflag_screener := true 
        new_flag_screener := false 
        long1_bo_screener := false 
        short1_bo_screener := false

    if is_first_screener
        new_flag_screener := true
    if crossOver_screener and bflag_screener and new_flag_screener
        bflag_screener := false 
        long1_bo_screener := true 

    if crossUnder_screener and sflag_screener and new_flag_screener
        sflag_screener := false 
        short1_bo_screener := true 

    High = orb_high_screener
    Low = orb_low_screener
    Status = close > High ? "Abv High" : close < Low ? "Blw Low" : "BTW"
    RSI = ta.rsi(close, rsi_len)
    VWAP = ta.vwap        
    fastEMA   = ta.ema(close, 12)
    slowEMA   = ta.ema(close, 26)
    macdLine  = fastEMA - slowEMA
    signalLine= ta.ema(macdLine, 9)
    macdHist  = macdLine - signalLine
    vol_len  = input.int(20,   title="Volume MA Length", group="Indicator")
    vol_mult = input.float(1.5, title="Volume Surge Multiplier", step=0.1, group="Indicator")
    upMove    = high - high[1]
    dnMove    = low[1] - low
    plusDM    = (upMove > dnMove and upMove > 0) ? upMove : 0
    minusDM   = (dnMove > upMove and dnMove > 0) ? dnMove : 0
    atrRMA    = ta.rma(ta.tr, adx_len)
    smPlusDM  = ta.rma(plusDM,    adx_len)
    smMinusDM = ta.rma(minusDM,   adx_len)
    plusDI    = 100 * smPlusDM  / atrRMA
    minusDI   = 100 * smMinusDM / atrRMA
    dx        = 100 * math.abs(plusDI - minusDI) / (plusDI + minusDI)
    adx_val   = ta.rma(dx,       adx_len)
    adx_ok    = adx_val >= adx_thresh
    avg_vol_screener = ta.sma(volume, vol_len)
    vol_ok_screener  = volume >= avg_vol_screener * vol_mult
    score = 0
    score += Status == "Abv High" or Status == "Blw Low" ? 25 : 0
    score += vol_ok_screener ? 20 : 0
    score += adx_ok ? 20 : 0
    score += (Status == "Abv High" and RSI > 50) or (Status == "Blw Low" and RSI < 50) ? 15 : 0
    score += (Status == "Abv High" and close > VWAP) or (Status == "Blw Low" and close < VWAP) ? 10 : 0
    score += macd_ok ? 10 : 0
    bg1 = long1_bo_screener ? color.green : color.gray
    bg2 = short1_bo_screener ? color.red : color.gray
    [ close, High, Low, Status, RSI, VWAP, vol_ok_screener, adx_ok, bg1, bg2, score, macdHist]
 
u01 = input.bool(true, title = "", group = 'Symbols', inline = 's01')
s01 = input.symbol('XAUUSD', group = 'Symbols', inline = 's01')

u02 = input.bool(true, title = "", group = 'Symbols', inline = 's01')
s02 = input.symbol('US100', group = 'Symbols', inline = 's01')

u03 = input.bool(true, title = "", group = 'Symbols', inline = 's02')
s03 = input.symbol('SPX500', group = 'Symbols', inline = 's02')

u04 = input.bool(true, title = "", group = 'Symbols', inline = 's02')
s04 = input.symbol('', group = 'Symbols', inline = 's02')

u05 = input.bool(true, title = "", group = 'Symbols', inline = 's03')
s05 = input.symbol('', group = 'Symbols', inline = 's03')

u06 = input.bool(true, title = "", group = 'Symbols', inline = 's03')
s06 = input.symbol('', group = 'Symbols', inline = 's03')

u07 = input.bool(true, title = "", group = 'Symbols', inline = 's04')
s07 = input.symbol('', group = 'Symbols', inline = 's04')

u08 = input.bool(true, title = "", group = 'Symbols', inline = 's04')
s08 = input.symbol('', group = 'Symbols', inline = 's04')

u09 = input.bool(true, title = "", group = 'Symbols', inline = 's05')
s09 = input.symbol('', group = 'Symbols', inline = 's05')

u10 = input.bool(true, title = "", group = 'Symbols', inline = 's05')
s10 = input.symbol('', group = 'Symbols', inline = 's05')

u11 = input.bool(true, title = "", group = 'Symbols', inline = 's06')
s11 = input.symbol('', group = 'Symbols', inline = 's06')

u12 = input.bool(true, title = "", group = 'Symbols', inline = 's06')
s12 = input.symbol('', group = 'Symbols', inline = 's06')

u13 = input.bool(true, title = "", group = 'Symbols', inline = 's07')
s13 = input.symbol('', group = 'Symbols', inline = 's07')

u14 = input.bool(true, title = "", group = 'Symbols', inline = 's07')
s14 = input.symbol('', group = 'Symbols', inline = 's07')

u15 = input.bool(true, title = "", group = 'Symbols', inline = 's08')
s15 = input.symbol('', group = 'Symbols', inline = 's08')

u16 = input.bool(true, title = "", group = 'Symbols', inline = 's08')
s16 = input.symbol('', group = 'Symbols', inline = 's08')

u17 = input.bool(true, title = "", group = 'Symbols', inline = 's09')
s17 = input.symbol('', group = 'Symbols', inline = 's09')

u18 = input.bool(true, title = "", group = 'Symbols', inline = 's09')
s18 = input.symbol('', group = 'Symbols', inline = 's09')

u19 = input.bool(true, title = "", group = 'Symbols', inline = 's10')
s19 = input.symbol('', group = 'Symbols', inline = 's10')

u20 = input.bool(true, title = "", group = 'Symbols', inline = 's10')
s20 = input.symbol('', group = 'Symbols', inline = 's10')

u21 = input.bool(true, title = "", group = 'Symbols', inline = 's11')
s21 = input.symbol('', group = 'Symbols', inline = 's11')

u22 = input.bool(true, title = "", group = 'Symbols', inline = 's11')
s22 = input.symbol('', group = 'Symbols', inline = 's11')

u23 = input.bool(true, title = "", group = 'Symbols', inline = 's12')
s23 = input.symbol('', group = 'Symbols', inline = 's12')

u24 = input.bool(true, title = "", group = 'Symbols', inline = 's12')
s24 = input.symbol('', group = 'Symbols', inline = 's12')

u25 = input.bool(true, title = "", group = 'Symbols', inline = 's13')
s25 = input.symbol('', group = 'Symbols', inline = 's13')

u26 = input.bool(true, title = "", group = 'Symbols', inline = 's13')
s26 = input.symbol('', group = 'Symbols', inline = 's13')

u27 = input.bool(true, title = "", group = 'Symbols', inline = 's14')
s27 = input.symbol('', group = 'Symbols', inline = 's14')

u28 = input.bool(true, title = "", group = 'Symbols', inline = 's14')
s28 = input.symbol('', group = 'Symbols', inline = 's14')

u29 = input.bool(true, title = "", group = 'Symbols', inline = 's15')
s29 = input.symbol('', group = 'Symbols', inline = 's15')

u30 = input.bool(true, title = "", group = 'Symbols', inline = 's15')
s30 = input.symbol('', group = 'Symbols', inline = 's15')

u31 = input.bool(true, title = "", group = 'Symbols', inline = 's16')
s31 = input.symbol('', group = 'Symbols', inline = 's16')

u32 = input.bool(true, title = "", group = 'Symbols', inline = 's16')
s32 = input.symbol('', group = 'Symbols', inline = 's16')

u33 = input.bool(true, title = "", group = 'Symbols', inline = 's17')
s33 = input.symbol('', group = 'Symbols', inline = 's17')

u34 = input.bool(true, title = "", group = 'Symbols', inline = 's17')
s34 = input.symbol('', group = 'Symbols', inline = 's17')

u35 = input.bool(true, title = "", group = 'Symbols', inline = 's18')
s35 = input.symbol('', group = 'Symbols', inline = 's18')

u36 = input.bool(true, title = "", group = 'Symbols', inline = 's18')
s36 = input.symbol('', group = 'Symbols', inline = 's18')

u37 = input.bool(true, title = "", group = 'Symbols', inline = 's19')
s37 = input.symbol('', group = 'Symbols', inline = 's19')

u38 = input.bool(true, title = "", group = 'Symbols', inline = 's19')
s38 = input.symbol('', group = 'Symbols', inline = 's19')

u39 = input.bool(true, title = "", group = 'Symbols', inline = 's20')
s39 = input.symbol('', group = 'Symbols', inline = 's20')

u40 = input.bool(true, title = "", group = 'Symbols', inline = 's20')
s40 = input.symbol('', group = 'Symbols', inline = 's20')

[Close01, High01, Low01, Status01, RSI01, VWAP01, vol_ok01, adx_ok01, bg01_1, bg01_2, score01, Hist01] = request.security(s01, timeframe.period, Screener())
[Close02, High02, Low02, Status02, RSI02, VWAP02, vol_ok02, adx_ok02, bg02_1, bg02_2, score02, Hist02] = request.security(s02, timeframe.period, Screener())
[Close03, High03, Low03, Status03, RSI03, VWAP03, vol_ok03, adx_ok03, bg03_1, bg03_2, score03, Hist03] = request.security(s03, timeframe.period, Screener())
[Close04, High04, Low04, Status04, RSI04, VWAP04, vol_ok04, adx_ok04, bg04_1, bg04_2, score04, Hist04] = request.security(s04, timeframe.period, Screener())
[Close05, High05, Low05, Status05, RSI05, VWAP05, vol_ok05, adx_ok05, bg05_1, bg05_2, score05, Hist05] = request.security(s05, timeframe.period, Screener())
[Close06, High06, Low06, Status06, RSI06, VWAP06, vol_ok06, adx_ok06, bg06_1, bg06_2, score06, Hist06] = request.security(s06, timeframe.period, Screener())
[Close07, High07, Low07, Status07, RSI07, VWAP07, vol_ok07, adx_ok07, bg07_1, bg07_2, score07, Hist07] = request.security(s07, timeframe.period, Screener())
[Close08, High08, Low08, Status08, RSI08, VWAP08, vol_ok08, adx_ok08, bg08_1, bg08_2, score08, Hist08] = request.security(s08, timeframe.period, Screener())
[Close09, High09, Low09, Status09, RSI09, VWAP09, vol_ok09, adx_ok09, bg09_1, bg09_2, score09, Hist09] = request.security(s09, timeframe.period, Screener())
[Close10, High10, Low10, Status10, RSI10, VWAP10, vol_ok10, adx_ok10, bg10_1, bg10_2, score10, Hist10] = request.security(s10, timeframe.period, Screener())

[Close11, High11, Low11, Status11, RSI11, VWAP11, vol_ok11, adx_ok11, bg11_1, bg11_2, score11, Hist11] = request.security(s11, timeframe.period, Screener())
[Close12, High12, Low12, Status12, RSI12, VWAP12, vol_ok12, adx_ok12, bg12_1, bg12_2, score12, Hist12] = request.security(s12, timeframe.period, Screener())
[Close13, High13, Low13, Status13, RSI13, VWAP13, vol_ok13, adx_ok13, bg13_1, bg13_2, score13, Hist13] = request.security(s13, timeframe.period, Screener())
[Close14, High14, Low14, Status14, RSI14, VWAP14, vol_ok14, adx_ok14, bg14_1, bg14_2, score14, Hist14] = request.security(s14, timeframe.period, Screener())
[Close15, High15, Low15, Status15, RSI15, VWAP15, vol_ok15, adx_ok15, bg15_1, bg15_2, score15, Hist15] = request.security(s15, timeframe.period, Screener())
[Close16, High16, Low16, Status16, RSI16, VWAP16, vol_ok16, adx_ok16, bg16_1, bg16_2, score16, Hist16] = request.security(s16, timeframe.period, Screener())
[Close17, High17, Low17, Status17, RSI17, VWAP17, vol_ok17, adx_ok17, bg17_1, bg17_2, score17, Hist17] = request.security(s17, timeframe.period, Screener())
[Close18, High18, Low18, Status18, RSI18, VWAP18, vol_ok18, adx_ok18, bg18_1, bg18_2, score18, Hist18] = request.security(s18, timeframe.period, Screener())
[Close19, High19, Low19, Status19, RSI19, VWAP19, vol_ok19, adx_ok19, bg19_1, bg19_2, score19, Hist19] = request.security(s19, timeframe.period, Screener())
[Close20, High20, Low20, Status20, RSI20, VWAP20, vol_ok20, adx_ok20, bg20_1, bg20_2, score20, Hist20] = request.security(s20, timeframe.period, Screener())

[Close21, High21, Low21, Status21, RSI21, VWAP21, vol_ok21, adx_ok21, bg21_1, bg21_2, score21, Hist21] = request.security(s21, timeframe.period, Screener())
[Close22, High22, Low22, Status22, RSI22, VWAP22, vol_ok22, adx_ok22, bg22_1, bg22_2, score22, Hist22] = request.security(s22, timeframe.period, Screener())
[Close23, High23, Low23, Status23, RSI23, VWAP23, vol_ok23, adx_ok23, bg23_1, bg23_2, score23, Hist23] = request.security(s23, timeframe.period, Screener())
[Close24, High24, Low24, Status24, RSI24, VWAP24, vol_ok24, adx_ok24, bg24_1, bg24_2, score24, Hist24] = request.security(s24, timeframe.period, Screener())
[Close25, High25, Low25, Status25, RSI25, VWAP25, vol_ok25, adx_ok25, bg25_1, bg25_2, score25, Hist25] = request.security(s25, timeframe.period, Screener())
[Close26, High26, Low26, Status26, RSI26, VWAP26, vol_ok26, adx_ok26, bg26_1, bg26_2, score26, Hist26] = request.security(s26, timeframe.period, Screener())
[Close27, High27, Low27, Status27, RSI27, VWAP27, vol_ok27, adx_ok27, bg27_1, bg27_2, score27, Hist27] = request.security(s27, timeframe.period, Screener())
[Close28, High28, Low28, Status28, RSI28, VWAP28, vol_ok28, adx_ok28, bg28_1, bg28_2, score28, Hist28] = request.security(s28, timeframe.period, Screener())
[Close29, High29, Low29, Status29, RSI29, VWAP29, vol_ok29, adx_ok29, bg29_1, bg29_2, score29, Hist29] = request.security(s29, timeframe.period, Screener())
[Close30, High30, Low30, Status30, RSI30, VWAP30, vol_ok30, adx_ok30, bg30_1, bg30_2, score30, Hist30] = request.security(s30, timeframe.period, Screener())

[Close31, High31, Low31, Status31, RSI31, VWAP31, vol_ok31, adx_ok31, bg31_1, bg31_2, score31, Hist31] = request.security(s31, timeframe.period, Screener())
[Close32, High32, Low32, Status32, RSI32, VWAP32, vol_ok32, adx_ok32, bg32_1, bg32_2, score32, Hist32] = request.security(s32, timeframe.period, Screener())
[Close33, High33, Low33, Status33, RSI33, VWAP33, vol_ok33, adx_ok33, bg33_1, bg33_2, score33, Hist33] = request.security(s33, timeframe.period, Screener())
[Close34, High34, Low34, Status34, RSI34, VWAP34, vol_ok34, adx_ok34, bg34_1, bg34_2, score34, Hist34] = request.security(s34, timeframe.period, Screener())
[Close35, High35, Low35, Status35, RSI35, VWAP35, vol_ok35, adx_ok35, bg35_1, bg35_2, score35, Hist35] = request.security(s35, timeframe.period, Screener())
[Close36, High36, Low36, Status36, RSI36, VWAP36, vol_ok36, adx_ok36, bg36_1, bg36_2, score36, Hist36] = request.security(s36, timeframe.period, Screener())
[Close37, High37, Low37, Status37, RSI37, VWAP37, vol_ok37, adx_ok37, bg37_1, bg37_2, score37, Hist37] = request.security(s37, timeframe.period, Screener())
[Close38, High38, Low38, Status38, RSI38, VWAP38, vol_ok38, adx_ok38, bg38_1, bg38_2, score38, Hist38] = request.security(s38, timeframe.period, Screener())
[Close39, High39, Low39, Status39, RSI39, VWAP39, vol_ok39, adx_ok39, bg39_1, bg39_2, score39, Hist39] = request.security(s39, timeframe.period, Screener())
[Close40, High40, Low40, Status40, RSI40, VWAP40, vol_ok40, adx_ok40, bg40_1, bg40_2, score40, Hist40] = request.security(s40, timeframe.period, Screener())

only_symbol(symbol) =>
    syminfo.ticker(symbol)

sym_arr = array.new_string(0)
close_arr   = array.new_float(0)
high_arr   = array.new_float(0)
low_arr   = array.new_float(0)
status_arr = array.new_string(0)
rsi_arr = array.new_float(0)
vwap_arr = array.new_float(0)
v_ok_arr = array.new_bool(0)
adx_ok_arr = array.new_bool(0)
bg1_arr = array.new_color(0)
bg2_arr = array.new_color(0)
u_arr   = array.new_bool(0)
score_arr = array.new_int(0)
macd_hist_arr = array.new_float(0)


array.push(sym_arr, only_symbol(s01))
array.push(sym_arr, only_symbol(s02))
array.push(sym_arr, only_symbol(s03))
array.push(sym_arr, only_symbol(s04))
array.push(sym_arr, only_symbol(s05))
array.push(sym_arr, only_symbol(s06))
array.push(sym_arr, only_symbol(s07))
array.push(sym_arr, only_symbol(s08))
array.push(sym_arr, only_symbol(s09))
array.push(sym_arr, only_symbol(s10))
array.push(sym_arr, only_symbol(s11))
array.push(sym_arr, only_symbol(s12))
array.push(sym_arr, only_symbol(s13))
array.push(sym_arr, only_symbol(s14))
array.push(sym_arr, only_symbol(s15))
array.push(sym_arr, only_symbol(s16))
array.push(sym_arr, only_symbol(s17))
array.push(sym_arr, only_symbol(s18))
array.push(sym_arr, only_symbol(s19))
array.push(sym_arr, only_symbol(s20))
array.push(sym_arr, only_symbol(s21))
array.push(sym_arr, only_symbol(s22))
array.push(sym_arr, only_symbol(s23))
array.push(sym_arr, only_symbol(s24))
array.push(sym_arr, only_symbol(s25))
array.push(sym_arr, only_symbol(s26))
array.push(sym_arr, only_symbol(s27))
array.push(sym_arr, only_symbol(s28))
array.push(sym_arr, only_symbol(s29))
array.push(sym_arr, only_symbol(s30))
array.push(sym_arr, only_symbol(s31))
array.push(sym_arr, only_symbol(s32))
array.push(sym_arr, only_symbol(s33))
array.push(sym_arr, only_symbol(s34))
array.push(sym_arr, only_symbol(s35))
array.push(sym_arr, only_symbol(s36))
array.push(sym_arr, only_symbol(s37))
array.push(sym_arr, only_symbol(s38))
array.push(sym_arr, only_symbol(s39))
array.push(sym_arr, only_symbol(s40))

array.push(u_arr, u01)
array.push(u_arr, u02)
array.push(u_arr, u03)
array.push(u_arr, u04)
array.push(u_arr, u05)
array.push(u_arr, u06)
array.push(u_arr, u07)
array.push(u_arr, u08)
array.push(u_arr, u09)
array.push(u_arr, u10)
array.push(u_arr, u11)
array.push(u_arr, u12)
array.push(u_arr, u13)
array.push(u_arr, u14)
array.push(u_arr, u15)
array.push(u_arr, u16)
array.push(u_arr, u17)
array.push(u_arr, u18)
array.push(u_arr, u19)
array.push(u_arr, u20)
array.push(u_arr, u21)
array.push(u_arr, u22)
array.push(u_arr, u23)
array.push(u_arr, u24)
array.push(u_arr, u25)
array.push(u_arr, u26)
array.push(u_arr, u27)
array.push(u_arr, u28)
array.push(u_arr, u29)
array.push(u_arr, u30)
array.push(u_arr, u31)
array.push(u_arr, u32)
array.push(u_arr, u33)
array.push(u_arr, u34)
array.push(u_arr, u35)
array.push(u_arr, u36)
array.push(u_arr, u37)
array.push(u_arr, u38)
array.push(u_arr, u39)
array.push(u_arr, u40)
array.push(high_arr, High01)
array.push(high_arr, High02)
array.push(high_arr, High03)
array.push(high_arr, High04)
array.push(high_arr, High05)
array.push(high_arr, High06)
array.push(high_arr, High07)
array.push(high_arr, High08)
array.push(high_arr, High09)
array.push(high_arr, High10)
array.push(high_arr, High11)
array.push(high_arr, High12)
array.push(high_arr, High13)
array.push(high_arr, High14)
array.push(high_arr, High15)
array.push(high_arr, High16)
array.push(high_arr, High17)
array.push(high_arr, High18)
array.push(high_arr, High19)
array.push(high_arr, High20)
array.push(high_arr, High21)
array.push(high_arr, High22)
array.push(high_arr, High23)
array.push(high_arr, High24)
array.push(high_arr, High25)
array.push(high_arr, High26)
array.push(high_arr, High27)
array.push(high_arr, High28)
array.push(high_arr, High29)
array.push(high_arr, High30)
array.push(high_arr, High31)
array.push(high_arr, High32)
array.push(high_arr, High33)
array.push(high_arr, High34)
array.push(high_arr, High35)
array.push(high_arr, High36)
array.push(high_arr, High37)
array.push(high_arr, High38)
array.push(high_arr, High39)
array.push(high_arr, High40)

array.push(low_arr, Low01)
array.push(low_arr, Low02)
array.push(low_arr, Low03)
array.push(low_arr, Low04)
array.push(low_arr, Low05)
array.push(low_arr, Low06)
array.push(low_arr, Low07)
array.push(low_arr, Low08)
array.push(low_arr, Low09)
array.push(low_arr, Low10)
array.push(low_arr, Low11)
array.push(low_arr, Low12)
array.push(low_arr, Low13)
array.push(low_arr, Low14)
array.push(low_arr, Low15)
array.push(low_arr, Low16)
array.push(low_arr, Low17)
array.push(low_arr, Low18)
array.push(low_arr, Low19)
array.push(low_arr, Low20)
array.push(low_arr, Low21)
array.push(low_arr, Low22)
array.push(low_arr, Low23)
array.push(low_arr, Low24)
array.push(low_arr, Low25)
array.push(low_arr, Low26)
array.push(low_arr, Low27)
array.push(low_arr, Low28)
array.push(low_arr, Low29)
array.push(low_arr, Low30)
array.push(low_arr, Low31)
array.push(low_arr, Low32)
array.push(low_arr, Low33)
array.push(low_arr, Low34)
array.push(low_arr, Low35)
array.push(low_arr, Low36)
array.push(low_arr, Low37)
array.push(low_arr, Low38)
array.push(low_arr, Low39)
array.push(low_arr, Low40)

array.push(status_arr, Status01)
array.push(status_arr, Status02)
array.push(status_arr, Status03)
array.push(status_arr, Status04)
array.push(status_arr, Status05)
array.push(status_arr, Status06)
array.push(status_arr, Status07)
array.push(status_arr, Status08)
array.push(status_arr, Status09)
array.push(status_arr, Status10)
array.push(status_arr, Status11)
array.push(status_arr, Status12)
array.push(status_arr, Status13)
array.push(status_arr, Status14)
array.push(status_arr, Status15)
array.push(status_arr, Status16)
array.push(status_arr, Status17)
array.push(status_arr, Status18)
array.push(status_arr, Status19)
array.push(status_arr, Status20)
array.push(status_arr, Status21)
array.push(status_arr, Status22)
array.push(status_arr, Status23)
array.push(status_arr, Status24)
array.push(status_arr, Status25)
array.push(status_arr, Status26)
array.push(status_arr, Status27)
array.push(status_arr, Status28)
array.push(status_arr, Status29)
array.push(status_arr, Status30)
array.push(status_arr, Status31)
array.push(status_arr, Status32)
array.push(status_arr, Status33)
array.push(status_arr, Status34)
array.push(status_arr, Status35)
array.push(status_arr, Status36)
array.push(status_arr, Status37)
array.push(status_arr, Status38)
array.push(status_arr, Status39)
array.push(status_arr, Status40)

array.push(rsi_arr, RSI01)
array.push(rsi_arr, RSI02)
array.push(rsi_arr, RSI03)
array.push(rsi_arr, RSI04)
array.push(rsi_arr, RSI05)
array.push(rsi_arr, RSI06)
array.push(rsi_arr, RSI07)
array.push(rsi_arr, RSI08)
array.push(rsi_arr, RSI09)
array.push(rsi_arr, RSI10)
array.push(rsi_arr, RSI11)
array.push(rsi_arr, RSI12)
array.push(rsi_arr, RSI13)
array.push(rsi_arr, RSI14)
array.push(rsi_arr, RSI15)
array.push(rsi_arr, RSI16)
array.push(rsi_arr, RSI17)
array.push(rsi_arr, RSI18)
array.push(rsi_arr, RSI19)
array.push(rsi_arr, RSI20)
array.push(rsi_arr, RSI21)
array.push(rsi_arr, RSI22)
array.push(rsi_arr, RSI23)
array.push(rsi_arr, RSI24)
array.push(rsi_arr, RSI25)
array.push(rsi_arr, RSI26)
array.push(rsi_arr, RSI27)
array.push(rsi_arr, RSI28)
array.push(rsi_arr, RSI29)
array.push(rsi_arr, RSI30)
array.push(rsi_arr, RSI31)
array.push(rsi_arr, RSI32)
array.push(rsi_arr, RSI33)
array.push(rsi_arr, RSI34)
array.push(rsi_arr, RSI35)
array.push(rsi_arr, RSI36)
array.push(rsi_arr, RSI37)
array.push(rsi_arr, RSI38)
array.push(rsi_arr, RSI39)
array.push(rsi_arr, RSI40)

array.push(vwap_arr, VWAP01)
array.push(vwap_arr, VWAP02)
array.push(vwap_arr, VWAP03)
array.push(vwap_arr, VWAP04)
array.push(vwap_arr, VWAP05)
array.push(vwap_arr, VWAP06)
array.push(vwap_arr, VWAP07)
array.push(vwap_arr, VWAP08)
array.push(vwap_arr, VWAP09)
array.push(vwap_arr, VWAP10)
array.push(vwap_arr, VWAP11)
array.push(vwap_arr, VWAP12)
array.push(vwap_arr, VWAP13)
array.push(vwap_arr, VWAP14)
array.push(vwap_arr, VWAP15)
array.push(vwap_arr, VWAP16)
array.push(vwap_arr, VWAP17)
array.push(vwap_arr, VWAP18)
array.push(vwap_arr, VWAP19)
array.push(vwap_arr, VWAP20)
array.push(vwap_arr, VWAP21)
array.push(vwap_arr, VWAP22)
array.push(vwap_arr, VWAP23)
array.push(vwap_arr, VWAP24)
array.push(vwap_arr, VWAP25)
array.push(vwap_arr, VWAP26)
array.push(vwap_arr, VWAP27)
array.push(vwap_arr, VWAP28)
array.push(vwap_arr, VWAP29)
array.push(vwap_arr, VWAP30)
array.push(vwap_arr, VWAP31)
array.push(vwap_arr, VWAP32)
array.push(vwap_arr, VWAP33)
array.push(vwap_arr, VWAP34)
array.push(vwap_arr, VWAP35)
array.push(vwap_arr, VWAP36)
array.push(vwap_arr, VWAP37)
array.push(vwap_arr, VWAP38)
array.push(vwap_arr, VWAP39)
array.push(vwap_arr, VWAP40)

array.push(v_ok_arr, vol_ok01)
array.push(v_ok_arr, vol_ok02)
array.push(v_ok_arr, vol_ok03)
array.push(v_ok_arr, vol_ok04)
array.push(v_ok_arr, vol_ok05)
array.push(v_ok_arr, vol_ok06)
array.push(v_ok_arr, vol_ok07)
array.push(v_ok_arr, vol_ok08)
array.push(v_ok_arr, vol_ok09)
array.push(v_ok_arr, vol_ok10)
array.push(v_ok_arr, vol_ok11)
array.push(v_ok_arr, vol_ok12)
array.push(v_ok_arr, vol_ok13)
array.push(v_ok_arr, vol_ok14)
array.push(v_ok_arr, vol_ok15)
array.push(v_ok_arr, vol_ok16)
array.push(v_ok_arr, vol_ok17)
array.push(v_ok_arr, vol_ok18)
array.push(v_ok_arr, vol_ok19)
array.push(v_ok_arr, vol_ok20)
array.push(v_ok_arr, vol_ok21)
array.push(v_ok_arr, vol_ok22)
array.push(v_ok_arr, vol_ok23)
array.push(v_ok_arr, vol_ok24)
array.push(v_ok_arr, vol_ok25)
array.push(v_ok_arr, vol_ok26)
array.push(v_ok_arr, vol_ok27)
array.push(v_ok_arr, vol_ok28)
array.push(v_ok_arr, vol_ok29)
array.push(v_ok_arr, vol_ok30)
array.push(v_ok_arr, vol_ok31)
array.push(v_ok_arr, vol_ok32)
array.push(v_ok_arr, vol_ok33)
array.push(v_ok_arr, vol_ok34)
array.push(v_ok_arr, vol_ok35)
array.push(v_ok_arr, vol_ok36)
array.push(v_ok_arr, vol_ok37)
array.push(v_ok_arr, vol_ok38)
array.push(v_ok_arr, vol_ok39)
array.push(v_ok_arr, vol_ok40)

array.push(adx_ok_arr, adx_ok01)
array.push(adx_ok_arr, adx_ok02)
array.push(adx_ok_arr, adx_ok03)
array.push(adx_ok_arr, adx_ok04)
array.push(adx_ok_arr, adx_ok05)
array.push(adx_ok_arr, adx_ok06)
array.push(adx_ok_arr, adx_ok07)
array.push(adx_ok_arr, adx_ok08)
array.push(adx_ok_arr, adx_ok09)
array.push(adx_ok_arr, adx_ok10)
array.push(adx_ok_arr, adx_ok11)
array.push(adx_ok_arr, adx_ok12)
array.push(adx_ok_arr, adx_ok13)
array.push(adx_ok_arr, adx_ok14)
array.push(adx_ok_arr, adx_ok15)
array.push(adx_ok_arr, adx_ok16)
array.push(adx_ok_arr, adx_ok17)
array.push(adx_ok_arr, adx_ok18)
array.push(adx_ok_arr, adx_ok19)
array.push(adx_ok_arr, adx_ok20)
array.push(adx_ok_arr, adx_ok21)
array.push(adx_ok_arr, adx_ok22)
array.push(adx_ok_arr, adx_ok23)
array.push(adx_ok_arr, adx_ok24)
array.push(adx_ok_arr, adx_ok25)
array.push(adx_ok_arr, adx_ok26)
array.push(adx_ok_arr, adx_ok27)
array.push(adx_ok_arr, adx_ok28)
array.push(adx_ok_arr, adx_ok29)
array.push(adx_ok_arr, adx_ok30)
array.push(adx_ok_arr, adx_ok31)
array.push(adx_ok_arr, adx_ok32)
array.push(adx_ok_arr, adx_ok33)
array.push(adx_ok_arr, adx_ok34)
array.push(adx_ok_arr, adx_ok35)
array.push(adx_ok_arr, adx_ok36)
array.push(adx_ok_arr, adx_ok37)
array.push(adx_ok_arr, adx_ok38)
array.push(adx_ok_arr, adx_ok39)
array.push(adx_ok_arr, adx_ok40)

array.push(macd_hist_arr, Hist01)
array.push(macd_hist_arr, Hist02)
array.push(macd_hist_arr, Hist03)
array.push(macd_hist_arr, Hist04)
array.push(macd_hist_arr, Hist05)
array.push(macd_hist_arr, Hist06)
array.push(macd_hist_arr, Hist07)
array.push(macd_hist_arr, Hist08)
array.push(macd_hist_arr, Hist09)
array.push(macd_hist_arr, Hist10)
array.push(macd_hist_arr, Hist11)
array.push(macd_hist_arr, Hist12)
array.push(macd_hist_arr, Hist13)
array.push(macd_hist_arr, Hist14)
array.push(macd_hist_arr, Hist15)
array.push(macd_hist_arr, Hist16)
array.push(macd_hist_arr, Hist17)
array.push(macd_hist_arr, Hist18)
array.push(macd_hist_arr, Hist19)
array.push(macd_hist_arr, Hist20)
array.push(macd_hist_arr, Hist21)
array.push(macd_hist_arr, Hist22)
array.push(macd_hist_arr, Hist23)
array.push(macd_hist_arr, Hist24)
array.push(macd_hist_arr, Hist25)
array.push(macd_hist_arr, Hist26)
array.push(macd_hist_arr, Hist27)
array.push(macd_hist_arr, Hist28)
array.push(macd_hist_arr, Hist29)
array.push(macd_hist_arr, Hist30)
array.push(macd_hist_arr, Hist31)
array.push(macd_hist_arr, Hist32)
array.push(macd_hist_arr, Hist33)
array.push(macd_hist_arr, Hist34)
array.push(macd_hist_arr, Hist35)
array.push(macd_hist_arr, Hist36)
array.push(macd_hist_arr, Hist37)
array.push(macd_hist_arr, Hist38)
array.push(macd_hist_arr, Hist39)
array.push(macd_hist_arr, Hist40)

array.push(bg1_arr, bg01_1)
array.push(bg1_arr, bg02_1)
array.push(bg1_arr, bg03_1)
array.push(bg1_arr, bg04_1)
array.push(bg1_arr, bg05_1)
array.push(bg1_arr, bg06_1)
array.push(bg1_arr, bg07_1)
array.push(bg1_arr, bg08_1)
array.push(bg1_arr, bg09_1)
array.push(bg1_arr, bg10_1)
array.push(bg1_arr, bg11_1)
array.push(bg1_arr, bg12_1)
array.push(bg1_arr, bg13_1)
array.push(bg1_arr, bg14_1)
array.push(bg1_arr, bg15_1)
array.push(bg1_arr, bg16_1)
array.push(bg1_arr, bg17_1)
array.push(bg1_arr, bg18_1)
array.push(bg1_arr, bg19_1)
array.push(bg1_arr, bg20_1)
array.push(bg1_arr, bg21_1)
array.push(bg1_arr, bg22_1)
array.push(bg1_arr, bg23_1)
array.push(bg1_arr, bg24_1)
array.push(bg1_arr, bg25_1)
array.push(bg1_arr, bg26_1)
array.push(bg1_arr, bg27_1)
array.push(bg1_arr, bg28_1)
array.push(bg1_arr, bg29_1)
array.push(bg1_arr, bg30_1)
array.push(bg1_arr, bg31_1)
array.push(bg1_arr, bg32_1)
array.push(bg1_arr, bg33_1)
array.push(bg1_arr, bg34_1)
array.push(bg1_arr, bg35_1)
array.push(bg1_arr, bg36_1)
array.push(bg1_arr, bg37_1)
array.push(bg1_arr, bg38_1)
array.push(bg1_arr, bg39_1)
array.push(bg1_arr, bg40_1)

array.push(bg2_arr, bg01_2)
array.push(bg2_arr, bg02_2)
array.push(bg2_arr, bg03_2)
array.push(bg2_arr, bg04_2)
array.push(bg2_arr, bg05_2)
array.push(bg2_arr, bg06_2)
array.push(bg2_arr, bg07_2)
array.push(bg2_arr, bg08_2)
array.push(bg2_arr, bg09_2)
array.push(bg2_arr, bg10_2)
array.push(bg2_arr, bg11_2)
array.push(bg2_arr, bg12_2)
array.push(bg2_arr, bg13_2)
array.push(bg2_arr, bg14_2)
array.push(bg2_arr, bg15_2)
array.push(bg2_arr, bg16_2)
array.push(bg2_arr, bg17_2)
array.push(bg2_arr, bg18_2)
array.push(bg2_arr, bg19_2)
array.push(bg2_arr, bg20_2)
array.push(bg2_arr, bg21_2)
array.push(bg2_arr, bg22_2)
array.push(bg2_arr, bg23_2)
array.push(bg2_arr, bg24_2)
array.push(bg2_arr, bg25_2)
array.push(bg2_arr, bg26_2)
array.push(bg2_arr, bg27_2)
array.push(bg2_arr, bg28_2)
array.push(bg2_arr, bg29_2)
array.push(bg2_arr, bg30_2)
array.push(bg2_arr, bg31_2)
array.push(bg2_arr, bg32_2)
array.push(bg2_arr, bg33_2)
array.push(bg2_arr, bg34_2)
array.push(bg2_arr, bg35_2)
array.push(bg2_arr, bg36_2)
array.push(bg2_arr, bg37_2)
array.push(bg2_arr, bg38_2)
array.push(bg2_arr, bg39_2)
array.push(bg2_arr, bg40_2)

array.push(score_arr, score01)
array.push(score_arr, score02)
array.push(score_arr, score03)
array.push(score_arr, score04)
array.push(score_arr, score05)
array.push(score_arr, score06)
array.push(score_arr, score07)
array.push(score_arr, score08)
array.push(score_arr, score09)
array.push(score_arr, score10)
array.push(score_arr, score11)
array.push(score_arr, score12)
array.push(score_arr, score13)
array.push(score_arr, score14)
array.push(score_arr, score15)
array.push(score_arr, score16)
array.push(score_arr, score17)
array.push(score_arr, score18)
array.push(score_arr, score19)
array.push(score_arr, score20)
array.push(score_arr, score21)
array.push(score_arr, score22)
array.push(score_arr, score23)
array.push(score_arr, score24)
array.push(score_arr, score25)
array.push(score_arr, score26)
array.push(score_arr, score27)
array.push(score_arr, score28)
array.push(score_arr, score29)
array.push(score_arr, score30)
array.push(score_arr, score31)
array.push(score_arr, score32)
array.push(score_arr, score33)
array.push(score_arr, score34)
array.push(score_arr, score35)
array.push(score_arr, score36)
array.push(score_arr, score37)
array.push(score_arr, score38)
array.push(score_arr, score39)
array.push(score_arr, score40)

array.push(close_arr, Close01)
array.push(close_arr, Close02)
array.push(close_arr, Close03)
array.push(close_arr, Close04)
array.push(close_arr, Close05)
array.push(close_arr, Close06)
array.push(close_arr, Close07)
array.push(close_arr, Close08)
array.push(close_arr, Close09)
array.push(close_arr, Close10)
array.push(close_arr, Close11)
array.push(close_arr, Close12)
array.push(close_arr, Close13)
array.push(close_arr, Close14)
array.push(close_arr, Close15)
array.push(close_arr, Close16)
array.push(close_arr, Close17)
array.push(close_arr, Close18)
array.push(close_arr, Close19)
array.push(close_arr, Close20)
array.push(close_arr, Close21)
array.push(close_arr, Close22)
array.push(close_arr, Close23)
array.push(close_arr, Close24)
array.push(close_arr, Close25)
array.push(close_arr, Close26)
array.push(close_arr, Close27)
array.push(close_arr, Close28)
array.push(close_arr, Close29)
array.push(close_arr, Close30)
array.push(close_arr, Close31)
array.push(close_arr, Close32)
array.push(close_arr, Close33)
array.push(close_arr, Close34)
array.push(close_arr, Close35)
array.push(close_arr, Close36)
array.push(close_arr, Close37)
array.push(close_arr, Close38)
array.push(close_arr, Close39)
array.push(close_arr, Close40)



// 1. Define swap helper OUTSIDE the loop
swap(arr, a, b) =>
    tmp = array.get(arr, a)
    array.set(arr, a, array.get(arr, b))
    array.set(arr, b, tmp)



position = (y_coordinate == "Top" ? (x_coordinate == "Left" ? position.top_left : x_coordinate == "Center" ? position.top_center : position.top_right) : y_coordinate == "Middle" ? (x_coordinate == "Left" ? position.middle_left : x_coordinate == "Center" ? position.middle_center : position.middle_right) : y_coordinate == "Bottom" ? (x_coordinate == "Left" ? position.bottom_left : x_coordinate == "Center" ? position.bottom_center : position.bottom_right) : position.top_right)
// جدول بترتيب أعمدة من اليمين لليسار (Symbol على أقصى اليمين)
var tbl = table.new(position, 11, 42, frame_color=#151715, frame_width=1, border_width=2, border_color=color.new(color.white, 100))
if barstate.islast
    // رؤوس الأعمدة (يمين ← يسار)
    table.cell(tbl, 10, 0, 'السهم',          text_halign = text.align_center, bgcolor = #295b79, text_color = color.white, text_size = size)
    table.cell(tbl,  9, 0, 'السعر الحالي',             text_halign = text.align_center, bgcolor = #295b79, text_color = color.white, text_size = size)
    table.cell(tbl,  8, 0, 'ادنى ORB',             text_halign = text.align_center, bgcolor = #295b79, text_color = color.white, text_size = size)    
    table.cell(tbl,  7, 0, 'اعلى ORB',            text_halign = text.align_center, bgcolor = #295b79, text_color = color.white, text_size = size)    
    table.cell(tbl,  6, 0, 'الحالة',          text_halign = text.align_center, bgcolor = #295b79, text_color = color.white, text_size = size)
    table.cell(tbl,  5, 0, 'RSI',             text_halign = text.align_center, bgcolor = #295b79, text_color = color.white, text_size = size)
    table.cell(tbl,  4, 0, 'VWAP',            text_halign = text.align_center, bgcolor = #295b79, text_color = color.white, text_size = size)
    table.cell(tbl,  3, 0, 'اندفاع السيولة',       text_halign = text.align_center, bgcolor = #295b79, text_color  = color.white, text_size = size)
    table.cell(tbl,  2, 0, 'قوة الاتجاة',          text_halign = text.align_center, bgcolor = #295b79, text_color=color.white, text_size=size)
    table.cell(tbl,  1, 0, 'MACD',            text_halign = text.align_center, bgcolor = #295b79, text_color=color.white, text_size=size)
    table.cell(tbl,  0, 0, 'قوة الاشارة',  text_halign = text.align_center, bgcolor = #295b79, text_color = color.white, text_size = size)

    // الصفوف
    for i = 0 to 39
        if array.get(u_arr, i) and array.get(sym_arr, i) != ""
            // Symbol (يمين)
            table.cell(tbl, 10, i + 1, array.get(sym_arr, i),                text_halign = text.align_center, bgcolor = #295b79, text_color = color.white, text_size = size)

            // LTP
            table.cell(tbl,  9, i + 1, str.tostring(array.get(close_arr, i), "#.###"),                text_halign = text.align_center, bgcolor = color.gray, text_color = color.white, text_size = size)

            // Low (خلفية إشارة الشورت)
            table.cell(tbl,  8, i + 1, str.tostring(array.get(low_arr, i), "#.###"),                text_halign = text.align_center, bgcolor = array.get(bg2_arr, i), text_color = color.white, text_size = size)

            // High (خلفية إشارة اللونغ)
            table.cell(tbl,  7, i + 1, str.tostring(array.get(high_arr, i), "#.###"),                text_halign = text.align_center, bgcolor = array.get(bg1_arr, i), text_color = color.white, text_size = size)

            // Status
            status_val = array.get(status_arr, i)
            status_bg  = status_val == "فوق النطاق" ? color.green : status_val == "تحت النطاق" ? color.red : color.gray
            table.cell(tbl,  6, i + 1, status_val,                text_halign = text.align_center, bgcolor = status_bg, text_color = color.white, text_size = size)

            // RSI
            table.cell(tbl,  5, i + 1, str.tostring(array.get(rsi_arr, i), "#.###"),                text_halign = text.align_center, bgcolor = color.gray, text_color = color.white, text_size = size)

            // VWAP (تلوين حسب موقع السعر من VWAP)
            bg_vwap = array.get(close_arr, i) > array.get(vwap_arr, i) ? color.green : color.red
            table.cell(tbl,  4, i + 1, str.tostring(array.get(vwap_arr, i), "#.###"),                text_halign = text.align_center, bgcolor = bg_vwap, text_color  = color.white, text_size = size)

            // Vol Surge
            is_vol = array.get(v_ok_arr, i)
            bg_vol = is_vol ? color.green : color.red
            table.cell(tbl,  3, i + 1, is_vol ? 'موجود' : 'غير موجود',                text_halign = text.align_center, bgcolor = bg_vol, text_color  = color.white, text_size = size)

            // ADX OK
            adx_flag = array.get(adx_ok_arr, i)
            bg_adx   = adx_flag ? color.green : color.red
            table.cell(tbl,  2, i + 1, adx_flag ? 'قوي' : 'ضعيف',                text_halign = text.align_center, bgcolor = bg_adx, text_color = color.white, text_size = size)

            // MACD Histogram
            macd_val = array.get(macd_hist_arr, i)
            macd_bg  = macd_val > 0 ? color.new(color.green, 0) : macd_val < 0 ? color.new(color.red, 0) : color.gray
            table.cell(tbl,  1, i + 1, str.tostring(macd_val, "#.###"),                text_halign = text.align_center, bgcolor = macd_bg, text_color = color.white, text_size = size)

            // Score + إشارة
            score_val = array.get(score_arr, i)
            signal_lbl = score_val >= 75 and status_val == "Abv High" ? "Buy" :
                         score_val >= 75 and status_val == "Blw Low"  ? "Sell" : ""
            display = signal_lbl != "" ? str.tostring(score_val) + " (" + signal_lbl + ")" : str.tostring(score_val)
            bg_score = score_val >= 75 ? color.green : score_val >= 50 ? color.orange : color.red
            table.cell(tbl,  0, i + 1, display,                text_halign = text.align_center, bgcolor = bg_score, text_color = color.white, text_size = size)




ليست هناك تعليقات:

إرسال تعليق