Untitled

 avatar
unknown
plain_text
a month ago
71 kB
10
Indexable
//@version=6
indicator(title = 'SCY Hacim Trend Analizi', shorttitle = 'SCY Hacim Trend Analizi', overlay = true)

//Source
BHsrc = input(close, title = 'Source')

//Inputs ////////////
heikin = input(false, 'Heikin Ashi Candles?')
ShowDL = false
ShowVV = false
ShowRV = false
RVLength = input.int(21, 'Volume MA Length', minval = 1)
ShowRVBars = input(true, 'Paint High Relative Volume Bars?')
RValue = input(3, 'Relative Volume for Bars?')
LabelS = input.string(title = 'Label Size', defval = 'Normal', options = ['Tiny', 'Small', 'Normal', 'Large', 'Huge'])
label_size = LabelS == 'Tiny' ? size.tiny : LabelS == 'Small' ? size.small : LabelS == 'Normal' ? size.normal : LabelS == 'Large' ? size.large : LabelS == 'Huge' ? size.huge : size.normal

// Table options
showDailyTable = input(true, 'Günlük Tablo Göster')
tablePosition = input.string(position.top_right, 'Tablo Pozisyonu', options = [position.top_left, position.top_right, position.bottom_left, position.bottom_right])
tableSize = input.string(title = 'Tablo Boyutu', defval = 'Normal', options = ['Tiny', 'Small', 'Normal', 'Large', 'Huge'])
table_size = tableSize == 'Tiny' ? size.tiny : tableSize == 'Small' ? size.small : tableSize == 'Normal' ? size.normal : tableSize == 'Large' ? size.large : tableSize == 'Huge' ? size.huge : size.normal

// Buy-Sell difference alert thresholds
diffAlertPercentage = input.float(20.0, 'Alım-Satım Farkı Yüzde Eşiği', minval = 0.0, step = 0.1)
diffAlertVolume = input.float(100000, 'Alım-Satım Farkı Hacim Eşiği', minval = 0.0, step = 1000)
positiveDiffAlert = input(true, 'Pozitif Fark Alarmı (Alım > Satım)')
negativeDiffAlert = input(true, 'Negatif Fark Alarmı (Satım > Alım)')

// Percentage difference thresholds
diffPctIncreaseThreshold = input.float(10.0, 'Yüzde Fark Artış Eşiği', minval = 0.0, step = 0.1)
diffPctDecreaseThreshold = input.float(10.0, 'Yüzde Fark Azalış Eşiği', minval = 0.0, step = 0.1)
diffPctChangeAlert = input(true, 'Yüzde Fark Değişim Alarmı')

Bopen = heikin ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open) : open
Bclose = heikin ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, BHsrc) : BHsrc
Blow = heikin ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low) : low
Bhigh = heikin ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high) : high

string Bstr = ''
string DPBstr = ''
string Sstr = ''
string DPSstr = ''
string TVol = ''
string RVolTB = ''
string RVolTS = ''

//Buy - Sell Volume
BuyVol = nz(math.round(Bhigh == Blow ? 0 : volume * (Bclose - Blow) / (Bhigh - Blow)))
SellVol = nz(math.round(Bhigh == Blow ? 0 : volume * (Bhigh - Bclose) / (Bhigh - Blow)))

// Calculate Buy-Sell Difference
VolDiff = BuyVol - SellVol
VolDiffPct = (BuyVol - SellVol) / (BuyVol + SellVol) * 100

//Buy-Sell Volume Percent Calculation ////////////
BuyVolumePercent = nz(100 * BuyVol / (BuyVol + SellVol))
SellVolumePercent = nz(100 * SellVol / (BuyVol + SellVol))

//Total Volume Calculation ////////////
if str.length(str.tostring(volume)) >= 10 and str.length(str.tostring(volume)) <= 12
    TVol := str.tostring(volume / 1000000000, '###.###') + 'B'
    TVol

if str.length(str.tostring(volume)) >= 7 and str.length(str.tostring(volume)) <= 9
    TVol := str.tostring(volume / 1000000, '###.###') + 'M'
    TVol

if str.length(str.tostring(volume)) < 7
    TVol := str.tostring(volume / 1000) + 'K'
    TVol

if str.length(str.tostring(volume)) < 4
    TVol := str.tostring(volume)
    TVol

//Buy-Sell Volume Calculation ////////////
//Buy Volume Billions Calculation
if BuyVolumePercent > 0 and str.length(str.tostring(BuyVol)) >= 10 and str.length(str.tostring(SellVol)) <= 12 and ShowVV
    Bstr := ' - ' + str.tostring(BuyVol / 1000000000, '###.###') + 'B'
    DPBstr := str.tostring(BuyVol / 1000000000, '###.###') + 'B'
    DPBstr

//Sell Volume Billions Calculation
if SellVolumePercent > 0 and str.length(str.tostring(SellVol)) >= 10 and str.length(str.tostring(SellVol)) <= 12 and ShowVV
    Sstr := ' - ' + str.tostring(SellVol / 1000000000, '###.###') + 'B'
    DPSstr := str.tostring(SellVol / 1000000000, '###.###') + 'B'
    DPSstr

//Buy Volume Millions Calculation
if BuyVolumePercent > 0 and str.length(str.tostring(BuyVol)) >= 7 and str.length(str.tostring(SellVol)) <= 9 and ShowVV
    Bstr := ' - ' + str.tostring(BuyVol / 1000000, '###.###') + 'M'
    DPBstr := str.tostring(BuyVol / 1000000, '###.###') + 'M'
    DPBstr

//Sell Volume Millions Calculation
if SellVolumePercent > 0 and str.length(str.tostring(SellVol)) >= 7 and str.length(str.tostring(SellVol)) <= 9 and ShowVV
    Sstr := ' - ' + str.tostring(SellVol / 1000000, '###.###') + 'M'
    DPSstr := str.tostring(SellVol / 1000000, '###.###') + 'M'
    DPSstr

//Buy Volume Thousands Calculation
if BuyVolumePercent > 0 and str.length(str.tostring(BuyVol)) < 7 and ShowVV
    Bstr := ' - ' + str.tostring(BuyVol / 1000) + 'K'
    DPBstr := str.tostring(BuyVol / 1000) + 'K'
    DPBstr

//Sell Thousands Calculation
if SellVolumePercent > 0 and str.length(str.tostring(SellVol)) < 7 and ShowVV
    Sstr := ' - ' + str.tostring(SellVol / 1000) + 'K'
    DPSstr := str.tostring(SellVol / 1000) + 'K'
    DPSstr

//Buy Volume less than a thousand 
if BuyVolumePercent > 0 and str.length(str.tostring(BuyVol)) < 4 and ShowVV
    Bstr := ' - ' + str.tostring(BuyVol)
    DPBstr := str.tostring(BuyVol)
    DPBstr

//Sell Volume less than a thousand 
if SellVolumePercent > 0 and str.length(str.tostring(SellVol)) < 4 and ShowVV
    Sstr := ' - ' + str.tostring(SellVol)
    DPSstr := str.tostring(SellVol)
    DPSstr

if BuyVolumePercent == 0 and ShowVV
    DPBstr := '0'
    DPBstr

if SellVolumePercent == 0 and ShowVV
    DPSstr := '0'
    DPSstr

//Relative Volume Calculation ////////////
AVol = ta.sma(volume, RVLength)
RVol = volume / AVol

//Relative Volume Label Value ////////////
if ShowDL
    RVolTB := ShowRV and Bclose > Bopen ? str.tostring(RVol, '##.#') : na
    RVolTS := ShowRV and Bclose < Bopen ? str.tostring(RVol, '##.#') : na
    RVolTS
else
    RVolTB := ShowRV and Bclose > Bopen ? str.tostring(RVol, '##.#') + ' - ' : na
    RVolTS := ShowRV and Bclose < Bopen ? str.tostring(RVol, '##.#') + ' - ' : na
    RVolTS

// Format date for table (DD.MM format for Turkish style)
format_date(bar_time) =>
    y = year(bar_time)
    m = month(bar_time)
    d = dayofmonth(bar_time)
    day_month = str.tostring(d, '00') + '.' + str.tostring(m, '00')
    day_month

// Format volume values
format_volume(vol) =>
    vol_text = ''
    if vol == 0
        vol_text := '0'
        vol_text
    else if str.length(str.tostring(vol)) >= 10
        vol_text := str.tostring(vol / 1000000000, '###.###') + 'B'
        vol_text
    else if str.length(str.tostring(vol)) >= 7
        vol_text := str.tostring(vol / 1000000, '###.###') + 'M'
        vol_text
    else if str.length(str.tostring(vol)) >= 4
        vol_text := str.tostring(vol / 1000) + 'K'
        vol_text
    else
        vol_text := str.tostring(vol)
        vol_text
    vol_text

// Format difference values
format_difference(diff) =>
    string diff_text = ''
    diff_abs = math.abs(diff)
    prefix = diff > 0 ? '+' : diff < 0 ? '-' : ''
    
    if diff_abs == 0
        diff_text := '0'
        diff_text
    else if str.length(str.tostring(diff_abs)) >= 10
        diff_text := prefix + str.tostring(diff_abs / 1000000000, '###.###') + 'B'
        diff_text
    else if str.length(str.tostring(diff_abs)) >= 7
        diff_text := prefix + str.tostring(diff_abs / 1000000, '###.###') + 'M'
        diff_text
    else if str.length(str.tostring(diff_abs)) >= 4
        diff_text := prefix + str.tostring(diff_abs / 1000) + 'K'
        diff_text
    else
        diff_text := prefix + str.tostring(diff_abs)
        diff_text
    diff_text

// Format RVol values with check for NaN
format_rvol(rvol) =>
    string rvol_text = ''
    if na(rvol) or rvol <= 0
        rvol_text := '-'
        rvol_text
    else
        rvol_text := str.tostring(rvol, '##.##')
        rvol_text
    rvol_text

