Untitled

 avatar
unknown
plain_text
24 days ago
18 kB
2
Indexable
//@version=6
indicator('FiboBorsa Ema Tablo', overlay = true, max_labels_count = 500, max_boxes_count = 500)


// Comparative Relative Strength calculations
comparativeTickerId = input.symbol('BIST:XU100', title = 'KOM SYMBOL', inline="group3", group='Komp - RSI Settings')
src1 = close
baseSymbol = request.security(syminfo.tickerid, timeframe.period, src1)
comparativeSymbol = request.security(comparativeTickerId, timeframe.period, src1)
crs = baseSymbol / comparativeSymbol
rsiLength = 14
higherRSI = ta.rsi(crs, rsiLength)

// Add enable/disable settings for comparative EMAs
show_comp_ema34 = input.bool(true, "KOMP EMA 34", group="Comparative EMA Display", inline="34")
color_ema34 = input.color(color.red, "", group="Comparative EMA Display", inline="34")

show_comp_ema233 = input.bool(true, "KOMP EMA 233", group="Comparative EMA Display", inline="233")
color_ema233 = input.color(color.purple, "", group="Comparative EMA Display", inline="233")


// Add text size control for comparative EMA labels
comp_ema_text_size = input.string("normal", "KOMP EMA Label Size", options=["tiny", "small", "normal", "large"], group="Comparative EMA Display")

// Convert text size input to size constant
get_text_size() =>
    switch comp_ema_text_size
        "tiny" => size.tiny
        "small" => size.small
        "large" => size.large
        => size.normal

// EMA Display Settings
show_regular_ema5 = input.bool(false, "EMA 5", group="EMA Display", inline="5")
color_regular_ema5 = input.color(color.rgb(0, 255, 17), "", group="EMA Display", inline="5", display=display.none)

