Trend Close Distance

b_kaptan85 · study · 527 行 · 点赞 0 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0
// © Prof2946
//@version=6
 
indicator('TOOLS-🎯- BTCUSD + TOTAL3 + CURRENT + 20 ALTS — Trend Close Distance', overlay = false, max_labels_count = 500, max_lines_count = 50)
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// INPUTS - HESAPLAMA MOTORU
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
int zigzagHighPeriod = input.int(title = 'Zigzag High Period', defval = 10, minval = 1, group = 'Algoritma Ayarları')
int zigzagLowPeriod  = input.int(title = 'Zigzag Low Period',  defval = 10, minval = 1, group = 'Algoritma Ayarları')
 
float minMovementPercent = input.float(
     title  = 'Minimum Movement Percent',
     defval = 0.160,
     minval = 0.01,
     maxval = 100.0,
     step   = 0.01,
     group  = 'Algoritma Ayarları'
)
 
int maPeriod = input.int(title = 'Moving Average Period', defval = 20, minval = 1, group = 'Algoritma Ayarları')
int maLengthAllSignals = input.int(title = 'Signal Moving Average Length', defval = 10, minval = 1, group = 'Algoritma Ayarları')
 
bool showLabels   = input.bool(true, 'Sağ Sembol Etiketlerini Göster', group = 'Görsel Ayarlar')
bool showZeroLine = input.bool(true, '0 Referans Çizgisini Göster', group = 'Görsel Ayarlar')
 
// 1 Çizgisi Ayarları
bool showOneLine          = input.bool(true, '1 Referans Çizgisini Göster', group = '1 Referans Çizgisi')
float oneLineValue        = input.float(1.0, '1 Çizgisi Değeri', step = 0.01, group = '1 Referans Çizgisi')
int oneLineLookbackBars   = input.int(300, '1 Çizgisi Sol Uzunluğu (bar)', minval = 20, group = '1 Referans Çizgisi')
int oneLineLabelGapBars   = input.int(6, '1 Çizgisi Sağ Etiket Boşluğu (bar)', minval = 1, maxval = 50, group = '1 Referans Çizgisi')
float oneLineLabelPadding = input.float(0.25, '1 Çizgisi Label Koruma Mesafesi', minval = 0.01, step = 0.01, group = '1 Referans Çizgisi')
 
// Kırılım Sinyali
bool showBreakoutSignal = input.bool(true, 'CURRENT 1 Çizgisi Yukarı Kırılım Sinyali', group = 'Kırılım Sinyali')
string breakoutEmoji    = input.string('🚀', 'Kırılım Emojisi', group = 'Kırılım Sinyali')
string breakoutLabelPos = input.string('Below', 'Emoji Konumu (ana ekran)', options = ['Below', 'Above'], group = 'Kırılım Sinyali')
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// SABİT REFERANSLAR & 20 COIN SEÇİMİ
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
string G_REF = 'Referans Semboller'
string BTC_SYMBOL    = input.symbol('COINBASE:BTCUSD', 'BTCUSD Referansı', group = G_REF)
string TOTAL3_SYMBOL = input.symbol('CRYPTOCAP:TOTAL3', 'Referans 2 (TOTAL3 veya USDT.D)', group = G_REF)
string CHART_SYMBOL  = syminfo.tickerid
 