// Store RVol values for each bar (Extended to 12 days)
var float rvol0 = na
var float rvol1 = na
var float rvol2 = na
var float rvol3 = na
var float rvol4 = na
var float rvol5 = na
var float rvol6 = na
var float rvol7 = na
var float rvol8 = na
var float rvol9 = na
var float rvol10 = na
var float rvol11 = na

// Store buy percentages for each day (Extended to 12 days)
var float buy_pct_day0 = na
var float buy_pct_day1 = na
var float buy_pct_day2 = na
var float buy_pct_day3 = na
var float buy_pct_day4 = na
var float buy_pct_day5 = na
var float buy_pct_day6 = na
var float buy_pct_day7 = na
var float buy_pct_day8 = na
var float buy_pct_day9 = na
var float buy_pct_day10 = na
var float buy_pct_day11 = na

// Store volume differences for each day
var float vol_diff_day0 = na
var float vol_diff_day1 = na
var float vol_diff_day2 = na
var float vol_diff_day3 = na
var float vol_diff_day4 = na
var float vol_diff_day5 = na
var float vol_diff_day6 = na
var float vol_diff_day7 = na
var float vol_diff_day8 = na
var float vol_diff_day9 = na
var float vol_diff_day10 = na
var float vol_diff_day11 = na

// Store volume difference percentages for each day
var float vol_diff_pct_day0 = na
var float vol_diff_pct_day1 = na
var float vol_diff_pct_day2 = na
var float vol_diff_pct_day3 = na
var float vol_diff_pct_day4 = na
var float vol_diff_pct_day5 = na
var float vol_diff_pct_day6 = na
var float vol_diff_pct_day7 = na
var float vol_diff_pct_day8 = na
var float vol_diff_pct_day9 = na
var float vol_diff_pct_day10 = na
var float vol_diff_pct_day11 = na

// Calculate RVol value for each bar and store (Extended to 12 days)
rvol0 := RVol
rvol1 := rvol0[1]
rvol2 := rvol1[1]
rvol3 := rvol2[1]
rvol4 := rvol3[1]
rvol5 := rvol4[1]
rvol6 := rvol5[1]
rvol7 := rvol6[1]
rvol8 := rvol7[1]
rvol9 := rvol8[1]
rvol10 := rvol9[1]
rvol11 := rvol10[1]

// Calculate volume metrics for a specific day
get_day_vol_data(idx) =>
    h = high[idx]
    l = low[idx]
    c = close[idx]
    o = open[idx]
    vol = volume[idx]

    buy_vol = nz(math.round(h == l ? 0 : vol * (c - l) / (h - l)))
    sell_vol = nz(math.round(h == l ? 0 : vol * (h - c) / (h - l)))
    vol_diff = buy_vol - sell_vol
    vol_diff_pct = vol > 0 ? (buy_vol - sell_vol) / (buy_vol + sell_vol) * 100 : 0.0

    buy_pct = nz(100 * buy_vol / (buy_vol + sell_vol))
    sell_pct = nz(100 * sell_vol / (buy_vol + sell_vol))

    // Use stored RVol values (Extended to 12 days)
    float rel_vol = na
    if idx == 0
        rel_vol := rvol0
    else if idx == 1
        rel_vol := rvol1
    else if idx == 2
        rel_vol := rvol2
    else if idx == 3
        rel_vol := rvol3
    else if idx == 4
        rel_vol := rvol4
    else if idx == 5
        rel_vol := rvol5
    else if idx == 6
        rel_vol := rvol6
    else if idx == 7
        rel_vol := rvol7
    else if idx == 8
        rel_vol := rvol8
    else if idx == 9
        rel_vol := rvol9
    else if idx == 10
        rel_vol := rvol10
    else if idx == 11
        rel_vol := rvol11

    [h, l, c, o, vol, buy_vol, sell_vol, buy_pct, sell_pct, rel_vol, vol_diff, vol_diff_pct]

// Create table for the last 12 days
if barstate.islast and showDailyTable
    // Create table with more rows (13 instead of 8: 1 header + 12 data rows)
    var table daily_table = table.new(tablePosition, columns = 8, rows = 13, border_width = 1)

    // Clear the table
    table.clear(daily_table, 0, 0)

    // Add header row
    // table.cell(daily_table, 0, 0, text = 'Tarih', bgcolor = color.new(color.blue, 90), text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 1, 0, text = 'Alış %', bgcolor = color.new(color.blue, 90), text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 2, 0, text = 'Alış Lot', bgcolor = color.new(color.blue, 90), text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 3, 0, text = 'Satış %', bgcolor = color.new(color.blue, 90), text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 4, 0, text = 'Satış Lot', bgcolor = color.new(color.blue, 90), text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 5, 0, text = 'Fark', bgcolor = color.new(color.blue, 90), text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 6, 0, text = 'Fark %', bgcolor = color.new(color.blue, 90), text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 7, 0, text = 'RVol', bgcolor = color.new(color.blue, 90), text_color = color.white, text_size = table_size)

    // Fill each row manually for all 12 days
    
    // Day 0 (Today)
    [h0, l0, c0, o0, vol0, buy_vol0, sell_vol0, buy_pct0, sell_pct0, rel_vol0, vol_diff0, vol_diff_pct0] = get_day_vol_data(0)
    date_val0 = format_date(time[0])
    is_bullish0 = c0 > o0
    buy_vol_txt0 = format_volume(buy_vol0)
    sell_vol_txt0 = format_volume(sell_vol0)
    vol_diff_txt0 = format_difference(vol_diff0)
    date_color0 = is_bullish0 ? color.new(color.green, 80) : color.new(color.red, 80)
    buy_color0 = buy_pct0 > 50 ? color.new(color.green, 85) : color.new(color.gray, 90)
    sell_color0 = sell_pct0 > 50 ? color.new(color.red, 85) : color.new(color.gray, 90)
    diff_color0 = vol_diff0 > 0 ? color.new(color.green, 85) : vol_diff0 < 0 ? color.new(color.red, 85) : color.new(color.gray, 90)
    diff_pct_color0 = vol_diff_pct0 > 0 ? color.new(color.green, 85) : vol_diff_pct0 < 0 ? color.new(color.red, 85) : color.new(color.gray, 90)
    rvol_color0 = na(rel_vol0) ? color.new(color.gray, 90) : rel_vol0 > RValue ? color.new(color.yellow, 80) : color.new(color.gray, 90)
    
    // Store the values
    buy_pct_day0 := buy_pct0
    vol_diff_day0 := vol_diff0
    vol_diff_pct_day0 := vol_diff_pct0
    
    // table.cell(daily_table, 0, 1, text = date_val0, bgcolor = date_color0, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 1, 1, text = '%' + str.tostring(buy_pct0, '#'), bgcolor = buy_color0, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 2, 1, text = buy_vol_txt0, bgcolor = buy_color0, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 3, 1, text = '%' + str.tostring(sell_pct0, '#'), bgcolor = sell_color0, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 4, 1, text = sell_vol_txt0, bgcolor = sell_color0, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 5, 1, text = vol_diff_txt0, bgcolor = diff_color0, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 6, 1, text = vol_diff_pct0 > 0 ? '+' + str.tostring(vol_diff_pct0, '#.#') + '%' : str.tostring(vol_diff_pct0, '#.#') + '%', bgcolor = diff_pct_color0, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 7, 1, text = format_rvol(rel_vol0), bgcolor = rvol_color0, text_color = color.white, text_size = table_size)

    // Day 1 (Yesterday)
    [h1, l1, c1, o1, vol1, buy_vol1, sell_vol1, buy_pct1, sell_pct1, rel_vol1, vol_diff1, vol_diff_pct1] = get_day_vol_data(1)
    date_val1 = format_date(time[1])
    is_bullish1 = c1 > o1
    buy_vol_txt1 = format_volume(buy_vol1)
    sell_vol_txt1 = format_volume(sell_vol1)
    vol_diff_txt1 = format_difference(vol_diff1)
    date_color1 = is_bullish1 ? color.new(color.green, 80) : color.new(color.red, 80)
    buy_color1 = buy_pct1 > 50 ? color.new(color.green, 85) : color.new(color.gray, 90)
    sell_color1 = sell_pct1 > 50 ? color.new(color.red, 85) : color.new(color.gray, 90)
    diff_color1 = vol_diff1 > 0 ? color.new(color.green, 85) : vol_diff1 < 0 ? color.new(color.red, 85) : color.new(color.gray, 90)
    diff_pct_color1 = vol_diff_pct1 > 0 ? color.new(color.green, 85) : vol_diff_pct1 < 0 ? color.new(color.red, 85) : color.new(color.gray, 90)
    rvol_color1 = na(rel_vol1) ? color.new(color.gray, 90) : rel_vol1 > RValue ? color.new(color.yellow, 80) : color.new(color.gray, 90)
    
    // Store the values
    buy_pct_day1 := buy_pct1
    vol_diff_day1 := vol_diff1
    vol_diff_pct_day1 := vol_diff_pct1
    
    // table.cell(daily_table, 0, 2, text = date_val1, bgcolor = date_color1, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 1, 2, text = '%' + str.tostring(buy_pct1, '#'), bgcolor = buy_color1, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 2, 2, text = buy_vol_txt1, bgcolor = buy_color1, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 3, 2, text = '%' + str.tostring(sell_pct1, '#'), bgcolor = sell_color1, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 4, 2, text = sell_vol_txt1, bgcolor = sell_color1, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 5, 2, text = vol_diff_txt1, bgcolor = diff_color1, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 6, 2, text = vol_diff_pct1 > 0 ? '+' + str.tostring(vol_diff_pct1, '#.#') + '%' : str.tostring(vol_diff_pct1, '#.#') + '%', bgcolor = diff_pct_color1, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 7, 2, text = format_rvol(rel_vol1), bgcolor = rvol_color1, text_color = color.white, text_size = table_size)

    // Day 2
    [h2, l2, c2, o2, vol2, buy_vol2, sell_vol2, buy_pct2, sell_pct2, rel_vol2, vol_diff2, vol_diff_pct2] = get_day_vol_data(2)
    date_val2 = format_date(time[2])
    is_bullish2 = c2 > o2
    buy_vol_txt2 = format_volume(buy_vol2)
    sell_vol_txt2 = format_volume(sell_vol2)
    vol_diff_txt2 = format_difference(vol_diff2)
    date_color2 = is_bullish2 ? color.new(color.green, 80) : color.new(color.red, 80)
    buy_color2 = buy_pct2 > 50 ? color.new(color.green, 85) : color.new(color.gray, 90)
    sell_color2 = sell_pct2 > 50 ? color.new(color.red, 85) : color.new(color.gray, 90)
    diff_color2 = vol_diff2 > 0 ? color.new(color.green, 85) : vol_diff2 < 0 ? color.new(color.red, 85) : color.new(color.gray, 90)
    diff_pct_color2 = vol_diff_pct2 > 0 ? color.new(color.green, 85) : vol_diff_pct2 < 0 ? color.new(color.red, 85) : color.new(color.gray, 90)
    rvol_color2 = na(rel_vol2) ? color.new(color.gray, 90) : rel_vol2 > RValue ? color.new(color.yellow, 80) : color.new(color.gray, 90)
    
    // Store the values
    buy_pct_day2 := buy_pct2
    vol_diff_day2 := vol_diff2
    vol_diff_pct_day2 := vol_diff_pct2
    