show_regular_ema8 = input.bool(false, "EMA 8", group="EMA Display", inline="8")
color_regular_ema8 = input.color(#1353a7, "", group="EMA Display", inline="8", display=display.none)

show_regular_ema14 = input.bool(false, "EMA 14", group="EMA Display", inline="14")
color_regular_ema14 = input.color(color.rgb(0, 255, 17), "", group="EMA Display", inline="14", display=display.none)

show_regular_ema21 = input.bool(false, "EMA 21", group="EMA Display", inline="21")
color_regular_ema21 = input.color(#eea615, "", group="EMA Display", inline="21", display=display.none)

show_regular_ema34 = input.bool(true, "EMA 34", group="EMA Display", inline="34")
color_regular_ema34 = input.color(color.rgb(253, 0, 0), "", group="EMA Display", inline="34")

show_regular_ema55 = input.bool(true, "EMA 55", group="EMA Display", inline="55")
color_regular_ema55 = input.color(#f8a407, "", group="EMA Display", inline="55", display=display.none)

show_regular_ema89 = input.bool(false, "EMA 89", group="EMA Display", inline="89")
color_regular_ema89 = input.color(color.rgb(207, 193, 166), "", group="EMA Display", inline="89", display=display.none)

show_regular_ema144 = input.bool(false, "EMA 144", group="EMA Display", inline="144")
color_regular_ema144 = input.color(color.rgb(184, 25, 232), "", group="EMA Display", inline="144", display=display.none)

show_regular_ema233 = input.bool(false, "EMA 233", group="EMA Display", inline="233")
color_regular_ema233 = input.color(color.rgb(0, 203, 254), "", group="EMA Display", inline="233", display=display.none)

show_regular_ema377 = input.bool(false, "EMA 377", group="EMA Display", inline="377")
color_regular_ema377 = input.color(color.rgb(7, 89, 240), "", group="EMA Display", inline="377", display=display.none)

show_regular_ema500 = input.bool(false, "EMA 500", group="EMA Display", inline="500")
color_regular_ema500 = input.color(color.rgb(124, 128, 131), "", group="EMA Display", inline="500", display=display.none)

show_regular_ema610 = input.bool(false, "EMA 610", group="EMA Display", inline="610")
color_regular_ema610 = input.color(#36ae50, "", group="EMA Display", inline="610", display=display.none)

show_regular_ema750 = input.bool(false, "EMA 750", group="EMA Display", inline="750")
color_regular_ema750 = input.color(#bb177c, "", group="EMA Display", inline="750", display=display.none)

show_regular_ema987 = input.bool(false, "EMA 987", group="EMA Display", inline="987")
color_regular_ema987 = input.color(#ccac29, "", group="EMA Display", inline="987", display=display.none)

// EMA Length inputs
emaLength13 = input.int(5, title = '', group="EMA Display", inline="5")
emaLength14 = input.int(8, title = '', group="EMA Display", inline="8")
emaLength12 = input.int(14, title = '', group="EMA Display", inline="14")
emaLength15 = input.int(21, title = '', group="EMA Display", inline="21")
emaLength3 = input.int(34, title = '', group="EMA Display", inline="34")
emaLength4 = input.int(55, title = '', group="EMA Display", inline="55")
emaLength10 = input.int(89, title = '', group="EMA Display", inline="89")
emaLength5 = input.int(144, title = '', group="EMA Display", inline="144")
emaLength6 = input.int(233, title = '', group="EMA Display", inline="233")
emaLength7 = input.int(377, title = '', group="EMA Display", inline="377")
emaLength16 = input.int(500, title = '', group="EMA Display", inline="500")
emaLength8 = input.int(610, title = '', group="EMA Display", inline="610")
emaLength17 = input.int(750, title = '', group="EMA Display", inline="750")
emaLength18 = input.int(987, title = '', group="EMA Display", inline="987")

// Calculate Regular EMAs
ema5 = ta.ema(close, emaLength13)
ema8 = ta.ema(close, emaLength14)
ema14 = ta.ema(close, emaLength12)
ema21 = ta.ema(close, emaLength15)
ema34 = ta.ema(close, emaLength3)
ema55 = ta.ema(close, emaLength4)
ema89 = ta.ema(close, emaLength10)
ema144 = ta.ema(close, emaLength5)
ema233 = ta.ema(close, emaLength6)
ema377 = ta.ema(close, emaLength7)
ema500 = ta.ema(close, emaLength16)
ema610 = ta.ema(close, emaLength8)
ema750 = ta.ema(close, emaLength17)
ema987 = ta.ema(close, emaLength18)

plot(show_regular_ema5 ? ema5 : na, title='5', color=color_regular_ema5, linewidth=2)
plot(show_regular_ema8 ? ema8 : na, title='8', color=color_regular_ema8, linewidth=2)
plot(show_regular_ema14 ? ema14 : na, title='14', color=color_regular_ema14, linewidth=2)
plot(show_regular_ema21 ? ema21 : na, title='21', color=color_regular_ema21, linewidth=2)
plot(show_regular_ema34 ? ema34 : na, title='34', color=color_regular_ema34, linewidth=2)
plot(show_regular_ema55 ? ema55 : na, title='55', color=color_regular_ema55, linewidth=2)
plot(show_regular_ema89 ? ema89 : na, title='89', color=color_regular_ema89, linewidth=2)
plot(show_regular_ema144 ? ema144 : na, title='144', color=color_regular_ema144, linewidth=2)
plot(show_regular_ema233 ? ema233 : na, title='233', color=color_regular_ema233, linewidth=2)
plot(show_regular_ema377 ? ema377 : na, title='377', color=color_regular_ema377, linewidth=2)
plot(show_regular_ema500 ? ema610 : na, title='500', color=color_regular_ema500, linewidth=2)
plot(show_regular_ema610 ? ema610 : na, title='610', color=color_regular_ema610, linewidth=2)
plot(show_regular_ema750 ? ema610 : na, title='750', color=color_regular_ema750, linewidth=2)
plot(show_regular_ema987 ? ema610 : na, title='987', color=color_regular_ema987, linewidth=2)

up = ta.rma(math.max(ta.change(src1), 0), rsiLength)
down = ta.rma(-math.min(ta.change(src1), 0), rsiLength)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - 100 / (1 + up / down)

// MACD settings
higherrsi_0 = ta.crossunder(rsi, 30) // MACD aşağı kesiş
higherrsi_01 = ta.crossover(rsi, 30) // MACD aşağı kesiş

emaCrossUp = ta.crossover(ema34, ema55)   // EMA34 yukarı kesiş
emaCrossDown = ta.crossunder(ema34, ema55) // EMA34 aşağı kesiş

       
// XU100 fiyatı ve EMA uzunlukları
xu100 = request.security('BIST:XU100', timeframe.period, close)
compEmaLength34 = input.int(34, title='', group="Comparative EMA Display", inline="34")
compEmaLength233 = input.int(233, title='', group="Comparative EMA Display", inline="233")



// Mevcut varlığın fiyatı ile XU100 arasındaki oran üzerinden EMA hesaplama
comp_ema34 = ta.ema(close / xu100, compEmaLength34)
comp_ema233 = ta.ema(close / xu100, compEmaLength233)



// Çizgi ve etiketler için değişkenler
var line ema_line1 = na
var label ema_label1 = na

var line ema_line3 = na
var label ema_label3 = na


 // Çizgileri ve etiketleri oluşturma
     
if bar_index > 6

    // EMA 34
    if na(ema_line1) and show_comp_ema34
        ema_line1 := line.new(x1=bar_index, y1=comp_ema34 * xu100, x2=bar_index + 6, y2=comp_ema34 * xu100, color=color_ema34, width=2)
        ema_label1 := label.new(x=bar_index + 7, y=comp_ema34 * xu100, text=str.tostring(comp_ema34 * xu100, '#.##'), style=label.style_label_left, color=color.new(color.white, 100), textcolor=color_ema34, size=size.normal)
    else if show_comp_ema34
        line.set_xy1(ema_line1, bar_index, comp_ema34 * xu100)
        line.set_xy2(ema_line1, bar_index + 6, comp_ema34 * xu100)
        label.set_x(ema_label1, bar_index + 6)  // Çizginin bitiş noktasına sabitle
        label.set_y(ema_label1, comp_ema34 * xu100)
        label.set_text(ema_label1,  "KOMP-34: " +  str.tostring(comp_ema34 * xu100, '#.##'))
        label.set_size(ema_label1, get_text_size())
    
    // EMA 233
    if na(ema_line3) and show_comp_ema233
        ema_line3 := line.new(x1=bar_index, y1=comp_ema233 * xu100, x2=bar_index + 6, y2=comp_ema233 * xu100, color=color_ema233, width=2)
        ema_label3 := label.new(x=bar_index + 7, y=comp_ema233 * xu100, text=str.tostring(comp_ema233 * xu100, '#.##'), style=label.style_label_left, color=color.new(color.white, 100), textcolor=color_ema233, size=size.normal)
    else if show_comp_ema233
        line.set_xy1(ema_line3, bar_index, comp_ema233 * xu100)
        line.set_xy2(ema_line3, bar_index + 6, comp_ema233 * xu100)
        label.set_x(ema_label3, bar_index + 6)
        label.set_y(ema_label3, comp_ema233 * xu100)
        label.set_text(ema_label3,  "KOMP-233: " + str.tostring(comp_ema233 * xu100, '#.##'))
        label.set_size(ema_label3, get_text_size())
	

// Table for displaying percentage changes
tablePosition = input.string('bottom_right', title = 'Table Position', options = ['top_right', 'top_left', 'bottom_right', 'bottom_left'], group="TABLE", inline="TBL")
fontSize = input.string('normal', title = 'Font Size', options = ['tiny', 'small', 'normal', 'large'], group="TABLE", inline="TBL")
tableBorderWidth3 = 1
frame_width3 = 2
// Tablo stil ayarları için kullanıcı girişleri
frame_color3 = input.color(#131722, title="Çerçeve Rengi", group="TABLE", inline="TBLE")
tableBgColor3 = input.color(#131722, title="Arka Plan Rengi", group="TABLE", inline="TBLE")
tableBorderColor3 = input.color(#ff99007c, title="Çizgi Rengi", group="TABLE", inline="TBLE")

Komp233_change = (((comp_ema233 * xu100) / close) - 1) * 100  // Yüzdesel değişim
Komp233_value = comp_ema233 * xu100                                          // Gerçek XU100 değeri

Komp34_change = (((comp_ema34 * xu100) / close) - 1) * 100  // Yüzdesel değişim
Komp34_value = comp_ema34 * xu100                                          // Gerçek XU100 değeri

fontSizeMap = fontSize == 'normal' ? size.normal : fontSize == 'small' ? size.small : fontSize == 'normal' ? size.normal : size.large
positionMap = tablePosition == 'bottom_right' ? position.bottom_right : tablePosition == 'top_left' ? position.top_left : tablePosition == 'top_right' ? position.top_right : tablePosition == 'bottom_right' ? position.bottom_right : position.top_right

var table tbl = table.new(positionMap, 20, 20, bgcolor=tableBgColor3, border_color=tableBorderColor3, border_width=tableBorderWidth3, frame_color=frame_color3, frame_width=frame_width3)
                                           
// Tablo başlıkları
if bar_index == 1
    table.cell(tbl, 0, 0, 'Ema 5', text_color = color.orange, text_size = fontSizeMap)
    table.cell(tbl, 0, 1, 'Ema 8', text_color = color.orange, text_size = fontSizeMap)
    table.cell(tbl, 0, 2, 'Ema 14', text_color = color.orange, text_size = fontSizeMap)
    table.cell(tbl, 0, 3, 'Ema 21', text_color = color.orange, text_size = fontSizeMap)
    table.cell(tbl, 0, 4, 'Ema 34', text_color = color.orange, text_size = fontSizeMap)
    table.cell(tbl, 0, 5, 'Ema 55', text_color = color.orange, text_size = fontSizeMap)
    table.cell(tbl, 0, 6, 'Ema 89', text_color = color.orange, text_size = fontSizeMap)
    table.cell(tbl, 0, 7, 'Ema 144', text_color = color.orange, text_size = fontSizeMap)
    table.cell(tbl, 0, 8, 'Ema 233', text_color = color.orange, text_size = fontSizeMap)
    table.cell(tbl, 0, 9, 'Ema 377', text_color = color.orange, text_size = fontSizeMap)
    table.cell(tbl, 0, 10, 'Ema 500', text_color = color.orange, text_size = fontSizeMap)
    table.cell(tbl, 0, 11, 'Ema 610', text_color = color.orange, text_size = fontSizeMap)
    table.cell(tbl, 0, 12, 'Ema 750', text_color = color.orange, text_size = fontSizeMap)
    table.cell(tbl, 0, 13, 'Ema 987', text_color = color.orange, text_size = fontSizeMap)
    table.cell(tbl, 0, 14, 'KOMP-34', text_color=color.orange, text_size = fontSizeMap)
    table.cell(tbl, 0, 15, 'KOMP-233', text_color = color.orange, text_size = fontSizeMap)
    table.cell(tbl, 0, 16, 'KOM RSI', text_color = color.orange, text_size = fontSizeMap)
    table.cell(tbl, 0, 17, 'RSI', text_color = color.orange, text_size = fontSizeMap)
    
// EMA 34 değerini tabloya ekleme
table.cell(tbl, 1, 0, str.tostring(ema5, '#.##'), text_color = ema5 >= close ? color.red : color.green, text_size = fontSizeMap)
table.cell(tbl, 1, 1, str.tostring(ema8, '#.##'), text_color = ema8 >= close ? color.red : color.green, text_size = fontSizeMap)
table.cell(tbl, 1, 2, str.tostring(ema14, '#.##'), text_color = ema14 >= close ? color.red : color.green, text_size = fontSizeMap)
table.cell(tbl, 1, 3, str.tostring(ema21, '#.##'), text_color = ema21 >= close ? color.red : color.green, text_size = fontSizeMap)
table.cell(tbl, 1, 4, str.tostring(ema34, '#.##'), text_color = ema34 >= close ? color.red : color.green, text_size = fontSizeMap)
table.cell(tbl, 1, 5, str.tostring(ema55, '#.##'), text_color = ema55 >= close ? color.red : color.green, text_size = fontSizeMap)
table.cell(tbl, 1, 6, str.tostring(ema89, '#.##'), text_color = ema89 >= close ? color.red : color.green, text_size = fontSizeMap)
table.cell(tbl, 1, 7, str.tostring(ema144, '#.##'), text_color = ema144 >= close ? color.red : color.green, text_size = fontSizeMap)
table.cell(tbl, 1, 8, str.tostring(ema233, '#.##'), text_color = ema233 >= close ? color.red : color.green, text_size = fontSizeMap)
table.cell(tbl, 1, 9, str.tostring(ema377, '#.##'), text_color = ema377 >= close ? color.red : color.green, text_size = fontSizeMap)
table.cell(tbl, 1, 10, str.tostring(ema500, '#.##'), text_color = ema500 >= close ? color.red : color.green, text_size = fontSizeMap)
table.cell(tbl, 1, 11, str.tostring(ema610, '#.##'), text_color = ema610 >= close ? color.red : color.green, text_size = fontSizeMap)
table.cell(tbl, 1, 12, str.tostring(ema750, '#.##'), text_color = ema750 >= close ? color.red : color.green, text_size = fontSizeMap)
table.cell(tbl, 1, 13, str.tostring(ema987, '#.##'), text_color = ema987 >= close ? color.red : color.green, text_size = fontSizeMap)
table.cell(tbl, 1, 14, str.tostring(Komp34_value, '#.##') + "\n" + "" + str.tostring(Komp34_change, '#.##') + " %", text_color = comp_ema34 <= close/xu100 ? color.green : color.red, text_size = fontSizeMap)
table.cell(tbl, 1, 15, str.tostring(Komp233_value, '#.##') + "\n" + "" + str.tostring(Komp233_change, '#.##') + " %", text_color = comp_ema233 <= close/xu100 ? color.green : color.red, text_size = fontSizeMap)
table.cell(tbl, 1, 16, str.tostring(higherRSI, '#.##'), text_color = higherRSI >= 50 ? color.green : color.red, text_size = fontSizeMap)
table.cell(tbl, 1, 17, str.tostring(rsi, '#.##'), text_color = rsi >= 50 ? color.green : color.red, text_size = fontSizeMap)

// Alarm ayarları (Enable/Disable)

enableEma34Alarm = input.bool(true, title = 'EMA 34 Alarm', group="Temel Alarm Ayarları")
enablekomp34Alarm = input.bool(true, title = 'KOMP 34 Alarm', group="Temel Alarm Ayarları")
enablekomp233Alarm = input.bool(true, title = 'KOMP 233 Alarm', group="Temel Alarm Ayarları")

// EMA 34 Alarm Koşulları
ema34CrossUp = ta.crossover(close, ema34) // Fiyat EMA 34'ün üzerine çıkıyor
ema34CrossDown = ta.crossunder(close, ema34) // Fiyat EMA 34'ün altına iniyor

if enableEma34Alarm
    if (ema34CrossUp)
        alert("FİYAT YUKARI KESTİ EMA 34!", alert.freq_once_per_bar)
    if ema34CrossDown
        alert('FİYAT AŞAĞI KESTİ EMA 34!', alert.freq_once_per_bar)

komp233CrossUp = ta.crossover(close, comp_ema233 * xu100) // Fiyat EMA 55'in üzerine çıkıyor
komp233CrossDown = ta.crossunder(close, comp_ema233 * xu100) // Fiyat EMA 55'in altına iniyor

if enablekomp233Alarm
    if (komp233CrossUp)
        alert("FİYAT YUKARI KESTİ KOMP 233!", alert.freq_once_per_bar)
    if komp233CrossDown
        alert('FİYAT AŞAĞI KESTİ KOMP 233!', alert.freq_once_per_bar)


komp34CrossUp = ta.crossover(close, comp_ema34 * xu100) // Fiyat EMA 55'in üzerine çıkıyor
komp34CrossDown = ta.crossunder(close, comp_ema34 * xu100) // Fiyat EMA 55'in altına iniyor

if enablekomp34Alarm
    if (komp34CrossUp)
        alert("FİYAT YUKARI KESTİ KOMP 34!", alert.freq_once_per_bar)
    if komp34CrossDown
        alert('FİYAT AŞAĞI KESTİ KOMP 34!', alert.freq_once_per_bar)



Leave a Comment