string G_ALTS = '20 İlave Kripto Para Seçimi'
bool en01 = input.bool(true, '', inline = 'c01', group = G_ALTS)
string s01 = input.symbol('BINANCE:ETHUSDT', '01', inline = 'c01', group = G_ALTS)
color col01 = input.color(#627eea, '', inline = 'c01', group = G_ALTS)
 
bool en02 = input.bool(true, '', inline = 'c02', group = G_ALTS)
string s02 = input.symbol('BINANCE:SOLUSDT', '02', inline = 'c02', group = G_ALTS)
color col02 = input.color(#14f195, '', inline = 'c02', group = G_ALTS)
 
bool en03 = input.bool(true, '', inline = 'c03', group = G_ALTS)
string s03 = input.symbol('BINANCE:BNBUSDT', '03', inline = 'c03', group = G_ALTS)
color col03 = input.color(#f3ba2f, '', inline = 'c03', group = G_ALTS)
 
bool en04 = input.bool(true, '', inline = 'c04', group = G_ALTS)
string s04 = input.symbol('BINANCE:XRPUSDT', '04', inline = 'c04', group = G_ALTS)
color col04 = input.color(#00aae4, '', inline = 'c04', group = G_ALTS)
 
bool en05 = input.bool(true, '', inline = 'c05', group = G_ALTS)
string s05 = input.symbol('BINANCE:DOGEUSDT', '05', inline = 'c05', group = G_ALTS)
color col05 = input.color(#c2a633, '', inline = 'c05', group = G_ALTS)
 
bool en06 = input.bool(true, '', inline = 'c06', group = G_ALTS)
string s06 = input.symbol('BINANCE:ADAUSDT', '06', inline = 'c06', group = G_ALTS)
color col06 = input.color(#3cc8c8, '', inline = 'c06', group = G_ALTS)
 
bool en07 = input.bool(true, '', inline = 'c07', group = G_ALTS)
string s07 = input.symbol('BINANCE:AVAXUSDT', '07', inline = 'c07', group = G_ALTS)
color col07 = input.color(#e84142, '', inline = 'c07', group = G_ALTS)
 
bool en08 = input.bool(true, '', inline = 'c08', group = G_ALTS)
string s08 = input.symbol('BINANCE:SUIUSDT', '08', inline = 'c08', group = G_ALTS)
color col08 = input.color(#4da2ff, '', inline = 'c08', group = G_ALTS)
 
bool en09 = input.bool(true, '', inline = 'c09', group = G_ALTS)
string s09 = input.symbol('BINANCE:LINKUSDT', '09', inline = 'c09', group = G_ALTS)
color col09 = input.color(#375bd2, '', inline = 'c09', group = G_ALTS)
 
bool en10 = input.bool(true, '', inline = 'c10', group = G_ALTS)
string s10 = input.symbol('BINANCE:NEARUSDT', '10', inline = 'c10', group = G_ALTS)
color col10 = input.color(#00e5ff, '', inline = 'c10', group = G_ALTS)
 
bool en11 = input.bool(true, '', inline = 'c11', group = G_ALTS)
string s11 = input.symbol('BINANCE:APTUSDT', '11', inline = 'c11', group = G_ALTS)
color col11 = input.color(#2ee09a, '', inline = 'c11', group = G_ALTS)
 
bool en12 = input.bool(true, '', inline = 'c12', group = G_ALTS)
string s12 = input.symbol('BINANCE:PEPEUSDT', '12', inline = 'c12', group = G_ALTS)
color col12 = input.color(#55a93e, '', inline = 'c12', group = G_ALTS)
 
bool en13 = input.bool(true, '', inline = 'c13', group = G_ALTS)
string s13 = input.symbol('BINANCE:ARBUSDT', '13', inline = 'c13', group = G_ALTS)
color col13 = input.color(#28a0f0, '', inline = 'c13', group = G_ALTS)
 
bool en14 = input.bool(true, '', inline = 'c14', group = G_ALTS)
string s14 = input.symbol('BINANCE:OPUSDT', '14', inline = 'c14', group = G_ALTS)
color col14 = input.color(#ff0420, '', inline = 'c14', group = G_ALTS)
 
bool en15 = input.bool(true, '', inline = 'c15', group = G_ALTS)
string s15 = input.symbol('BINANCE:TIAUSDT', '15', inline = 'c15', group = G_ALTS)
color col15 = input.color(#a855f7, '', inline = 'c15', group = G_ALTS)
 
bool en16 = input.bool(true, '', inline = 'c16', group = G_ALTS)
string s16 = input.symbol('BINANCE:INJUSDT', '16', inline = 'c16', group = G_ALTS)
color col16 = input.color(#00f2fe, '', inline = 'c16', group = G_ALTS)
 
bool en17 = input.bool(true, '', inline = 'c17', group = G_ALTS)
string s17 = input.symbol('BINANCE:RENDERUSDT', '17', inline = 'c17', group = G_ALTS)
color col17 = input.color(#e53935, '', inline = 'c17', group = G_ALTS)
 
bool en18 = input.bool(true, '', inline = 'c18', group = G_ALTS)
string s18 = input.symbol('BINANCE:FETUSDT', '18', inline = 'c18', group = G_ALTS)
color col18 = input.color(#1e88e5, '', inline = 'c18', group = G_ALTS)
 
bool en19 = input.bool(true, '', inline = 'c19', group = G_ALTS)
string s19 = input.symbol('BINANCE:DOTUSDT', '19', inline = 'c19', group = G_ALTS)
color col19 = input.color(#e6007a, '', inline = 'c19', group = G_ALTS)
 
bool en20 = input.bool(true, '', inline = 'c20', group = G_ALTS)
string s20 = input.symbol('BINANCE:TAOUSDT', '20', inline = 'c20', group = G_ALTS)
color col20 = input.color(#ff7043, '', inline = 'c20', group = G_ALTS)
 
// Tablo Konum & Boyut Ayarları
string G_TBL = 'Canlı Takip Tablosu Ayarları'
bool showTable            = input.bool(true, 'Takip Tablosunu Göster', group = G_TBL)
string tablePosInput      = input.string('Sol Üst', 'Tablo Konumu', options = ['Sol Üst', 'Sol Orta', 'Sol Alt', 'Sağ Üst', 'Sağ Orta', 'Sağ Alt'], group = G_TBL)
string tableFontSizeInput = input.string('Küçük (Small)', 'Yazı Boyutu', options = ['Çok Küçük (Tiny)', 'Küçük (Small)', 'Normal (Normal)', 'Büyük (Large)'], group = G_TBL)
 
// Sabit Renkler
color C_BTC     = color.new(#00d4ff, 0)
color C_TOTAL3  = color.new(#ff0055, 0)
color C_CURRENT = color.new(#00ff88, 0)
color C_ZERO    = color.new(color.gray, 20)
color C_ONE     = color.new(#d100ff, 0)
color C_TEXT    = color.black // Etiket içi siyah font
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// CORE CALCULATION ENGINE
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
f_distanceFromSignalAverage() =>
    float zHigh = ta.highestbars(high, zigzagHighPeriod) == 0 ? high : na
    float zLow  = ta.lowestbars(low, zigzagLowPeriod) == 0 ? low : na
 
    bool highPivotNow = ta.highestbars(high, zigzagHighPeriod) == 0
    bool lowPivotNow  = ta.lowestbars(low, zigzagLowPeriod) == 0
 
    float prevZHighClose = ta.valuewhen(highPivotNow, close, 1)
    float prevZLowClose  = ta.valuewhen(lowPivotNow, close, 1)
 
    float minMovement = close * minMovementPercent / 100.0
 
    bool longMumu =
         not na(zHigh) and
         zHigh > ta.valuewhen(highPivotNow, zHigh, 1) and
         not na(prevZHighClose) and
         close - prevZHighClose >= minMovement
 
    bool shortMumu =
         not na(zLow) and
         zLow < ta.valuewhen(lowPivotNow, zLow, 1) and
         not na(prevZLowClose) and
         prevZLowClose - close >= minMovement
 
    float signalSource1 = longMumu ? low : shortMumu ? high : na
    float maSignal1 = ta.sma(signalSource1, maLengthAllSignals)
 
    float baseMa = ta.sma(close, maPeriod)
 
    bool shortPotentialCandles = close > baseMa
    bool longPotentialCandles2 = close < baseMa
 
    float signalSource2 = shortPotentialCandles ? low : longPotentialCandles2 ? high : na
    float maSignal2 = ta.sma(signalSource2, maLengthAllSignals)
 
    float avgSignalLine = (maSignal1 + maSignal2) / 2.0
 
    float rawDistance =
         not na(avgSignalLine) and avgSignalLine != 0.0
         ? ((close - avgSignalLine) / avgSignalLine) * 100.0
         : na
 
    fixnan(rawDistance)
 
f_getDistance(string sym) =>
    request.security(sym, timeframe.period, f_distanceFromSignalAverage(), barmerge.gaps_off, barmerge.lookahead_off)
 
f_cleanTicker(string fullSym) =>
    array<string> parts = str.split(fullSym, ':')
    array.size(parts) > 1 ? array.get(parts, 1) : fullSym
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// DISTANCE HESAPLAMALARI
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
float btcDistance     = f_getDistance(BTC_SYMBOL)
float total3Distance  = f_getDistance(TOTAL3_SYMBOL)
float currentDistance = f_getDistance(CHART_SYMBOL)
 
float d01 = en01 ? f_getDistance(s01) : na
float d02 = en02 ? f_getDistance(s02) : na
float d03 = en03 ? f_getDistance(s03) : na
float d04 = en04 ? f_getDistance(s04) : na
float d05 = en05 ? f_getDistance(s05) : na
float d06 = en06 ? f_getDistance(s06) : na
float d07 = en07 ? f_getDistance(s07) : na
float d08 = en08 ? f_getDistance(s08) : na
float d09 = en09 ? f_getDistance(s09) : na
float d10 = en10 ? f_getDistance(s10) : na
float d11 = en11 ? f_getDistance(s11) : na
float d12 = en12 ? f_getDistance(s12) : na
float d13 = en13 ? f_getDistance(s13) : na
float d14 = en14 ? f_getDistance(s14) : na
float d15 = en15 ? f_getDistance(s15) : na
float d16 = en16 ? f_getDistance(s16) : na
float d17 = en17 ? f_getDistance(s17) : na
float d18 = en18 ? f_getDistance(s18) : na
float d19 = en19 ? f_getDistance(s19) : na
float d20 = en20 ? f_getDistance(s20) : na
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// KESİŞİM VE ZAMAN İZLEME MOTORU (5 SANİYE YANIP SÖNME)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
f_trackCross(float d, float btc, float ref2) =>
    bool bUp   = not na(d) and not na(btc)  and ta.crossover(d, btc)
    bool bDown = not na(d) and not na(btc)  and ta.crossunder(d, btc)
    bool rUp   = not na(d) and not na(ref2) and ta.crossover(d, ref2)
    bool rDown = not na(d) and not na(ref2) and ta.crossunder(d, ref2)
 
    var int tCross = 0
    var string msgCross = '-'
    var color colCross = color.gray
 
    if bUp
        tCross := timenow
        msgCross := 'BTC ▲'
        colCross := color.green
    else if bDown
        tCross := timenow
        msgCross := 'BTC ▼'
        colCross := color.red
    else if rUp
        tCross := timenow
        msgCross := 'REF ▲'
        colCross := color.teal
    else if rDown
        tCross := timenow
        msgCross := 'REF ▼'
        colCross := color.orange
 
    [tCross, msgCross, colCross]
 
[tCur, msgCur, colCur] = f_trackCross(currentDistance, btcDistance, total3Distance)
[t01, msg01, col01_cr] = f_trackCross(d01, btcDistance, total3Distance)
[t02, msg02, col02_cr] = f_trackCross(d02, btcDistance, total3Distance)
[t03, msg03, col03_cr] = f_trackCross(d03, btcDistance, total3Distance)
[t04, msg04, col04_cr] = f_trackCross(d04, btcDistance, total3Distance)
[t05, msg05, col05_cr] = f_trackCross(d05, btcDistance, total3Distance)
[t06, msg06, col06_cr] = f_trackCross(d06, btcDistance, total3Distance)
[t07, msg07, col07_cr] = f_trackCross(d07, btcDistance, total3Distance)
[t08, msg08, col08_cr] = f_trackCross(d08, btcDistance, total3Distance)
[t09, msg09, col09_cr] = f_trackCross(d09, btcDistance, total3Distance)
[t10, msg10, col10_cr] = f_trackCross(d10, btcDistance, total3Distance)
[t11, msg11, col11_cr] = f_trackCross(d11, btcDistance, total3Distance)
[t12, msg12, col12_cr] = f_trackCross(d12, btcDistance, total3Distance)
[t13, msg13, col13_cr] = f_trackCross(d13, btcDistance, total3Distance)
[t14, msg14, col14_cr] = f_trackCross(d14, btcDistance, total3Distance)
[t15, msg15, col15_cr] = f_trackCross(d15, btcDistance, total3Distance)
[t16, msg16, col16_cr] = f_trackCross(d16, btcDistance, total3Distance)
[t17, msg17, col17_cr] = f_trackCross(d17, btcDistance, total3Distance)
[t18, msg18, col18_cr] = f_trackCross(d18, btcDistance, total3Distance)
[t19, msg19, col19_cr] = f_trackCross(d19, btcDistance, total3Distance)
[t20, msg20, col20_cr] = f_trackCross(d20, btcDistance, total3Distance)
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// GRAFİK PLOTLARI
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
plot(btcDistance,    title = 'BTCUSD',    color = C_BTC,    linewidth = 2)
plot(total3Distance, title = 'TOTAL3',    color = C_TOTAL3, linewidth = 2)
plot(currentDistance,title = 'CURRENT',   color = C_CURRENT,linewidth = 3)
 
plot(d01, title = '01', color = col01, linewidth = 1)
plot(d02, title = '02', color = col02, linewidth = 1)
plot(d03, title = '03', color = col03, linewidth = 1)
plot(d04, title = '04', color = col04, linewidth = 1)
plot(d05, title = '05', color = col05, linewidth = 1)
plot(d06, title = '06', color = col06, linewidth = 1)
plot(d07, title = '07', color = col07, linewidth = 1)
plot(d08, title = '08', color = col08, linewidth = 1)
plot(d09, title = '09', color = col09, linewidth = 1)
plot(d10, title = '10', color = col10, linewidth = 1)
plot(d11, title = '11', color = col11, linewidth = 1)
plot(d12, title = '12', color = col12, linewidth = 1)
plot(d13, title = '13', color = col13, linewidth = 1)
plot(d14, title = '14', color = col14, linewidth = 1)
plot(d15, title = '15', color = col15, linewidth = 1)
plot(d16, title = '16', color = col16, linewidth = 1)
plot(d17, title = '17', color = col17, linewidth = 1)
plot(d18, title = '18', color = col18, linewidth = 1)
plot(d19, title = '19', color = col19, linewidth = 1)
plot(d20, title = '20', color = col20, linewidth = 1)
 
plot(showZeroLine ? 0.0 : na, title = 'Zero Line', color = C_ZERO, linewidth = 2)
 
// CURRENT 1 Çizgisi Kırılım Sinyali
bool currentBreakUp = showBreakoutSignal and not na(currentDistance) and ta.crossover(currentDistance, oneLineValue)
if currentBreakUp
    label.new(
         x             = bar_index,
         y             = na,
         yloc          = breakoutLabelPos == 'Below' ? yloc.belowbar : yloc.abovebar,
         text          = breakoutEmoji,
         style         = breakoutLabelPos == 'Below' ? label.style_label_up : label.style_label_down,
         color         = color.new(C_CURRENT, 15),
         textcolor     = color.white,
         size          = size.tiny,
         force_overlay = true
    )
 
plot(currentBreakUp ? 1.0 : 0.0, title = 'CURRENT Breakout Signal', display = display.none)
alertcondition(currentBreakUp, title = 'CURRENT 1 Çizgisi Yukarı Kırılım', message = 'CURRENT sembol 1 çizgisini yukarı kırdı 🚀')
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// ETİKET (LABEL) MOTORU
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
f_getSafeLabelY(float y, bool protectFromOneLine, float refLine, float padding) =>
    float safeY = y
    if protectFromOneLine and not na(y)
        if math.abs(y - refLine) < padding
            safeY := y >= refLine ? refLine + padding : refLine - padding
    safeY
 
f_updateHorizontalLine(line ln, bool enabled, float y, color col, int lookbackBars, int rightGapBars) =>
    line result = ln
    int x1 = math.max(0, bar_index - lookbackBars)
    int x2 = math.max(x1 + 1, bar_index - rightGapBars)
    if enabled
        if na(result)
            result := line.new(x1, y, x2, y, xloc.bar_index, extend.none, col, line.style_solid, 2)
        else
            line.set_xy1(result, x1, y)
            line.set_xy2(result, x2, y)
            line.set_color(result, col)
    else if not na(result)
        line.delete(result)
        result := na
    result
 
var array<label> labels = array.new<label>()
var line oneLineRef = na
 
f_deleteLabels(array<label> labelArray) =>
    int labelCount = array.size(labelArray)
    if labelCount > 0
        for i = 0 to labelCount - 1
            label.delete(array.get(labelArray, i))
        array.clear(labelArray)
 
f_addLabel(array<label> labelArray, float y, string txt, color bgColor) =>
    if not na(y)
        float finalY = f_getSafeLabelY(y, showOneLine, oneLineValue, oneLineLabelPadding)
        label newLabel = label.new(
             x         = bar_index,
             y         = finalY,
             text      = txt,
             style     = label.style_label_left,
             textcolor = C_TEXT, // SİYAH YAZI FONTU
             color     = bgColor,
             size      = size.small
        )
        array.push(labelArray, newLabel)
 
if barstate.islast
    f_deleteLabels(labels)
    oneLineRef := f_updateHorizontalLine(oneLineRef, showOneLine, oneLineValue, C_ONE, oneLineLookbackBars, oneLineLabelGapBars)
 
    if showLabels
        f_addLabel(labels, btcDistance,     'BTCUSD  ' + str.tostring(btcDistance, '#.##') + '%', C_BTC)
        f_addLabel(labels, total3Distance,  'TOTAL3  ' + str.tostring(total3Distance, '#.##') + '%', C_TOTAL3)
        f_addLabel(labels, currentDistance, syminfo.ticker + '  ' + str.tostring(currentDistance, '#.##') + '%', C_CURRENT)
 
        if en01 and not na(d01)
            f_addLabel(labels, d01, f_cleanTicker(s01) + '  ' + str.tostring(d01, '#.##') + '%', col01)
        if en02 and not na(d02)
            f_addLabel(labels, d02, f_cleanTicker(s02) + '  ' + str.tostring(d02, '#.##') + '%', col02)
        if en03 and not na(d03)
            f_addLabel(labels, d03, f_cleanTicker(s03) + '  ' + str.tostring(d03, '#.##') + '%', col03)
        if en04 and not na(d04)
            f_addLabel(labels, d04, f_cleanTicker(s04) + '  ' + str.tostring(d04, '#.##') + '%', col04)
        if en05 and not na(d05)
            f_addLabel(labels, d05, f_cleanTicker(s05) + '  ' + str.tostring(d05, '#.##') + '%', col05)
        if en06 and not na(d06)
            f_addLabel(labels, d06, f_cleanTicker(s06) + '  ' + str.tostring(d06, '#.##') + '%', col06)
        if en07 and not na(d07)
            f_addLabel(labels, d07, f_cleanTicker(s07) + '  ' + str.tostring(d07, '#.##') + '%', col07)
        if en08 and not na(d08)
            f_addLabel(labels, d08, f_cleanTicker(s08) + '  ' + str.tostring(d08, '#.##') + '%', col08)
        if en09 and not na(d09)
            f_addLabel(labels, d09, f_cleanTicker(s09) + '  ' + str.tostring(d09, '#.##') + '%', col09)
        if en10 and not na(d10)
            f_addLabel(labels, d10, f_cleanTicker(s10) + '  ' + str.tostring(d10, '#.##') + '%', col10)
        if en11 and not na(d11)
            f_addLabel(labels, d11, f_cleanTicker(s11) + '  ' + str.tostring(d11, '#.##') + '%', col11)
        if en12 and not na(d12)
            f_addLabel(labels, d12, f_cleanTicker(s12) + '  ' + str.tostring(d12, '#.##') + '%', col12)
        if en13 and not na(d13)
            f_addLabel(labels, d13, f_cleanTicker(s13) + '  ' + str.tostring(d13, '#.##') + '%', col13)
        if en14 and not na(d14)
            f_addLabel(labels, d14, f_cleanTicker(s14) + '  ' + str.tostring(d14, '#.##') + '%', col14)
        if en15 and not na(d15)
            f_addLabel(labels, d15, f_cleanTicker(s15) + '  ' + str.tostring(d15, '#.##') + '%', col15)
        if en16 and not na(d16)
            f_addLabel(labels, d16, f_cleanTicker(s16) + '  ' + str.tostring(d16, '#.##') + '%', col16)
        if en17 and not na(d17)
            f_addLabel(labels, d17, f_cleanTicker(s17) + '  ' + str.tostring(d17, '#.##') + '%', col17)
        if en18 and not na(d18)
            f_addLabel(labels, d18, f_cleanTicker(s18) + '  ' + str.tostring(d18, '#.##') + '%', col18)
        if en19 and not na(d19)
            f_addLabel(labels, d19, f_cleanTicker(s19) + '  ' + str.tostring(d19, '#.##') + '%', col19)
        if en20 and not na(d20)
            f_addLabel(labels, d20, f_cleanTicker(s20) + '  ' + str.tostring(d20, '#.##') + '%', col20)
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// CANLI TAKİP TABLOSU (İKİYE BÖLÜNMÜŞ 6 SÜTUNLU IZGARA)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
f_getTableFontSize(string s) =>
    s == 'Çok Küçük (Tiny)' ? size.tiny :
     s == 'Küçük (Small)'    ? size.small :
     s == 'Normal (Normal)'  ? size.normal :
     s == 'Büyük (Large)'    ? size.large : size.small
 
f_renderCellGroup(table tbl, int startCol, int rowIdx, string symName, float distVal, int lastCrossTime, string crossMsg, color crossCol, color symCol, string txtSize) =>
    bool isBlink = (timenow - lastCrossTime) <= 5000 and lastCrossTime > 0
    bool flashState = ((timenow - lastCrossTime) / 300) % 2 == 0
    
    color bgSignal = isBlink ? (flashState ? color.new(crossCol, 15) : color.new(color.yellow, 15)) : color.new(#181a20, 20)
    color txtSignalColor = isBlink ? color.black : (crossMsg == '-' ? color.gray : color.white)
    string statusText = isBlink ? '⚡ ' + crossMsg : crossMsg
 
    table.cell(tbl, startCol + 0, rowIdx, symName, bgcolor = color.new(#131722, 10), text_color = symCol, text_size = txtSize)
    table.cell(tbl, startCol + 1, rowIdx, not na(distVal) ? str.tostring(distVal, '#.##') + '%' : '-', bgcolor = color.new(#131722, 10), text_color = color.white, text_size = txtSize)
    table.cell(tbl, startCol + 2, rowIdx, statusText, bgcolor = bgSignal, text_color = txtSignalColor, text_size = txtSize)
 
var table dash = na
 
if barstate.islast and showTable
    if not na(dash)
        table.delete(dash)
 
    string pos = tablePosInput == 'Sol Üst'   ? position.top_left :
                 tablePosInput == 'Sol Orta'  ? position.middle_left :
                 tablePosInput == 'Sol Alt'   ? position.bottom_left :
                 tablePosInput == 'Sağ Üst'   ? position.top_right :
                 tablePosInput == 'Sağ Orta'  ? position.middle_right : position.bottom_right
 
    string tSize = f_getTableFontSize(tableFontSizeInput)
 
    // 6 Sütun (Sol blok: 0,1,2 | Sağ blok: 3,4,5) x 13 Satır
    dash := table.new(pos, 6, 13, bgcolor = color.new(#0b0e14, 10), border_color = color.new(color.gray, 70), border_width = 1)
 
    // Başlıklar
    table.cell(dash, 0, 0, 'Sembol', bgcolor = color.new(#1f2430, 0), text_color = color.white, text_size = tSize)
    table.cell(dash, 1, 0, 'Fark %', bgcolor = color.new(#1f2430, 0), text_color = color.white, text_size = tSize)
    table.cell(dash, 2, 0, 'Sinyal', bgcolor = color.new(#1f2430, 0), text_color = color.white, text_size = tSize)
 
    table.cell(dash, 3, 0, 'Sembol', bgcolor = color.new(#1f2430, 0), text_color = color.white, text_size = tSize)
    table.cell(dash, 4, 0, 'Fark %', bgcolor = color.new(#1f2430, 0), text_color = color.white, text_size = tSize)
    table.cell(dash, 5, 0, 'Sinyal', bgcolor = color.new(#1f2430, 0), text_color = color.white, text_size = tSize)
 
    // SOL BLOK DOLDURMA (CURRENT + 01-10)
    int rL = 1
    f_renderCellGroup(dash, 0, rL, '▶ ' + syminfo.ticker, currentDistance, tCur, msgCur, colCur, C_CURRENT, tSize), rL += 1
    if en01
        f_renderCellGroup(dash, 0, rL, f_cleanTicker(s01), d01, t01, msg01, col01_cr, col01, tSize), rL += 1
    if en02
        f_renderCellGroup(dash, 0, rL, f_cleanTicker(s02), d02, t02, msg02, col02_cr, col02, tSize), rL += 1
    if en03
        f_renderCellGroup(dash, 0, rL, f_cleanTicker(s03), d03, t03, msg03, col03_cr, col03, tSize), rL += 1
    if en04
        f_renderCellGroup(dash, 0, rL, f_cleanTicker(s04), d04, t04, msg04, col04_cr, col04, tSize), rL += 1
    if en05
        f_renderCellGroup(dash, 0, rL, f_cleanTicker(s05), d05, t05, msg05, col05_cr, col05, tSize), rL += 1
    if en06
        f_renderCellGroup(dash, 0, rL, f_cleanTicker(s06), d06, t06, msg06, col06_cr, col06, tSize), rL += 1
    if en07
        f_renderCellGroup(dash, 0, rL, f_cleanTicker(s07), d07, t07, msg07, col07_cr, col07, tSize), rL += 1
    if en08
        f_renderCellGroup(dash, 0, rL, f_cleanTicker(s08), d08, t08, msg08, col08_cr, col08, tSize), rL += 1
    if en09
        f_renderCellGroup(dash, 0, rL, f_cleanTicker(s09), d09, t09, msg09, col09_cr, col09, tSize), rL += 1
    if en10
        f_renderCellGroup(dash, 0, rL, f_cleanTicker(s10), d10, t10, msg10, col10_cr, col10, tSize), rL += 1
 
    // SAĞ BLOK DOLDURMA (11-20)
    int rR = 1
    if en11
        f_renderCellGroup(dash, 3, rR, f_cleanTicker(s11), d11, t11, msg11, col11_cr, col11, tSize), rR += 1
    if en12
        f_renderCellGroup(dash, 3, rR, f_cleanTicker(s12), d12, t12, msg12, col12_cr, col12, tSize), rR += 1
    if en13
        f_renderCellGroup(dash, 3, rR, f_cleanTicker(s13), d13, t13, msg13, col13_cr, col13, tSize), rR += 1
    if en14
        f_renderCellGroup(dash, 3, rR, f_cleanTicker(s14), d14, t14, msg14, col14_cr, col14, tSize), rR += 1
    if en15
        f_renderCellGroup(dash, 3, rR, f_cleanTicker(s15), d15, t15, msg15, col15_cr, col15, tSize), rR += 1
    if en16
        f_renderCellGroup(dash, 3, rR, f_cleanTicker(s16), d16, t16, msg16, col16_cr, col16, tSize), rR += 1
    if en17
        f_renderCellGroup(dash, 3, rR, f_cleanTicker(s17), d17, t17, msg17, col17_cr, col17, tSize), rR += 1
    if en18
        f_renderCellGroup(dash, 3, rR, f_cleanTicker(s18), d18, t18, msg18, col18_cr, col18, tSize), rR += 1
    if en19
        f_renderCellGroup(dash, 3, rR, f_cleanTicker(s19), d19, t19, msg19, col19_cr, col19, tSize), rR += 1
    if en20
        f_renderCellGroup(dash, 3, rR, f_cleanTicker(s20), d20, t20, msg20, col20_cr, col20, tSize), rR += 1

← 返回列表