// ö
    // Day 3
    [h3, l3, c3, o3, vol3, buy_vol3, sell_vol3, buy_pct3, sell_pct3, rel_vol3, vol_diff3, vol_diff_pct3] = get_day_vol_data(3)
    date_val3 = format_date(time[3])
    is_bullish3 = c3 > o3
    buy_vol_txt3 = format_volume(buy_vol3)
    sell_vol_txt3 = format_volume(sell_vol3)
    vol_diff_txt3 = format_difference(vol_diff3)
    date_color3 = is_bullish3 ? color.new(color.green, 80) : color.new(color.red, 80)
    buy_color3 = buy_pct3 > 50 ? color.new(color.green, 85) : color.new(color.gray, 90)
    sell_color3 = sell_pct3 > 50 ? color.new(color.red, 85) : color.new(color.gray, 90)
    diff_color3 = vol_diff3 > 0 ? color.new(color.green, 85) : vol_diff3 < 0 ? color.new(color.red, 85) : color.new(color.gray, 90)
    diff_pct_color3 = vol_diff_pct3 > 0 ? color.new(color.green, 85) : vol_diff_pct3 < 0 ? color.new(color.red, 85) : color.new(color.gray, 90)
    rvol_color3 = na(rel_vol3) ? color.new(color.gray, 90) : rel_vol3 > RValue ? color.new(color.yellow, 80) : color.new(color.gray, 90)
    
    // Store the values
    buy_pct_day3 := buy_pct3
    vol_diff_day3 := vol_diff3
    vol_diff_pct_day3 := vol_diff_pct3
    
    // table.cell(daily_table, 0, 4, text = date_val3, bgcolor = date_color3, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 1, 4, text = '%' + str.tostring(buy_pct3, '#'), bgcolor = buy_color3, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 2, 4, text = buy_vol_txt3, bgcolor = buy_color3, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 3, 4, text = '%' + str.tostring(sell_pct3, '#'), bgcolor = sell_color3, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 4, 4, text = sell_vol_txt3, bgcolor = sell_color3, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 5, 4, text = vol_diff_txt3, bgcolor = diff_color3, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 6, 4, text = vol_diff_pct3 > 0 ? '+' + str.tostring(vol_diff_pct3, '#.#') + '%' : str.tostring(vol_diff_pct3, '#.#') + '%', bgcolor = diff_pct_color3, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 7, 4, text = format_rvol(rel_vol3), bgcolor = rvol_color3, text_color = color.white, text_size = table_size)

    // Day 4
    [h4, l4, c4, o4, vol4, buy_vol4, sell_vol4, buy_pct4, sell_pct4, rel_vol4, vol_diff4, vol_diff_pct4] = get_day_vol_data(4)
    date_val4 = format_date(time[4])
    is_bullish4 = c4 > o4
    buy_vol_txt4 = format_volume(buy_vol4)
    sell_vol_txt4 = format_volume(sell_vol4)
    vol_diff_txt4 = format_difference(vol_diff4)
    date_color4 = is_bullish4 ? color.new(color.green, 80) : color.new(color.red, 80)
    buy_color4 = buy_pct4 > 50 ? color.new(color.green, 85) : color.new(color.gray, 90)
    sell_color4 = sell_pct4 > 50 ? color.new(color.red, 85) : color.new(color.gray, 90)
    diff_color4 = vol_diff4 > 0 ? color.new(color.green, 85) : vol_diff4 < 0 ? color.new(color.red, 85) : color.new(color.gray, 90)
    diff_pct_color4 = vol_diff_pct4 > 0 ? color.new(color.green, 85) : vol_diff_pct4 < 0 ? color.new(color.red, 85) : color.new(color.gray, 90)
    rvol_color4 = na(rel_vol4) ? color.new(color.gray, 90) : rel_vol4 > RValue ? color.new(color.yellow, 80) : color.new(color.gray, 90)
    
    // Store the values
    buy_pct_day4 := buy_pct4
    vol_diff_day4 := vol_diff4
    vol_diff_pct_day4 := vol_diff_pct4
    
    // table.cell(daily_table, 0, 5, text = date_val4, bgcolor = date_color4, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 1, 5, text = '%' + str.tostring(buy_pct4, '#'), bgcolor = buy_color4, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 2, 5, text = buy_vol_txt4, bgcolor = buy_color4, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 3, 5, text = '%' + str.tostring(sell_pct4, '#'), bgcolor = sell_color4, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 4, 5, text = sell_vol_txt4, bgcolor = sell_color4, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 5, 5, text = vol_diff_txt4, bgcolor = diff_color4, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 6, 5, text = vol_diff_pct4 > 0 ? '+' + str.tostring(vol_diff_pct4, '#.#') + '%' : str.tostring(vol_diff_pct4, '#.#') + '%', bgcolor = diff_pct_color4, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 7, 5, text = format_rvol(rel_vol4), bgcolor = rvol_color4, text_color = color.white, text_size = table_size)

    // Day 5
    [h5, l5, c5, o5, vol5, buy_vol5, sell_vol5, buy_pct5, sell_pct5, rel_vol5, vol_diff5, vol_diff_pct5] = get_day_vol_data(5)
    date_val5 = format_date(time[5])
    is_bullish5 = c5 > o5
    buy_vol_txt5 = format_volume(buy_vol5)
    sell_vol_txt5 = format_volume(sell_vol5)
    vol_diff_txt5 = format_difference(vol_diff5)
    date_color5 = is_bullish5 ? color.new(color.green, 80) : color.new(color.red, 80)
    buy_color5 = buy_pct5 > 50 ? color.new(color.green, 85) : color.new(color.gray, 90)
    sell_color5 = sell_pct5 > 50 ? color.new(color.red, 85) : color.new(color.gray, 90)
    diff_color5 = vol_diff5 > 0 ? color.new(color.green, 85) : vol_diff5 < 0 ? color.new(color.red, 85) : color.new(color.gray, 90)
    diff_pct_color5 = vol_diff_pct5 > 0 ? color.new(color.green, 85) : vol_diff_pct5 < 0 ? color.new(color.red, 85) : color.new(color.gray, 90)
    rvol_color5 = na(rel_vol5) ? color.new(color.gray, 90) : rel_vol5 > RValue ? color.new(color.yellow, 80) : color.new(color.gray, 90)
    
    // Store the values
    buy_pct_day5 := buy_pct5
    vol_diff_day5 := vol_diff5
    vol_diff_pct_day5 := vol_diff_pct5
    
    // table.cell(daily_table, 0, 6, text = date_val5, bgcolor = date_color5, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 1, 6, text = '%' + str.tostring(buy_pct5, '#'), bgcolor = buy_color5, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 2, 6, text = buy_vol_txt5, bgcolor = buy_color5, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 3, 6, text = '%' + str.tostring(sell_pct5, '#'), bgcolor = sell_color5, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 4, 6, text = sell_vol_txt5, bgcolor = sell_color5, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 5, 6, text = vol_diff_txt5, bgcolor = diff_color5, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 6, 6, text = vol_diff_pct5 > 0 ? '+' + str.tostring(vol_diff_pct5, '#.#') + '%' : str.tostring(vol_diff_pct5, '#.#') + '%', bgcolor = diff_pct_color5, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 7, 6, text = format_rvol(rel_vol5), bgcolor = rvol_color5, text_color = color.white, text_size = table_size)

    // Day 6
    [h6, l6, c6, o6, vol6, buy_vol6, sell_vol6, buy_pct6, sell_pct6, rel_vol6, vol_diff6, vol_diff_pct6] = get_day_vol_data(6)
    date_val6 = format_date(time[6])
    is_bullish6 = c6 > o6
    buy_vol_txt6 = format_volume(buy_vol6)
    sell_vol_txt6 = format_volume(sell_vol6)
    vol_diff_txt6 = format_difference(vol_diff6)
    date_color6 = is_bullish6 ? color.new(color.green, 80) : color.new(color.red, 80)
    buy_color6 = buy_pct6 > 50 ? color.new(color.green, 85) : color.new(color.gray, 90)
    sell_color6 = sell_pct6 > 50 ? color.new(color.red, 85) : color.new(color.gray, 90)
    diff_color6 = vol_diff6 > 0 ? color.new(color.green, 85) : vol_diff6 < 0 ? color.new(color.red, 85) : color.new(color.gray, 90)
    diff_pct_color6 = vol_diff_pct6 > 0 ? color.new(color.green, 85) : vol_diff_pct6 < 0 ? color.new(color.red, 85) : color.new(color.gray, 90)
    rvol_color6 = na(rel_vol6) ? color.new(color.gray, 90) : rel_vol6 > RValue ? color.new(color.yellow, 80) : color.new(color.gray, 90)
    
    // Store the values
    buy_pct_day6 := buy_pct6
    vol_diff_day6 := vol_diff6
    vol_diff_pct_day6 := vol_diff_pct6
    
    // table.cell(daily_table, 0, 7, text = date_val6, bgcolor = date_color6, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 1, 7, text = '%' + str.tostring(buy_pct6, '#'), bgcolor = buy_color6, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 2, 7, text = buy_vol_txt6, bgcolor = buy_color6, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 3, 7, text = '%' + str.tostring(sell_pct6, '#'), bgcolor = sell_color6, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 4, 7, text = sell_vol_txt6, bgcolor = sell_color6, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 5, 7, text = vol_diff_txt6, bgcolor = diff_color6, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 6, 7, text = vol_diff_pct6 > 0 ? '+' + str.tostring(vol_diff_pct6, '#.#') + '%' : str.tostring(vol_diff_pct6, '#.#') + '%', bgcolor = diff_pct_color6, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 7, 7, text = format_rvol(rel_vol6), bgcolor = rvol_color6, text_color = color.white, text_size = table_size)
    
    // Day 7 (new)
    [h7, l7, c7, o7, vol7, buy_vol7, sell_vol7, buy_pct7, sell_pct7, rel_vol7, vol_diff7, vol_diff_pct7] = get_day_vol_data(7)
    date_val7 = format_date(time[7])
    is_bullish7 = c7 > o7
    buy_vol_txt7 = format_volume(buy_vol7)
    sell_vol_txt7 = format_volume(sell_vol7)
    vol_diff_txt7 = format_difference(vol_diff7)
    date_color7 = is_bullish7 ? color.new(color.green, 80) : color.new(color.red, 80)
    buy_color7 = buy_pct7 > 50 ? color.new(color.green, 85) : color.new(color.gray, 90)
    sell_color7 = sell_pct7 > 50 ? color.new(color.red, 85) : color.new(color.gray, 90)
    diff_color7 = vol_diff7 > 0 ? color.new(color.green, 85) : vol_diff7 < 0 ? color.new(color.red, 85) : color.new(color.gray, 90)
    diff_pct_color7 = vol_diff_pct7 > 0 ? color.new(color.green, 85) : vol_diff_pct7 < 0 ? color.new(color.red, 85) : color.new(color.gray, 90)
    rvol_color7 = na(rel_vol7) ? color.new(color.gray, 90) : rel_vol7 > RValue ? color.new(color.yellow, 80) : color.new(color.gray, 90)
    
    // Store the values
    buy_pct_day7 := buy_pct7
    vol_diff_day7 := vol_diff7
    vol_diff_pct_day7 := vol_diff_pct7
    
    // table.cell(daily_table, 0, 8, text = date_val7, bgcolor = date_color7, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 1, 8, text = '%' + str.tostring(buy_pct7, '#'), bgcolor = buy_color7, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 2, 8, text = buy_vol_txt7, bgcolor = buy_color7, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 3, 8, text = '%' + str.tostring(sell_pct7, '#'), bgcolor = sell_color7, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 4, 8, text = sell_vol_txt7, bgcolor = sell_color7, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 5, 8, text = vol_diff_txt7, bgcolor = diff_color7, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 6, 8, text = vol_diff_pct7 > 0 ? '+' + str.tostring(vol_diff_pct7, '#.#') + '%' : str.tostring(vol_diff_pct7, '#.#') + '%', bgcolor = diff_pct_color7, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 7, 8, text = format_rvol(rel_vol7), bgcolor = rvol_color7, text_color = color.white, text_size = table_size)
    
    // Day 8 (new)
    [h8, l8, c8, o8, vol8, buy_vol8, sell_vol8, buy_pct8, sell_pct8, rel_vol8, vol_diff8, vol_diff_pct8] = get_day_vol_data(8)
    date_val8 = format_date(time[8])
    is_bullish8 = c8 > o8
    buy_vol_txt8 = format_volume(buy_vol8)
    sell_vol_txt8 = format_volume(sell_vol8)
    vol_diff_txt8 = format_difference(vol_diff8)
    date_color8 = is_bullish8 ? color.new(color.green, 80) : color.new(color.red, 80)
    buy_color8 = buy_pct8 > 50 ? color.new(color.green, 85) : color.new(color.gray, 90)
    sell_color8 = sell_pct8 > 50 ? color.new(color.red, 85) : color.new(color.gray, 90)
    diff_color8 = vol_diff8 > 0 ? color.new(color.green, 85) : vol_diff8 < 0 ? color.new(color.red, 85) : color.new(color.gray, 90)
    diff_pct_color8 = vol_diff_pct8 > 0 ? color.new(color.green, 85) : vol_diff_pct8 < 0 ? color.new(color.red, 85) : color.new(color.gray, 90)
    rvol_color8 = na(rel_vol8) ? color.new(color.gray, 90) : rel_vol8 > RValue ? color.new(color.yellow, 80) : color.new(color.gray, 90)
    
    // Store the values
    buy_pct_day8 := buy_pct8
    vol_diff_day8 := vol_diff8
    vol_diff_pct_day8 := vol_diff_pct8
    
    // table.cell(daily_table, 0, 9, text = date_val8, bgcolor = date_color8, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 1, 9, text = '%' + str.tostring(buy_pct8, '#'), bgcolor = buy_color8, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 2, 9, text = buy_vol_txt8, bgcolor = buy_color8, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 3, 9, text = '%' + str.tostring(sell_pct8, '#'), bgcolor = sell_color8, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 4, 9, text = sell_vol_txt8, bgcolor = sell_color8, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 5, 9, text = vol_diff_txt8, bgcolor = diff_color8, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 6, 9, text = vol_diff_pct8 > 0 ? '+' + str.tostring(vol_diff_pct8, '#.#') + '%' : str.tostring(vol_diff_pct8, '#.#') + '%', bgcolor = diff_pct_color8, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 7, 9, text = format_rvol(rel_vol8), bgcolor = rvol_color8, text_color = color.white, text_size = table_size)
    
    // Day 9 (new)
    [h9, l9, c9, o9, vol9, buy_vol9, sell_vol9, buy_pct9, sell_pct9, rel_vol9, vol_diff9, vol_diff_pct9] = get_day_vol_data(9)
    date_val9 = format_date(time[9])
    is_bullish9 = c9 > o9
    buy_vol_txt9 = format_volume(buy_vol9)
    sell_vol_txt9 = format_volume(sell_vol9)
    vol_diff_txt9 = format_difference(vol_diff9)
    date_color9 = is_bullish9 ? color.new(color.green, 80) : color.new(color.red, 80)
    buy_color9 = buy_pct9 > 50 ? color.new(color.green, 85) : color.new(color.gray, 90)
    sell_color9 = sell_pct9 > 50 ? color.new(color.red, 85) : color.new(color.gray, 90)
    diff_color9 = vol_diff9 > 0 ? color.new(color.green, 85) : vol_diff9 < 0 ? color.new(color.red, 85) : color.new(color.gray, 90)
    diff_pct_color9 = vol_diff_pct9 > 0 ? color.new(color.green, 85) : vol_diff_pct9 < 0 ? color.new(color.red, 85) : color.new(color.gray, 90)
    rvol_color9 = na(rel_vol9) ? color.new(color.gray, 90) : rel_vol9 > RValue ? color.new(color.yellow, 80) : color.new(color.gray, 90)
    
    // Store the values
    buy_pct_day9 := buy_pct9
    vol_diff_day9 := vol_diff9
    vol_diff_pct_day9 := vol_diff_pct9
    
    // table.cell(daily_table, 0, 10, text = date_val9, bgcolor = date_color9, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 1, 10, text = '%' + str.tostring(buy_pct9, '#'), bgcolor = buy_color9, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 2, 10, text = buy_vol_txt9, bgcolor = buy_color9, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 3, 10, text = '%' + str.tostring(sell_pct9, '#'), bgcolor = sell_color9, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 4, 10, text = sell_vol_txt9, bgcolor = sell_color9, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 5, 10, text = vol_diff_txt9, bgcolor = diff_color9, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 6, 10, text = vol_diff_pct9 > 0 ? '+' + str.tostring(vol_diff_pct9, '#.#') + '%' : str.tostring(vol_diff_pct9, '#.#') + '%', bgcolor = diff_pct_color9, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 7, 10, text = format_rvol(rel_vol9), bgcolor = rvol_color9, text_color = color.white, text_size = table_size)
    
    // Day 10 (new)
    [h10, l10, c10, o10, vol10, buy_vol10, sell_vol10, buy_pct10, sell_pct10, rel_vol10, vol_diff10, vol_diff_pct10] = get_day_vol_data(10)
    date_val10 = format_date(time[10])
    is_bullish10 = c10 > o10
    buy_vol_txt10 = format_volume(buy_vol10)
    sell_vol_txt10 = format_volume(sell_vol10)
    vol_diff_txt10 = format_difference(vol_diff10)
    date_color10 = is_bullish10 ? color.new(color.green, 80) : color.new(color.red, 80)
    buy_color10 = buy_pct10 > 50 ? color.new(color.green, 85) : color.new(color.gray, 90)
    sell_color10 = sell_pct10 > 50 ? color.new(color.red, 85) : color.new(color.gray, 90)
    diff_color10 = vol_diff10 > 0 ? color.new(color.green, 85) : vol_diff10 < 0 ? color.new(color.red, 85) : color.new(color.gray, 90)
    diff_pct_color10 = vol_diff_pct10 > 0 ? color.new(color.green, 85) : vol_diff_pct10 < 0 ? color.new(color.red, 85) : color.new(color.gray, 90)
    rvol_color10 = na(rel_vol10) ? color.new(color.gray, 90) : rel_vol10 > RValue ? color.new(color.yellow, 80) : color.new(color.gray, 90)
    
    // Store the values
    buy_pct_day10 := buy_pct10
    vol_diff_day10 := vol_diff10
    vol_diff_pct_day10 := vol_diff_pct10
    
    // table.cell(daily_table, 0, 11, text = date_val10, bgcolor = date_color10, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 1, 11, text = '%' + str.tostring(buy_pct10, '#'), bgcolor = buy_color10, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 2, 11, text = buy_vol_txt10, bgcolor = buy_color10, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 3, 11, text = '%' + str.tostring(sell_pct10, '#'), bgcolor = sell_color10, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 4, 11, text = sell_vol_txt10, bgcolor = sell_color10, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 5, 11, text = vol_diff_txt10, bgcolor = diff_color10, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 6, 11, text = vol_diff_pct10 > 0 ? '+' + str.tostring(vol_diff_pct10, '#.#') + '%' : str.tostring(vol_diff_pct10, '#.#') + '%', bgcolor = diff_pct_color10, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 7, 11, text = format_rvol(rel_vol10), bgcolor = rvol_color10, text_color = color.white, text_size = table_size)
    
    // Day 11 (new)
    [h11, l11, c11, o11, vol11, buy_vol11, sell_vol11, buy_pct11, sell_pct11, rel_vol11, vol_diff11, vol_diff_pct11] = get_day_vol_data(11)
    date_val11 = format_date(time[11])
    is_bullish11 = c11 > o11
    buy_vol_txt11 = format_volume(buy_vol11)
    sell_vol_txt11 = format_volume(sell_vol11)
    vol_diff_txt11 = format_difference(vol_diff11)
    date_color11 = is_bullish11 ? color.new(color.green, 80) : color.new(color.red, 80)
    buy_color11 = buy_pct11 > 50 ? color.new(color.green, 85) : color.new(color.gray, 90)
    sell_color11 = sell_pct11 > 50 ? color.new(color.red, 85) : color.new(color.gray, 90)
    diff_color11 = vol_diff11 > 0 ? color.new(color.green, 85) : vol_diff11 < 0 ? color.new(color.red, 85) : color.new(color.gray, 90)
    diff_pct_color11 = vol_diff_pct11 > 0 ? color.new(color.green, 85) : vol_diff_pct11 < 0 ? color.new(color.red, 85) : color.new(color.gray, 90)
    rvol_color11 = na(rel_vol11) ? color.new(color.gray, 90) : rel_vol11 > RValue ? color.new(color.yellow, 80) : color.new(color.gray, 90)
    
    // Store the values
    buy_pct_day11 := buy_pct11
    vol_diff_day11 := vol_diff11
    vol_diff_pct_day11 := vol_diff_pct11
    
    // table.cell(daily_table, 0, 12, text = date_val11, bgcolor = date_color11, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 1, 12, text = '%' + str.tostring(buy_pct11, '#'), bgcolor = buy_color11, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 2, 12, text = buy_vol_txt11, bgcolor = buy_color11, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 3, 12, text = '%' + str.tostring(sell_pct11, '#'), bgcolor = sell_color11, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 4, 12, text = sell_vol_txt11, bgcolor = sell_color11, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 5, 12, text = vol_diff_txt11, bgcolor = diff_color11, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 6, 12, text = vol_diff_pct11 > 0 ? '+' + str.tostring(vol_diff_pct11, '#.#') + '%' : str.tostring(vol_diff_pct11, '#.#') + '%', bgcolor = diff_pct_color11, text_color = color.white, text_size = table_size)
    // table.cell(daily_table, 7, 12, text = format_rvol(rel_vol11), bgcolor = rvol_color11, text_color = color.white, text_size = table_size)

// // Labels for current bar (original functionality)
// if ShowDL
//     //Detail Labels //////////////////////////
//     l = label.new(bar_index, na, text = (Bclose > Bopen and math.round(RVol) > 0 ? 'Relative Volume : ' + RVolTB + '\n' : na) + 'Buy Percent : %' + str.tostring(BuyVolumePercent, '##') + '\n' + 'Buy Volume : ' + DPBstr + '\n' + 'Total Volume : ' + TVol, color = color.green, textcolor = color.white, textalign = text.align_left, style = label.style_label_lower_left, size = label_size, yloc = yloc.abovebar)
//     label.delete(l[1])

//     r = label.new(bar_index, na, text = (Bclose < Bopen and math.round(RVol) > 0 ? 'Relative Volume : ' + RVolTS + '\n' : na) + 'Sell Percent : %' + str.tostring(SellVolumePercent, '##') + '\n' + 'Sell Volume : ' + DPSstr, color = color.red, textcolor = color.white, textalign = text.align_left, style = label.style_label_upper_left, size = label_size, yloc = yloc.belowbar)
//     label.delete(r[1])
// else //Small Labels /////////////////////////
//     l = label.new(bar_index, na, text = (math.round(RVol) > 0 ? RVolTB : na) + '%' + str.tostring(BuyVolumePercent, '##') + Bstr, color = color.green, textcolor = color.white, style = label.style_label_lower_left, size = label_size, yloc = yloc.abovebar)
//     label.delete(l[1])

//     r = label.new(bar_index, na, text = (math.round(RVol) > 0 ? RVolTS : na) + '%' + str.tostring(SellVolumePercent, '##') + Sstr, color = color.red, textcolor = color.white, style = label.style_label_upper_left, size = label_size, yloc = yloc.belowbar)
//     label.delete(r[1])

//If the relative volume value is greater than the value(Relative Volume for bars) we specify, paint those bars.
barcolor(title = 'Relative Volume Candles', color = ShowRVBars and Bclose > Bopen and RVol > RValue ? color.blue : na)

// New Alert Conditions
// Alarms based on volume difference
positive_diff_cond = VolDiff > diffAlertVolume and VolDiffPct > diffAlertPercentage
negative_diff_cond = VolDiff < -diffAlertVolume and VolDiffPct < -diffAlertPercentage

// Alarms based on percentage difference changes
pct_diff_increase_cond = vol_diff_pct_day0 > vol_diff_pct_day1 + diffPctIncreaseThreshold and diffPctChangeAlert
pct_diff_decrease_cond = vol_diff_pct_day0 < vol_diff_pct_day1 - diffPctDecreaseThreshold and diffPctChangeAlert

// Set up new alerts for volume difference
alertcondition(positive_diff_cond and positiveDiffAlert, title = 'Yüksek Pozitif Alım-Satım Farkı', message = 'Alım hacmi satış hacminden belirtilen eşiğin üstünde')
alertcondition(negative_diff_cond and negativeDiffAlert, title = 'Yüksek Negatif Alım-Satım Farkı', message = 'Satış hacmi alım hacminden belirtilen eşiğin üstünde')

// Different days alert conditions
alertcondition(vol_diff_day0 > diffAlertVolume, title = 'Gün 0 Pozitif Fark', message = 'Bugün alım hacmi satış hacminden fazla')
alertcondition(vol_diff_day0 < -diffAlertVolume, title = 'Gün 0 Negatif Fark', message = 'Bugün satış hacmi alım hacminden fazla')
alertcondition(vol_diff_day1 > diffAlertVolume, title = 'Gün 1 Pozitif Fark', message = 'Dün alım hacmi satış hacminden fazla')
alertcondition(vol_diff_day1 < -diffAlertVolume, title = 'Gün 1 Negatif Fark', message = 'Dün satış hacmi alım hacminden fazla')

// Alert for volume difference change trend
alertcondition(vol_diff_day0 > 0 and vol_diff_day1 < 0, title = 'Fark Pozitife Döndü', message = 'Alım-satım farkı negatiften pozitife döndü')
alertcondition(vol_diff_day0 < 0 and vol_diff_day1 > 0, title = 'Fark Negatife Döndü', message = 'Alım-satım farkı pozitiften negatife döndü')

// Alert for consecutive days with same direction
alertcondition(vol_diff_day0 > 0 and vol_diff_day1 > 0 and vol_diff_day2 > 0, title = '3 Gün Pozitif Fark', message = 'Son 3 gün alım hacmi satış hacminden fazla')
alertcondition(vol_diff_day0 < 0 and vol_diff_day1 < 0 and vol_diff_day2 < 0, title = '3 Gün Negatif Fark', message = 'Son 3 gün satış hacmi alım hacminden fazla')

// New alerts for percentage difference
alertcondition(vol_diff_pct_day0 > diffAlertPercentage, title = 'Yüksek Pozitif Yüzde Fark', message = 'Alım-satım yüzde farkı yüksek pozitif seviyede')
alertcondition(vol_diff_pct_day0 < -diffAlertPercentage, title = 'Yüksek Negatif Yüzde Fark', message = 'Alım-satım yüzde farkı yüksek negatif seviyede')
alertcondition(pct_diff_increase_cond, title = 'Yüzde Fark Belirgin Artış', message = 'Alım-satım yüzde farkı belirgin şekilde arttı')
alertcondition(pct_diff_decrease_cond, title = 'Yüzde Fark Belirgin Azalış', message = 'Alım-satım yüzde farkı belirgin şekilde azaldı')

// Alert for trend change in percentage difference
alertcondition(vol_diff_pct_day0 > 0 and vol_diff_pct_day1 < 0, title = 'Yüzde Fark Pozitife Döndü', message = 'Alım-satım yüzde farkı negatiften pozitife döndü')
alertcondition(vol_diff_pct_day0 < 0 and vol_diff_pct_day1 > 0, title = 'Yüzde Fark Negatife Döndü', message = 'Alım-satım yüzde farkı pozitiften negatife döndü')

// Input thresholds for each day (extended to 12 days)
var gun0 = input.int(50, title="gun0", minval=0)
var gun1 = input.int(50, title="gun1", minval=0)
var gun2 = input.int(50, title="gun2", minval=0)
var gun3 = input.int(50, title="gun3", minval=0)
var gun4 = input.int(50, title="gun4", minval=0)
var gun5 = input.int(50, title="gun5", minval=0)
var gun6 = input.int(50, title="gun6", minval=0)
var gun7 = input.int(50, title="gun7", minval=0)  // Added for day 7
var gun8 = input.int(50, title="gun8", minval=0)  // Added for day 8
var gun9 = input.int(50, title="gun9", minval=0)  // Added for day 9
var gun10 = input.int(50, title="gun10", minval=0) // Added for day 10
var gun11 = input.int(50, title="gun11", minval=0) // Added for day 11

// Hidden plots for volume differences
plot(VolDiff, title = 'Alım-Satım Farkı', display = display.none)
plot(VolDiffPct, title = 'Alım-Satım Yüzde Farkı', display = display.none)

// Hidden plots for daily differences
plot(vol_diff_day0, title = 'Alım-Satım Farkı Gün 0', display = display.none)
plot(vol_diff_day1, title = 'Alım-Satım Farkı Gün 1', display = display.none)
plot(vol_diff_day2, title = 'Alım-Satım Farkı Gün 2', display = display.none)
plot(vol_diff_day3, title = 'Alım-Satım Farkı Gün 3', display = display.none)
plot(vol_diff_day4, title = 'Alım-Satım Farkı Gün 4', display = display.none)
plot(vol_diff_day5, title = 'Alım-Satım Farkı Gün 5', display = display.none)
plot(vol_diff_day6, title = 'Alım-Satım Farkı Gün 6', display = display.none)
plot(vol_diff_day7, title = 'Alım-Satım Farkı Gün 7', display = display.none)
plot(vol_diff_day8, title = 'Alım-Satım Farkı Gün 8', display = display.none)
plot(vol_diff_day9, title = 'Alım-Satım Farkı Gün 9', display = display.none)
plot(vol_diff_day10, title = 'Alım-Satım Farkı Gün 10', display = display.none)
plot(vol_diff_day11, title = 'Alım-Satım Farkı Gün 11', display = display.none)

// Hidden plots for daily percentage differences
plot(vol_diff_pct_day0, title = 'Alım-Satım Yüzde Farkı Gün 0', display = display.none)
plot(vol_diff_pct_day1, title = 'Alım-Satım Yüzde Farkı Gün 1', display = display.none)
plot(vol_diff_pct_day2, title = 'Alım-Satım Yüzde Farkı Gün 2', display = display.none)
plot(vol_diff_pct_day3, title = 'Alım-Satım Yüzde Farkı Gün 3', display = display.none)
plot(vol_diff_pct_day4, title = 'Alım-Satım Yüzde Farkı Gün 4', display = display.none)
plot(vol_diff_pct_day5, title = 'Alım-Satım Yüzde Farkı Gün 5', display = display.none)
plot(vol_diff_pct_day6, title = 'Alım-Satım Yüzde Farkı Gün 6', display = display.none)
plot(vol_diff_pct_day7, title = 'Alım-Satım Yüzde Farkı Gün 7', display = display.none)
plot(vol_diff_pct_day8, title = 'Alım-Satım Yüzde Farkı Gün 8', display = display.none)
plot(vol_diff_pct_day9, title = 'Alım-Satım Yüzde Farkı Gün 9', display = display.none)
plot(vol_diff_pct_day10, title = 'Alım-Satım Yüzde Farkı Gün 10', display = display.none)
plot(vol_diff_pct_day11, title = 'Alım-Satım Yüzde Farkı Gün 11', display = display.none)

// BuyVol calculation
vol = volume
c = close
l = low
h = high
buyVol = vol * (c - l) / (h - l)  // Buy volume

// Last 3 candles ratio calculations
// Calculate increase and decrease ratios separately for each candle

// CANDLE 0 (current candle)
mum0_artis_orani = buyVol[1] != 0 and buyVol > buyVol[1] ? buyVol / buyVol[1] : na  // Only if increase
mum0_azalis_orani = buyVol[1] != 0 and buyVol < buyVol[1] ? buyVol[1] / buyVol : na  // Only if decrease (as inverse ratio)

// CANDLE 1 (previous candle)
mum1_artis_orani = buyVol[2] != 0 and buyVol[1] > buyVol[2] ? buyVol[1] / buyVol[2] : na  // Only if increase
mum1_azalis_orani = buyVol[2] != 0 and buyVol[1] < buyVol[2] ? buyVol[2] / buyVol[1] : na  // Only if decrease (as inverse ratio)

// CANDLE 2 (2 candles back)
mum2_artis_orani = buyVol[3] != 0 and buyVol[2] > buyVol[3] ? buyVol[2] / buyVol[3] : na  // Only if increase
mum2_azalis_orani = buyVol[3] != 0 and buyVol[2] < buyVol[3] ? buyVol[3] / buyVol[2] : na  // Only if decrease (as inverse ratio)

// Chart settings
var artisRengi = input.color(color.green, "Artış Rengi", group="Renkler")
var azalisRengi = input.color(color.red, "Azalış Rengi", group="Renkler")

// Plot scale factor
olcek = input.float(1.0, "Grafik Ölçeği", minval=0.1, maxval=10.0, step=0.1, group="Grafikler")

// Candle 0 (current candle) controls
show_mum0_artis = input.bool(true, "Mevcut Mum Artış Göster", group="Mum 0 (Mevcut)")
show_mum0_azalis = input.bool(true, "Mevcut Mum Azalış Göster", group="Mum 0 (Mevcut)")
mum0_artis_esik = input.float(1.5, "Mevcut Mum Artış Eşiği", minval=1.01, step=0.1, group="Mum 0 (Mevcut)")
mum0_azalis_esik = input.float(1.5, "Mevcut Mum Azalış Eşiği", minval=1.01, step=0.1, group="Mum 0 (Mevcut)")

// Candle 1 (previous candle) controls
show_mum1_artis = input.bool(true, "Önceki Mum Artış Göster", group="Mum 1 (Önceki)")
show_mum1_azalis = input.bool(true, "Önceki Mum Azalış Göster", group="Mum 1 (Önceki)")
mum1_artis_esik = input.float(1.5, "Önceki Mum Artış Eşiği", minval=1.01, step=0.1, group="Mum 1 (Önceki)")
mum1_azalis_esik = input.float(1.5, "Önceki Mum Azalış Eşiği", minval=1.01, step=0.1, group="Mum 1 (Önceki)")

// Candle 2 (previous previous candle) controls
show_mum2_artis = input.bool(true, "Öncekinin Öncesi Mum Artış Göster", group="Mum 2 (Öncekinin Öncesi)")
show_mum2_azalis = input.bool(true, "Öncekinin Öncesi Mum Azalış Göster", group="Mum 2 (Öncekinin Öncesi)")
mum2_artis_esik = input.float(1.5, "Öncekinin Öncesi Mum Artış Eşiği", minval=1.01, step=0.1, group="Mum 2 (Öncekinin Öncesi)")
mum2_azalis_esik = input.float(1.5, "Öncekinin Öncesi Mum Azalış Eşiği", minval=1.01, step=0.1, group="Mum 2 (Öncekinin Öncesi)")

// No change reference line
// hline(1.0, "Değişim Yok Seviyesi", color=color.new(color.gray, 50), linestyle=hline.style_dashed)

// // Candle 0 (current candle) plots
// plot(show_mum0_artis ? mum0_artis_orani * olcek : na, "Mevcut Mum Artış", color=artisRengi, style=plot.style_line, linewidth=3)

// // Candle 1 (previous candle) plots
// plot(show_mum1_artis ? mum1_artis_orani * olcek : na, "Önceki Mum Artış", color=color.new(artisRengi, 30), style=plot.style_line, linewidth=2)

// // Candle 2 (previous previous candle) plots
// plot(show_mum2_artis ? mum2_artis_orani * olcek : na, "Öncekinin Öncesi Mum Artış", color=color.new(artisRengi, 60), style=plot.style_line, linewidth=1)

// RSI Calculation
rsiLength = input(14, 'RSI Length')
rsi = ta.rsi(close, rsiLength)

// Moving Averages based on RSI
fmal = input(0, 'First Moving Average Length')
smal = input(1, 'Second Moving Average Length')
tmal = fmal + smal
Fmal = smal + tmal
Ftmal = tmal + Fmal
Smal = Fmal + Ftmal

w1 = rsi
w2 = ta.wma(w1, smal)
w3 = ta.wma(w2, tmal)
w4 = ta.wma(w3, Fmal)
w5 = ta.wma(w4, Ftmal)
MAVW = ta.wma(w5, Smal)

col1 = MAVW > MAVW[1] ? color.aqua : MAVW < MAVW[1] ? color.blue : color.yellow

// // Plot RSI
// hline(70, 'Overbought', color = color.red)
// hline(30, 'Oversold', color = color.green)
// plot(rsi, title = 'RSI', color = color.purple, linewidth = 2)

// Plot MAVW on RSI
// plot(MAVW, color = col1, linewidth = 2, title = 'MAVW on RSI')

// New alert condition for RSI crossover
rsi_cross_up = ta.crossover(rsi, MAVW) and MAVW > MAVW[1]
alertcondition(rsi_cross_up, title = 'RSI MAVW Yukarı Kesti', message = 'RSI, MAVW çizgisini yukarı yönde kesti')

// Table for Buy/Sell Signals and Market Analysis
// Table for Buy/Sell Signals and Market Analysis
if barstate.islast and showDailyTable
    // Create signal analysis table
    var table signal_table = table.new(position.bottom_right, columns = 2, rows = 16, border_width = 1)
    
    // Clear the table
    table.clear(signal_table, 0, 0)
    
    // Calculate signal conditions
    var bool strong_buy_signal = false
    var bool buy_signal = false
    var bool neutral_signal = false
    var bool sell_signal = false
    var bool strong_sell_signal = false
    
    // Multi-factor analysis
    // 1. Volume Analysis (3 consecutive days of positive buying)
    bool vol_trend_bullish = vol_diff_day0 > 0 and vol_diff_day1 > 0 and vol_diff_day2 > 0
    bool vol_trend_bearish = vol_diff_day0 < 0 and vol_diff_day1 < 0 and vol_diff_day2 < 0
    
    // 2. Buy percentage increasing trend
    bool buy_pct_increasing = buy_pct_day0 > buy_pct_day1 and buy_pct_day1 > buy_pct_day2
    bool buy_pct_decreasing = buy_pct_day0 < buy_pct_day1 and buy_pct_day1 < buy_pct_day2
    
    // 3. RSI conditions
    bool rsi_bullish = rsi > MAVW and MAVW > MAVW[1] and rsi < 70
    bool rsi_bearish = rsi < MAVW and MAVW < MAVW[1] and rsi > 30
    bool rsi_oversold = rsi < 30
    bool rsi_overbought = rsi > 70
    
    // 4. Relative Volume spike
    bool rvol_spike = rvol0 > RValue
    
    // 5. Volume difference momentum
    bool vol_diff_accelerating = vol_diff_pct_day0 > vol_diff_pct_day1 and vol_diff_pct_day1 > vol_diff_pct_day2
    
    // 6. Buy volume surge detection
    bool buy_vol_surge = not na(mum0_artis_orani) and mum0_artis_orani > mum0_artis_esik
    
    // Strong Buy Signal Conditions
    int strong_buy_conditions = 0
    if vol_trend_bullish
        strong_buy_conditions := strong_buy_conditions + 1
    if buy_pct_increasing
        strong_buy_conditions := strong_buy_conditions + 1
    if rsi_bullish
        strong_buy_conditions := strong_buy_conditions + 1
    if rvol_spike
        strong_buy_conditions := strong_buy_conditions + 1
    if vol_diff_accelerating
        strong_buy_conditions := strong_buy_conditions + 1
    if buy_vol_surge
        strong_buy_conditions := strong_buy_conditions + 1
    if rsi_oversold and vol_diff_day0 > 0
        strong_buy_conditions := strong_buy_conditions + 2  // Extra weight
    
    // Strong Sell Signal Conditions
    int strong_sell_conditions = 0
    if vol_trend_bearish
        strong_sell_conditions := strong_sell_conditions + 1
    if buy_pct_decreasing
        strong_sell_conditions := strong_sell_conditions + 1
    if rsi_bearish
        strong_sell_conditions := strong_sell_conditions + 1
    if rsi_overbought and vol_diff_day0 < 0
        strong_sell_conditions := strong_sell_conditions + 2  // Extra weight
    
    // Determine final signal
    string signal_text = ''
    color signal_color = color.gray
    
    if strong_buy_conditions >= 5
        strong_buy_signal := true
        signal_text := '🚀 GÜÇLÜ ALIM'
        signal_color := color.new(color.green, 0)
    else if strong_buy_conditions >= 3
        buy_signal := true
        signal_text := '📈 ALIM'
        signal_color := color.new(color.green, 30)
    else if strong_sell_conditions >= 4
        strong_sell_signal := true
        signal_text := '🔴 GÜÇLÜ SATIM'
        signal_color := color.new(color.red, 0)
    else if strong_sell_conditions >= 2
        sell_signal := true
        signal_text := '📉 SATIM'
        signal_color := color.new(color.red, 30)
    else
        neutral_signal := true
        signal_text := '⚖️ NÖTR'
        signal_color := color.new(color.gray, 50)
    
    // Calculate rally potential score (0-100)
    float rally_score = 0.0
    rally_score := rally_score + (vol_trend_bullish ? 20.0 : 0.0)
    rally_score := rally_score + (buy_pct_day0 > 60 ? 15.0 : buy_pct_day0 > 55 ? 10.0 : buy_pct_day0 > 50 ? 5.0 : 0.0)
    rally_score := rally_score + (rsi_bullish ? 15.0 : 0.0)
    rally_score := rally_score + (rvol_spike ? 15.0 : rvol0 > 2 ? 10.0 : 0.0)
    rally_score := rally_score + (vol_diff_accelerating ? 15.0 : 0.0)
    rally_score := rally_score + (buy_vol_surge ? 10.0 : 0.0)
    rally_score := rally_score + (rsi_oversold and vol_diff_day0 > 0 ? 10.0 : 0.0)
    
    // Rally potential color
    color rally_color = rally_score >= 70 ? color.new(color.green, 20) : rally_score >= 50 ? color.new(color.orange, 40) : rally_score >= 30 ? color.new(color.yellow, 40) : color.new(color.red, 40)
    
    // Market momentum (short term trend)
    string momentum_text = ''
    if buy_pct_day0 > buy_pct_day1 and buy_pct_day1 > buy_pct_day2
        momentum_text := '⬆️⬆️ Güçlü Yükseliş'
    else if buy_pct_day0 > buy_pct_day1
        momentum_text := '⬆️ Yükselişte'
    else if buy_pct_day0 < buy_pct_day1 and buy_pct_day1 < buy_pct_day2
        momentum_text := '⬇️⬇️ Güçlü Düşüş'
    else if buy_pct_day0 < buy_pct_day1
        momentum_text := '⬇️ Düşüşte'
    else
        momentum_text := '➡️ Yatay'
    
    // Volume trend description
    string vol_trend_text = ''
    if vol_diff_day0 > 0 and vol_diff_day1 > 0 and vol_diff_day2 > 0
        vol_trend_text := '✅ 3 Gün Alım Baskısı'
    else if vol_diff_day0 < 0 and vol_diff_day1 < 0 and vol_diff_day2 < 0
        vol_trend_text := '❌ 3 Gün Satış Baskısı'
    else if vol_diff_day0 > 0
        vol_trend_text := '✅ Güncel Alım Var'
    else if vol_diff_day0 < 0
        vol_trend_text := '❌ Güncel Satış Var'
    else
        vol_trend_text := '⚖️ Dengede'
    
    // RSI status
    string rsi_status = ''
    if rsi > 70
        rsi_status := '🔥 Aşırı Alım ('+str.tostring(rsi, '#.#')+')'
    else if rsi > 60
        rsi_status := '📈 Güçlü ('+str.tostring(rsi, '#.#')+')'
    else if rsi > 40
        rsi_status := '➡️ Nötr ('+str.tostring(rsi, '#.#')+')'
    else if rsi > 30
        rsi_status := '📉 Zayıf ('+str.tostring(rsi, '#.#')+')'
    else
        rsi_status := '💎 Aşırı Satım ('+str.tostring(rsi, '#.#')+')'
    
    // Header
    table.cell(signal_table, 0, 0, text = '📊 PİYASA ANALİZİ', bgcolor = color.new(color.blue, 70), text_color = color.white, text_size = table_size)
    table.cell(signal_table, 1, 0, text = '', bgcolor = color.new(color.blue, 70), text_color = color.white, text_size = table_size)
    
    // Main Signal
    table.cell(signal_table, 0, 1, text = 'Ana Sinyal', bgcolor = color.new(color.gray, 80), text_color = color.white, text_size = table_size)
    table.cell(signal_table, 1, 1, text = signal_text, bgcolor = signal_color, text_color = color.white, text_size = table_size)
    
    // Rally Potential
    table.cell(signal_table, 0, 2, text = 'Ralli Potansiyeli', bgcolor = color.new(color.gray, 80), text_color = color.white, text_size = table_size)
    table.cell(signal_table, 1, 2, text = str.tostring(rally_score, '#') + '/100', bgcolor = rally_color, text_color = color.white, text_size = table_size)
    
    // Momentum
    table.cell(signal_table, 0, 3, text = 'Momentum', bgcolor = color.new(color.gray, 80), text_color = color.white, text_size = table_size)
    table.cell(signal_table, 1, 3, text = momentum_text, bgcolor = color.new(color.gray, 90), text_color = color.white, text_size = table_size)
    
    // Volume Trend
    table.cell(signal_table, 0, 4, text = 'Hacim Trendi', bgcolor = color.new(color.gray, 80), text_color = color.white, text_size = table_size)
    table.cell(signal_table, 1, 4, text = vol_trend_text, bgcolor = color.new(color.gray, 90), text_color = color.white, text_size = table_size)
    
    // RSI Status
    table.cell(signal_table, 0, 5, text = 'RSI Durumu', bgcolor = color.new(color.gray, 80), text_color = color.white, text_size = table_size)
    table.cell(signal_table, 1, 5, text = rsi_status, bgcolor = color.new(color.gray, 90), text_color = color.white, text_size = table_size)
    
    // Relative Volume
    table.cell(signal_table, 0, 6, text = 'Göreceli Hacim', bgcolor = color.new(color.gray, 80), text_color = color.white, text_size = table_size)
    table.cell(signal_table, 1, 6, text = str.tostring(rvol0, '#.##') + 'x' + (rvol_spike ? ' 🔥' : ''), bgcolor = rvol_spike ? color.new(color.yellow, 60) : color.new(color.gray, 90), text_color = color.white, text_size = table_size)
    
    // Current Buy %
    table.cell(signal_table, 0, 7, text = 'Güncel Alış %', bgcolor = color.new(color.gray, 80), text_color = color.white, text_size = table_size)
    table.cell(signal_table, 1, 7, text = '%' + str.tostring(buy_pct_day0, '#.#'), bgcolor = buy_pct_day0 > 55 ? color.new(color.green, 70) : buy_pct_day0 < 45 ? color.new(color.red, 70) : color.new(color.gray, 90), text_color = color.white, text_size = table_size)
    
    // Volume Difference Today
    table.cell(signal_table, 0, 8, text = 'Bugün Fark', bgcolor = color.new(color.gray, 80), text_color = color.white, text_size = table_size)
    table.cell(signal_table, 1, 8, text = format_difference(vol_diff_day0), bgcolor = vol_diff_day0 > 0 ? color.new(color.green, 70) : vol_diff_day0 < 0 ? color.new(color.red, 70) : color.new(color.gray, 90), text_color = color.white, text_size = table_size)
    
    // Volume Difference % Today
    table.cell(signal_table, 0, 9, text = 'Bugün Fark %', bgcolor = color.new(color.gray, 80), text_color = color.white, text_size = table_size)
    table.cell(signal_table, 1, 9, text = (vol_diff_pct_day0 > 0 ? '+' : '') + str.tostring(vol_diff_pct_day0, '#.#') + '%', bgcolor = vol_diff_pct_day0 > 0 ? color.new(color.green, 70) : vol_diff_pct_day0 < 0 ? color.new(color.red, 70) : color.new(color.gray, 90), text_color = color.white, text_size = table_size)
    
    // 3-Day Buy Average
    float avg_buy_3day = (buy_pct_day0 + buy_pct_day1 + buy_pct_day2) / 3
    table.cell(signal_table, 0, 10, text = '3 Gün Ort. Alış %', bgcolor = color.new(color.gray, 80), text_color = color.white, text_size = table_size)
    table.cell(signal_table, 1, 10, text = '%' + str.tostring(avg_buy_3day, '#.#'), bgcolor = avg_buy_3day > 55 ? color.new(color.green, 70) : avg_buy_3day < 45 ? color.new(color.red, 70) : color.new(color.gray, 90), text_color = color.white, text_size = table_size)
    
    // Buy Volume Acceleration
    table.cell(signal_table, 0, 11, text = 'Alış Ivmesi', bgcolor = color.new(color.gray, 80), text_color = color.white, text_size = table_size)
    table.cell(signal_table, 1, 11, text = buy_vol_surge ? '🚀 Hızlanıyor' : not na(mum0_artis_orani) and mum0_artis_orani > 1.2 ? '⬆️ Artışta' : '➡️ Normal', bgcolor = buy_vol_surge ? color.new(color.green, 60) : color.new(color.gray, 90), text_color = color.white, text_size = table_size)
    
    // Signal Strength (how many conditions met)
    table.cell(signal_table, 0, 12, text = 'Sinyal Gücü', bgcolor = color.new(color.gray, 80), text_color = color.white, text_size = table_size)
    table.cell(signal_table, 1, 12, text = str.tostring(strong_buy_signal or buy_signal ? strong_buy_conditions : strong_sell_conditions) + '/8 Koşul', bgcolor = color.new(color.gray, 90), text_color = color.white, text_size = table_size)
    
    // Market Phase
    string market_phase = ''
    if rally_score >= 70 and rsi < 70
        market_phase := '🎯 Ralli Başlangıcı'
    else if rally_score >= 50 and vol_trend_bullish
        market_phase := '📈 Yükseliş Trendi'
    else if rally_score < 30 and vol_trend_bearish
        market_phase := '📉 Düşüş Trendi'
    else if rsi > 70
        market_phase := '⚠️ Aşırı Alım Bölgesi'
    else if rsi < 30
        market_phase := '💎 Fırsat Bölgesi'
    else
        market_phase := '⏸️ Konsolidasyon'
    
    table.cell(signal_table, 0, 13, text = 'Piyasa Fazı', bgcolor = color.new(color.gray, 80), text_color = color.white, text_size = table_size)
    table.cell(signal_table, 1, 13, text = market_phase, bgcolor = color.new(color.gray, 90), text_color = color.white, text_size = table_size)
    
// Recommendation
    string recommendation = ''
    if strong_buy_signal
        recommendation := '✅ Güçlü alım fırsatı. Pozisyon açılabilir.'
    else if buy_signal
        recommendation := '✅ Alım sinyali var. Dikkatli pozisyon alınabilir.'
    else if strong_sell_signal
        recommendation := '❌ Güçlü satış baskısı. Pozisyonlar kapatılmalı.'
    else if sell_signal
        recommendation := '⚠️ Satış sinyali var. Dikkatli olunmalı.'
    else if rally_score >= 60 and rsi < 70
        recommendation := '🎯 Ralli başlayabilir. Takip edilmeli.'
    else
        recommendation := '⏸️ Nötr. Daha net sinyaller beklenmeli.'
    
    table.cell(signal_table, 0, 14, text = 'Öneri', bgcolor = color.new(color.blue, 80), text_color = color.white, text_size = table_size)
    table.cell(signal_table, 1, 14, text = recommendation, bgcolor = color.new(color.blue, 90), text_color = color.white, text_size = table_size)
    
    // Disclaimer row
    table.cell(signal_table, 0, 15, text = '', bgcolor = color.new(color.gray, 95), text_color = color.white, text_size = size.tiny)
    table.cell(signal_table, 1, 15, text = '⚠️ Yatırım tavsiyesi değildir!', bgcolor = color.new(color.gray, 95), text_color = color.orange, text_size = size.normal)

// Store values for alerts (outside the if block)
var float stored_rally_score = na
var int stored_strong_buy = 0
var int stored_strong_sell = 0

if barstate.islast
    // Recalculate for alerts
    bool vol_trend_bullish_alert = vol_diff_day0 > 0 and vol_diff_day1 > 0 and vol_diff_day2 > 0
    bool buy_pct_increasing_alert = buy_pct_day0 > buy_pct_day1 and buy_pct_day1 > buy_pct_day2
    bool rsi_bullish_alert = rsi > MAVW and MAVW > MAVW[1] and rsi < 70
    bool rvol_spike_alert = rvol0 > RValue
    bool vol_diff_accelerating_alert = vol_diff_pct_day0 > vol_diff_pct_day1 and vol_diff_pct_day1 > vol_diff_pct_day2
    bool buy_vol_surge_alert = not na(mum0_artis_orani) and mum0_artis_orani > mum0_artis_esik
    bool rsi_oversold_alert = rsi < 30
    bool vol_trend_bearish_alert = vol_diff_day0 < 0 and vol_diff_day1 < 0 and vol_diff_day2 < 0
    bool buy_pct_decreasing_alert = buy_pct_day0 < buy_pct_day1 and buy_pct_day1 < buy_pct_day2
    bool rsi_bearish_alert = rsi < MAVW and MAVW < MAVW[1] and rsi > 30
    bool rsi_overbought_alert = rsi > 70
    
    stored_strong_buy := 0
    stored_strong_buy := stored_strong_buy + (vol_trend_bullish_alert ? 1 : 0)
    stored_strong_buy := stored_strong_buy + (buy_pct_increasing_alert ? 1 : 0)
    stored_strong_buy := stored_strong_buy + (rsi_bullish_alert ? 1 : 0)
    stored_strong_buy := stored_strong_buy + (rvol_spike_alert ? 1 : 0)
    stored_strong_buy := stored_strong_buy + (vol_diff_accelerating_alert ? 1 : 0)
    stored_strong_buy := stored_strong_buy + (buy_vol_surge_alert ? 1 : 0)
    stored_strong_buy := stored_strong_buy + (rsi_oversold_alert and vol_diff_day0 > 0 ? 2 : 0)
    
    stored_strong_sell := 0
    stored_strong_sell := stored_strong_sell + (vol_trend_bearish_alert ? 1 : 0)
    stored_strong_sell := stored_strong_sell + (buy_pct_decreasing_alert ? 1 : 0)
    stored_strong_sell := stored_strong_sell + (rsi_bearish_alert ? 1 : 0)
    stored_strong_sell := stored_strong_sell + (rsi_overbought_alert and vol_diff_day0 < 0 ? 2 : 0)
    
    stored_rally_score := 0.0
    stored_rally_score := stored_rally_score + (vol_trend_bullish_alert ? 20.0 : 0.0)
    stored_rally_score := stored_rally_score + (buy_pct_day0 > 60 ? 15.0 : buy_pct_day0 > 55 ? 10.0 : buy_pct_day0 > 50 ? 5.0 : 0.0)
    stored_rally_score := stored_rally_score + (rsi_bullish_alert ? 15.0 : 0.0)
    stored_rally_score := stored_rally_score + (rvol_spike_alert ? 15.0 : rvol0 > 2 ? 10.0 : 0.0)
    stored_rally_score := stored_rally_score + (vol_diff_accelerating_alert ? 15.0 : 0.0)
    stored_rally_score := stored_rally_score + (buy_vol_surge_alert ? 10.0 : 0.0)
    stored_rally_score := stored_rally_score + (rsi_oversold_alert and vol_diff_day0 > 0 ? 10.0 : 0.0)

// Alert conditions for signals
alertcondition(stored_strong_buy >= 5, title = '🚀 Güçlü Alım Sinyali', message = 'GÜÇLÜ ALIM SİNYALİ: Ralli potansiyeli yüksek!')
alertcondition(stored_strong_buy >= 3 and stored_strong_buy < 5, title = '📈 Alım Sinyali', message = 'ALIM SİNYALİ: Yükseliş potansiyeli var')
alertcondition(stored_strong_sell >= 4, title = '🔴 Güçlü Satım Sinyali', message = 'GÜÇLÜ SATIM SİNYALİ: Satış baskısı yüksek!')
alertcondition(stored_strong_sell >= 2 and stored_strong_sell < 4, title = '📉 Satım Sinyali', message = 'SATIM SİNYALİ: Düşüş baskısı var')

// Rally detection alert
alertcondition(stored_rally_score >= 70 and stored_rally_score[1] < 70 and rsi < 70, title = '🎯 Ralli Başlıyor', message = 'RALLİ BAŞLIYOR: Yükseliş potansiyeli çok yüksek!')
Editor is loading...
Leave a Comment