Untitled

 avatar
unknown
plain_text
a month ago
59 kB
5
Indexable
//@version=5
indicator("RSN_Kule", overlay = true, max_lines_count = 40)

// INPUTS
length = input.int(28, "Trend")
atr_length = input.int(200, "ATR")  // ATR için parametre

// VARİABLER
var bool trend = na
float trend_value = na

// Colors
color up_color = #06b690
color dn_color = #b60606

// ATR for calculating stop loss and target levels
series float atr_value = ta.sma(ta.atr(atr_length), atr_length) * 0.8  // ATR hesaplamasında atr_length kullanıldı

// Moving averages for trend detection
series float sma_high = ta.sma(high, length) + atr_value
series float sma_low = ta.sma(low, length) - atr_value
color plot_color = color.new(chart.fg_color, 80)

// UDT for managing lines and labels
type TrendTargets
    line[] lines
    label[] labels

// Initialize UDT
var TrendTargets targets_up = TrendTargets.new(array.new_line(), array.new_label())
var TrendTargets targets_down = TrendTargets.new(array.new_line(), array.new_label())

// CÁLCULOS
// Determine trend based on crossovers
if ta.crossover(close, sma_high) and barstate.isconfirmed
    trend := true
if ta.crossunder(close, sma_low) and barstate.isconfirmed
    trend := false

trend_value := switch
    trend => sma_low
    not trend => sma_high

trend_color = trend ? up_color : not trend ? dn_color : na

// Plot candlesticks with trend color
// plotcandle(open, high, low, close,
//            title = 'Title', 
//            color = trend_color,
//            wickcolor = trend_color, 
//            bordercolor = trend_color)

// Plot trailing stops
p1 = plot(trend ? trend_value : na, style = plot.style_linebr, color = plot_color)
p2 = plot(not trend ? trend_value : na, style = plot.style_linebr, color = plot_color)
p0 = plot(hl2, display = display.none, editable = false)

//functions
xrf(values, length) =>
    r_val = float(na)
    if length >= 1
        for i = 0 to length by 1
            if na(r_val) or not na(values[i])
                r_val := values[i]
                r_val
    r_val

xsa(src, len, wei) =>
    sumf = 0.0
    ma = 0.0
    out = 0.0
    sumf := nz(sumf[1]) - nz(src[len]) + src
    ma := na(src[len]) ? na : sumf / len
    out := na(out[1]) ? ma : (src * wei + out[1] * (len - wei)) / len
    out

//set up a simple model of banker fund flow trend	
fundtrend = (3 * xsa((close - ta.lowest(low, 27)) / (ta.highest(high, 27) - ta.lowest(low, 27)) * 100, 5, 1) - 2 * xsa(xsa((close - ta.lowest(low, 27)) / (ta.highest(high, 27) - ta.lowest(low, 27)) * 100, 5, 1), 3, 1) - 50) * 1.032 + 50
//define typical price for banker fund
typ = (2 * close + high + low + open) / 5
//lowest low with mid term fib # 34
lol = ta.lowest(low, 34)
//highest high with mid term fib # 34
hoh = ta.highest(high, 34)
//define banker fund flow bull bear line
bullbearline = ta.ema((typ - lol) / (hoh - lol) * 100, 13)
//define banker entry signal
bankerentry = ta.crossover(fundtrend, bullbearline) and bullbearline < 41
bankerexit = ta.crossunder(fundtrend, bullbearline) and bullbearline > 75

//banker fund entry with yellow candle
// Banker fund entry with yellow circle
plotshape(bankerentry, style=shape.circle, location=location.belowbar, color=#ffffff92, size=size.normal)

// Banker fund exit with red circle
plotshape(bankerexit, style=shape.circle, location=location.abovebar, color=#b90cf34d, size=size.normal)

// Variables for 3D timeframe
fundtrend_3d = request.security(syminfo.tickerid, "3D",  (3 * xsa((close - ta.lowest(low, 27)) / (ta.highest(high, 27) - ta.lowest(low, 27)) * 100, 5, 1) -  2 * xsa(xsa((close - ta.lowest(low, 27)) / (ta.highest(high, 27) - ta.lowest(low, 27)) * 100, 5, 1), 3, 1) -  50) * 1.032 + 50)

typ_3d = request.security(syminfo.tickerid, "3D", (2 * close + high + low + open) / 5)

lol_3d = request.security(syminfo.tickerid, "3D", ta.lowest(low, 34))
hoh_3d = request.security(syminfo.tickerid, "3D", ta.highest(high, 34))

bullbearline_3d = request.security(syminfo.tickerid, "3D", ta.ema((typ_3d - lol_3d) / (hoh_3d - lol_3d) * 100, 13))

bankerentry_3d = request.security(syminfo.tickerid, "3D", ta.crossover(fundtrend_3d, bullbearline_3d) and bullbearline_3d < 41)
bankerexit_3d = request.security(syminfo.tickerid, "3D", ta.crossunder(fundtrend_3d, bullbearline_3d) and bullbearline_3d > 75)

// Banker fund entry with yellow candle
// plotcandle(0, 50, 0, 5000, color = bankerentry_3d ? #ffffff33 : na, wickcolor = bankerentry_3d ? #00000000 : na, bordercolor = bankerentry_3d ? #00000000 : na, offset=0)
// plotcandle(0, 50, 0, 5000, color = bankerexit_3d ? #1613d35e : na, wickcolor = bankerexit_3d ? #00000000 : na, bordercolor = bankerexit_3d ? #00000000 : na, offset=0)

// Using plotshape for entry and exit signals with offset
plotshape(bankerentry_3d, color = #00ff2f, style = shape.triangleup, location = location.belowbar, offset = -8, size=size.normal)  // Entry signal with offset
plotshape(bankerexit_3d, color = color.rgb(255, 0, 0), style = shape.triangledown, location = location.abovebar, offset = -8, size=size.normal) // Exit signal with offset


// 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)

// Kullanıcıdan zaman dilimini seçmesini istiyoruz
timeframekar = input.timeframe("D", title="Kar AL ve Tekrar Al Zaman Dilimi Seç")

// MACD ayarları
fastLength = 12
slowLength = 26
signalSmoothing = 9

macd = fastLength - slowLength

// Zaman dilimindeki MACD hesaplamaları
[macdLine, signalLine, _] = ta.macd(close, fastLength, slowLength, signalSmoothing)

// Sinyal koşulları
buySignalm = ta.crossover(macdLine, 0)
sellSignalm = ta.crossunder(macdLine, 0)
macdsart = macdLine > 0

buySignal34 = ta.crossover(macdLine, signalLine) and macdsart
sellSignal34 = ta.crossunder(macdLine, signalLine) and macdsart

// Çizim koşulları (Farklı zaman dilimlerine göre çizim)
plotshape(buySignal34, location=location.belowbar, style=shape.arrowup, title='TEKRAR AL', text='RE_BUY', textcolor=#eac809, size=size.normal, offset=0, display = display.none)
plotshape(sellSignal34, location=location.abovebar, style=shape.arrowdown, title='KAR AL', text='RE_SELL', textcolor=#00ffbf, size=size.normal, offset=0, display = display.none)

// Fibonacci göstergesi ayarları
showFibonacci = input.bool(false, title="Show Fibonacci Levels", group="Fibonacci Settings")
fibDirection = input.string('Bottom to Top', title = 'Fibonacci Direction', options = ['Bottom to Top', 'Top to Bottom'], display = display.none)
lookbackBars = 144  // Fibonacci hesaplamasında bakılacak periyot
lookbackPrevBars = 144  // Önceki yüksek ve düşük hesaplama periyodu

// Fibonacci seviyeleri
fibLevel0 = 0
fibLevel1 = 0.214
fibLevel3 = 0.380
fibLevel6 = 0.618
fibLevel7 = 0.800
fibLevel8 = 1
fibLevel9 = 1.200

// En yüksek yüksek ve en düşük düşük hesaplama
highestHigh = ta.highest(high, lookbackBars)
lowestLow = ta.lowest(low, lookbackBars)

// Önceki yüksek ve düşük hesaplama
previousHigh = ta.highest(high, lookbackPrevBars)
previousLow = ta.lowest(low, lookbackPrevBars)

// Fibonacci seviyelerinin hesaplanması
fib0 = fibDirection == 'Bottom to Top' ? lowestLow + (highestHigh - lowestLow) * fibLevel0 : highestHigh - (highestHigh - lowestLow) * fibLevel0
fib1 = fibDirection == 'Bottom to Top' ? lowestLow + (highestHigh - lowestLow) * fibLevel1 : highestHigh - (highestHigh - lowestLow) * fibLevel1
fib3 = fibDirection == 'Bottom to Top' ? lowestLow + (highestHigh - lowestLow) * fibLevel3 : highestHigh - (highestHigh - lowestLow) * fibLevel3
fib6 = fibDirection == 'Bottom to Top' ? lowestLow + (highestHigh - lowestLow) * fibLevel6 : highestHigh - (highestHigh - lowestLow) * fibLevel6
fib7 = fibDirection == 'Bottom to Top' ? lowestLow + (highestHigh - lowestLow) * fibLevel7 : highestHigh - (highestHigh - lowestLow) * fibLevel7
fib8 = fibDirection == 'Bottom to Top' ? lowestLow + (highestHigh - lowestLow) * fibLevel8 : highestHigh - (highestHigh - lowestLow) * fibLevel8
fib9 = fibDirection == 'Bottom to Top' ? lowestLow + (highestHigh - lowestLow) * fibLevel9 : highestHigh - (highestHigh - lowestLow) * fibLevel9

// Fibonacci etiketleri için array
var array<label> fibLabels = array.new<label>()

// Etiketleri güncelleme fonksiyonu
updateLabels() =>
    if array.size(fibLabels) > 0
        for i = 0 to array.size(fibLabels) - 1
            label.delete(array.get(fibLabels, i))
        array.clear(fibLabels)
    
    if showFibonacci
        // Yeni etiketleri oluştur
        array.push(fibLabels, label.new(bar_index + 28, fib0, text = 'DİP - ' + str.tostring(fib0, format.mintick), color = color.rgb(88, 20, 95, 37), textcolor = color.rgb(255, 255, 255), style = label.style_label_left, size = size.normal))
        array.push(fibLabels, label.new(bar_index + 28, fib1, text = 'STOP - ' + str.tostring(fib1, format.mintick), color = color.rgb(27, 79, 25, 36), textcolor = color.rgb(255, 255, 255), style = label.style_label_left, size = size.normal))
        array.push(fibLabels, label.new(bar_index + 28, fib3, text = 'GİRİŞ - ' + str.tostring(fib3, format.mintick), color = #5b5415, textcolor = color.rgb(255, 255, 255), style = label.style_label_left, size = size.normal))
        array.push(fibLabels, label.new(bar_index + 28, fib6, text = 'ONAY - ' + str.tostring(fib6, format.mintick), color = #145116bd, textcolor = color.rgb(255, 255, 255), style = label.style_label_left, size = size.normal))
        array.push(fibLabels, label.new(bar_index + 28, fib7, text = '1. ÇIKIŞ - ' + str.tostring(fib7, format.mintick), color = color.rgb(255, 55, 0, 30), textcolor = color.rgb(255, 255, 255), style = label.style_label_left, size = size.normal))
        array.push(fibLabels, label.new(bar_index + 28, fib8, text = 'TEPE - ' + str.tostring(fib8, format.mintick), color = color.rgb(90, 20, 99, 34), textcolor = color.rgb(255, 255, 255), style = label.style_label_left, size = size.normal))
        array.push(fibLabels, label.new(bar_index + 28, fib9, text = '2. ÇIKIŞ - ' + str.tostring(fib9, format.mintick), color = color.rgb(221, 72, 8, 21), textcolor = color.rgb(255, 255, 255), style = label.style_label_left, size = size.normal))

// Etiketleri güncelle
updateLabels()

// 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_ema55 = input.bool(false, "KOMP EMA 55", group="Comparative EMA Display", inline="55")
color_ema55 = input.color(color.orange, "", group="Comparative EMA Display", inline="55")

show_comp_ema89 = input.bool(false, "KOMP EMA 89", group="Comparative EMA Display", inline="89")
color_ema89 = input.color(color.teal, "", group="Comparative EMA Display", inline="89")

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")

show_comp_ema377 = input.bool(false, "KOMP EMA 377", group="Comparative EMA Display", inline="377")
color_ema377 = input.color(color.blue, "", group="Comparative EMA Display", inline="377")

show_comp_ema610 = input.bool(false, "KOMP EMA 610", group="Comparative EMA Display", inline="610")
color_ema610 = input.color(color.gray, "", group="Comparative EMA Display", inline="610")

show_comp_ema987 = input.bool(false, "KOMP EMA 987", group="Comparative EMA Display", inline="987")
color_ema987 = input.color(color.maroon, "", group="Comparative EMA Display", inline="987")

show_comp_ema1597 = input.bool(false, "KOMP EMA 1597", group="Comparative EMA Display", inline="1597")
color_ema1597 = input.color(color.navy, "", group="Comparative EMA Display", inline="1597")

// show_comp_ema2584 = input.bool(false, "KOMP EMA 2584", group="Comparative EMA Display", inline="2584")
// color_ema2584 = input.color(color.aqua, "", group="Comparative EMA Display", inline="2584")

// show_comp_ema4181 = input.bool(false, "KOMP EMA 4181", group="Comparative EMA Display", inline="4181")
// color_ema4181 = input.color(color.fuchsia, "", group="Comparative EMA Display", inline="4181")

showema34_1s  = input.bool(true, "EMA 34 1s", group="EMA Values")

// 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_ema12 = input.bool(false, "EMA 12", group="EMA Display", inline="12")
// color_regular_ema12 = input.color(#368c3c, "", group="EMA Display", inline="12", display=display.none)

// show_regular_ema26 = input.bool(false, "EMA 26", group="EMA Display", inline="26")
// color_regular_ema26 = input.color(#e4cb0c, "", group="EMA Display", inline="26", 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_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", display=display.none)

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_ema610 = input.bool(false, "EMA 610", group="EMA Display", inline="610")
color_regular_ema610 = input.color(color.rgb(124, 128, 131), "", group="EMA Display", inline="610", display=display.none)

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

// show_regular_ema1597 = input.bool(false, "EMA 1597", group="EMA Display", inline="1597")
// color_regular_ema1597 = input.color(color.rgb(145, 18, 18), "", group="EMA Display", inline="1597", display=display.none)

// show_regular_ema115 = input.bool(false, "PIVOT 115", group="EMA Display", inline="115")
// color_regular_ema115 = input.color(#ea754b, "", group="EMA Display", inline="115", display=display.none)

// EMA Length inputs
// emaLength1 = input.int(12, title = '', group="EMA Display", inline="12")
// emaLength2 = input.int(26, title = '', group="EMA Display", inline="26")
emaLength12 = input.int(14, title = '', group="EMA Display", inline="14")
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")
emaLength8 = input.int(610, title = '', group="EMA Display", inline="610")
emaLength9 = input.int(987, title = '', group="EMA Display", inline="987")
// emaLength13 = input.int(115, title = '', group="EMA Display", inline="115")

// Calculate Regular EMAs
// ema12 = ta.ema(close, emaLength1)
// ema26 = ta.ema(close, emaLength2)
ema14 = ta.ema(close, emaLength12)
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)
ema610 = ta.ema(close, emaLength8)
ema987 = ta.ema(close, emaLength9)
// ema115 = ta.ema(close, emaLength13)

// Plot fonksiyonları - stil panelinde görünmeden ama parametre kontrolü çalışarak
// plot(show_regular_ema12 ? ema12 : na, title='12', color=color_regular_ema12, linewidth=2)
// plot(show_regular_ema26 ? ema26 : na, title='26', color=color_regular_ema26, linewidth=2)
plot(show_regular_ema14 ? ema14 : na, title='', color=color_regular_ema14, 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_ema610 ? ema610 : na, title='610', color=color_regular_ema610, linewidth=2)
plot(show_regular_ema987 ? ema987 : na, title='987', color=color_regular_ema987, linewidth=2)
// plot(show_regular_ema115 ? ema115 : na, title='115', color=color_regular_ema115, 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_CrossUp = ta.crossover(macdLine, 0) // MACD yukarı kesiş
higherrsi_Crossdown = ta.crossunder(macdLine, 0) // MACD aşağı kesiş
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ş

// Al ve Sat koşulları
buySignal2 = ta.crossover(macdLine, 0)   // MACD pozitif oldu
sellSignal2 = ta.crossunder(macdLine, 0) // MACD negatif oldu

// // Kullanıcı tarafından seçilebilir zaman dilimi parametresi
timeframe_input = input.timeframe("60", title="EMA 34 1s", confirm=true)

 // EMA 34 hesaplama (seçilen zaman dilimine göre)
ema34_1s = request.security(syminfo.tickerid, timeframe_input, ta.ema(close, 34))

 // Çizgi ve etiket için değişkenler
line_color = #10f751  // Çizgi için kullanılan renk
var line ema_line = na  // Çizgi değişkeni
var label ema_label = na  // Etiket değişkeni

if bar_index > 6
// EMA 34_1s
    if showema34_1s
        if na(ema_line)
            ema_line := line.new(x1=bar_index, y1=ema34_1s, x2=bar_index + 4, y2=ema34_1s, color=line_color, width=2)
        else
            line.set_xy1(ema_line, bar_index, ema34_1s)
            line.set_xy2(ema_line, bar_index + 4, ema34_1s)

        label_text = "Ema-34_1s: " + str.tostring(ema34_1s, '#.##')
        if na(ema_label)
            ema_label := label.new(x=bar_index + 4, y=ema34_1s, text=label_text, style=label.style_label_left, color=color.new(color.white, 100), textcolor=line_color, size=size.large)
        else
            label.set_x(ema_label, bar_index + 4)
            label.set_y(ema_label, ema34_1s)
            label.set_text(ema_label, label_text)
            label.set_textcolor(ema_label, line_color)
            label.set_size(ema_label, get_text_size())
    else
        if not na(ema_line)
            line.delete(ema_line)
            ema_line := na
        if not na(ema_label)
            label.delete(ema_label)
            ema_label := na

        
// XU100 fiyatı ve EMA uzunlukları
xu100 = request.security('BIST:XU100', timeframe.period, close)
compEmaLength34 = input.int(34, title='', group="Comparative EMA Display", inline="34")
compEmaLength55 = input.int(55, title='', group="Comparative EMA Display", inline="55")
compEmaLength89 = input.int(89, title='', group="Comparative EMA Display", inline="89")
compEmaLength233 = input.int(233, title='', group="Comparative EMA Display", inline="233")
compEmaLength377 = input.int(377, title='', group="Comparative EMA Display", inline="377")
compEmaLength610 = input.int(610, title='', group="Comparative EMA Display", inline="610")
compEmaLength987 = input.int(987, title='', group="Comparative EMA Display", inline="987")
compEmaLength1597 = input.int(1597, title='', group="Comparative EMA Display", inline="1597")
// compEmaLength2584 = input.int(2584, title='', group="Comparative EMA Display", inline="2584")
// compEmaLength4181 = input.int(4181, title='', group="Comparative EMA Display", inline="4181")

// Mevcut varlığın fiyatı ile XU100 arasındaki oran üzerinden EMA hesaplama
comp_ema34 = ta.ema(close / xu100, compEmaLength34)
comp_ema55 = ta.ema(close / xu100, compEmaLength55)
comp_ema89 = ta.ema(close / xu100, compEmaLength89)
comp_ema233 = ta.ema(close / xu100, compEmaLength233)
comp_ema377 = ta.ema(close / xu100, compEmaLength377)
comp_ema610 = ta.ema(close / xu100, compEmaLength610)
comp_ema987 = ta.ema(close / xu100, compEmaLength987)
comp_ema1597 = ta.ema(close / xu100, compEmaLength1597)
// comp_ema2584 = ta.ema(close / xu100, compEmaLength2584)
// comp_ema4181 = ta.ema(close / xu100, compEmaLength4181)

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

var line ema_line2 = na
var label ema_label2 = na

var line ema_line3 = na
var label ema_label3 = na

var line ema_line4 = na
var label ema_label4 = na

var line ema_line5 = na
var label ema_label5 = na

var line ema_line6 = na
var label ema_label6 = na

var line ema_line7 = na
var label ema_label7 = na

var line ema_line8 = na
var label ema_label8 = na

// var line ema_line9 = na
// var label ema_label9 = na

// var line ema_line10 = na
// var label ema_label10 = 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 55
    if na(ema_line2) and show_comp_ema55
        ema_line2 := line.new(x1=bar_index, y1=comp_ema55 * xu100, x2=bar_index + 6, y2=comp_ema55 * xu100, color=color_ema55, width=2)
        ema_label2 := label.new(x=bar_index + 7, y=comp_ema55 * xu100, text=str.tostring(comp_ema55 * xu100, '#.##'), style=label.style_label_left, color=color.new(color.white, 100), textcolor=color_ema55, size=size.normal)
    else if show_comp_ema55
        line.set_xy1(ema_line2, bar_index, comp_ema55 * xu100)
        line.set_xy2(ema_line2, bar_index + 6, comp_ema55 * xu100)
        label.set_x(ema_label2, bar_index + 6)
        label.set_y(ema_label2, comp_ema55 * xu100)
        label.set_text(ema_label2,  "KOMP-55: " + str.tostring(comp_ema55 * xu100, '#.##'))
        label.set_size(ema_label2, get_text_size())

    // EMA 89
    if na(ema_line6) and show_comp_ema89
        ema_line6 := line.new(x1=bar_index, y1=comp_ema89 * xu100, x2=bar_index + 6, y2=comp_ema89 * xu100, color=color_ema89, width=2)
        ema_label6 := label.new(x=bar_index + 7, y=comp_ema89 * xu100, text=str.tostring(comp_ema89 * xu100, '#.##'), style=label.style_label_left, color=color.new(color.white, 100), textcolor=color_ema89, size=size.normal)
    else if show_comp_ema89
        line.set_xy1(ema_line6, bar_index, comp_ema89 * xu100)
        line.set_xy2(ema_line6, bar_index + 6, comp_ema89 * xu100)
        label.set_x(ema_label6, bar_index + 6)
        label.set_y(ema_label6, comp_ema89 * xu100)
        label.set_text(ema_label6,  "KOMP-89: " + str.tostring(comp_ema89 * xu100, '#.##'))
        label.set_size(ema_label6, 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())

    // EMA 377
    if na(ema_line4) and show_comp_ema377
        ema_line4 := line.new(x1=bar_index, y1=comp_ema377 * xu100, x2=bar_index + 6, y2=comp_ema377 * xu100, color=color_ema377, width=2)
        ema_label4 := label.new(x=bar_index + 7, y=comp_ema377 * xu100, text=str.tostring(comp_ema377 * xu100, '#.##'), style=label.style_label_left, color=color.new(color.white, 100), textcolor=color_ema377, size=size.normal)
    else if show_comp_ema377
        line.set_xy1(ema_line4, bar_index, comp_ema377 * xu100)
        line.set_xy2(ema_line4, bar_index + 6, comp_ema377 * xu100)
        label.set_x(ema_label4, bar_index + 6)
        label.set_y(ema_label4, comp_ema377 * xu100)
        label.set_text(ema_label4,  "KOMP-377: " + str.tostring(comp_ema377 * xu100, '#.##'))
        label.set_size(ema_label4, get_text_size())

    // EMA 610
    if na(ema_line5) and show_comp_ema610
        ema_line5 := line.new(x1=bar_index, y1=comp_ema610 * xu100, x2=bar_index + 6, y2=comp_ema610 * xu100, color=color_ema610, width=2)
        ema_label5 := label.new(x=bar_index + 7, y=comp_ema610 * xu100, text=str.tostring(comp_ema610 * xu100, '#.##'), style=label.style_label_left, color=color.new(color.white, 100), textcolor=color_ema610, size=size.normal)
    else if show_comp_ema610
        line.set_xy1(ema_line5, bar_index, comp_ema610 * xu100)
        line.set_xy2(ema_line5, bar_index + 6, comp_ema610 * xu100)
        label.set_x(ema_label5, bar_index + 6)
        label.set_y(ema_label5, comp_ema610 * xu100)
        label.set_text(ema_label5,  "KOMP-610: " + str.tostring(comp_ema610 * xu100, '#.##'))
        label.set_size(ema_label5, get_text_size())

    // EMA 987
    if na(ema_line8) and show_comp_ema987
        ema_line8 := line.new(x1=bar_index, y1=comp_ema987 * xu100, x2=bar_index + 6, y2=comp_ema987 * xu100, color=color_ema987, width=2)
        ema_label8 := label.new(x=bar_index + 7, y=comp_ema987 * xu100, text=str.tostring(comp_ema987 * xu100, '#.##'), style=label.style_label_left, color=color.new(color.white, 100), textcolor=color_ema987, size=size.normal)
    else if show_comp_ema987
        line.set_xy1(ema_line8, bar_index, comp_ema987 * xu100)
        line.set_xy2(ema_line8, bar_index + 6, comp_ema987 * xu100)
        label.set_x(ema_label8, bar_index + 6)  // Çizginin bitiş noktasına sabitle
        label.set_y(ema_label8, comp_ema987 * xu100)
        label.set_text(ema_label8,  "KOMP-987: " + str.tostring(comp_ema987 * xu100, '#.##'))
        label.set_size(ema_label8, get_text_size())

    // EMA 1597
    if na(ema_line7) and show_comp_ema1597
        ema_line7 := line.new(x1=bar_index, y1=comp_ema1597 * xu100, x2=bar_index + 6, y2=comp_ema1597 * xu100, color=color_ema1597, width=2)
        ema_label7 := label.new(x=bar_index + 7, y=comp_ema1597 * xu100, text="EMA-1597: " + str.tostring(comp_ema1597 * xu100, '#.##'), style=label.style_label_left, color=color.new(color.white, 100), textcolor=color_ema1597, size=size.normal)
    else if show_comp_ema1597
        line.set_xy1(ema_line7, bar_index, comp_ema1597 * xu100)
        line.set_xy2(ema_line7, bar_index + 6, comp_ema1597 * xu100)
        label.set_x(ema_label7, bar_index + 6)
        label.set_y(ema_label7, comp_ema1597 * xu100)
        label.set_text(ema_label7, "KOMP-1597: " + str.tostring(comp_ema1597 * xu100, '#.##'))
        label.set_size(ema_label7, get_text_size())

    // // EMA 2584
    // if na(ema_line9) and show_comp_ema2584
    //     ema_line9 := line.new(x1=bar_index, y1=comp_ema2584 * xu100, x2=bar_index + 6, y2=comp_ema2584 * xu100, color=color_ema2584, width=2)
    //     ema_label9 := label.new(x=bar_index + 7, y=comp_ema2584 * xu100, text=str.tostring(comp_ema2584 * xu100, '#.##'), style=label.style_label_left, color=color.new(color.white, 100), textcolor=color_ema2584, size=get_text_size())
    // else if show_comp_ema2584
    //     line.set_xy1(ema_line9, bar_index, comp_ema2584 * xu100)
    //     line.set_xy2(ema_line9, bar_index + 6, comp_ema2584 * xu100)
    //     label.set_x(ema_label9, bar_index + 6)
    //     label.set_y(ema_label9, comp_ema2584 * xu100)
    //     label.set_text(ema_label9, "KOMP-2584: " + str.tostring(comp_ema2584 * xu100, '#.##'))
    //     label.set_size(ema_label9, get_text_size())
    
    // // EMA 4181
    // if na(ema_line10) and show_comp_ema4181
    //     ema_line10 := line.new(x1=bar_index, y1=comp_ema4181 * xu100, x2=bar_index + 6, y2=comp_ema4181 * xu100, color=color_ema4181, width=2)
    //     ema_label10 := label.new(x=bar_index + 7, y=comp_ema4181 * xu100, text=str.tostring(comp_ema4181 * xu100, '#.##'), style=label.style_label_left, color=color.new(color.white, 100), textcolor=color_ema4181, size=size.large)
    // else if show_comp_ema4181
    //     line.set_xy1(ema_line10, bar_index, comp_ema4181 * xu100)
    //     line.set_xy2(ema_line10, bar_index + 6, comp_ema4181 * xu100)
    //     label.set_x(ema_label10, bar_index + 6)  // Çizginin bitiş noktasına sabitle
    //     label.set_y(ema_label10, comp_ema4181 * xu100)
    //     label.set_text(ema_label10, str.tostring(comp_ema4181 * xu100, '#.##'))


////hacim tablo///////

// Kullanıcıdan sembol girişleri
// Tabloyu göster/gizle düğmesi
showTable = input.bool(false, title="HACİM TABLOSUNU GÖSTER", group="HACİM TABLOSU")
string s01 = syminfo.ticker  // Mevcut grafikteki sembol kullanılır
frame_color1 = input.color(#000000, title="Çerçeve Rengi", group="HACİM TABLOSU", inline="THC")
frame_width1 = 2

// Parametreler
lookbackPeriod = input.int(23, title="Bar Sayısı", group="HACİM TABLOSU", inline="THC")

// Tablo konumu için kullanıcı girişi
tablePosition1 = input.string("top_center", title="Tablo Konumu", options=["top_left", "top_center", "top_right", "bottom_left", "bottom_center", "bottom_right"], group="HACİM TABLOSU", inline="THC")

// Tablo boyutu için kullanıcı girişi
tableSize = input.string("normal", title="Tablo Boyutu", options=["tiny", "small", "normal", "large"], group="HACİM TABLOSU", inline="THC")

// Tablo stil ayarları için kullanıcı girişleri
tableBgColor1 = input.color(#000000, title="Arka Plan Rengi", group="HACİM TABLOSU", inline="THCE")
tableBorderColor1 = input.color(color.orange, title="Çerçeve Rengi", group="HACİM TABLOSU", inline="THCE")
tableBorderWidth1 = 2
// Renk seçenekleri için kullanıcı girişleri
headerColor = input.color(color.new(color.black, 0), title="Başlık Arka Plan Rengi", group="HACİM TABLOSU", inline="THCE")
buyColor = input.color(#4caf4f69, title="Alış Hacmi Rengi", group="HACİM TABLOSU", inline="THCE")
sellColor = input.color(#ff525279, title="Satış Hacmi Rengi", group="HACİM TABLOSU", inline="THCE")
resultBuyColor = input.color(#4caf4f70, title="Alış Rengi", group="HACİM TABLOSU", inline="THCE")
resultSellColor = input.color(#ff525260, title="Satış Rengi", group="HACİM TABLOSU", inline="THCE")
textColor = input.color(color.white, title="Metin Rengi", group="HACİM TABLOSU", inline="THCE")



// Hücre boyutlarını belirleme fonksiyonu
getFontSize(size) =>
    switch size
        "tiny" => size.tiny
        "small" => size.small
        "normal" => size.normal
        "large" => size.large

// Hacim hesaplama fonksiyonu
calculateVolumes(closeData, volumeData) =>
    float upVolumeSum = 0.0
    float downVolumeSum = 0.0

    for i = 0 to lookbackPeriod - 1
        upVolumeSum += (closeData[i] > closeData[i + 1] ? volumeData[i] : 0)
        downVolumeSum += (closeData[i] < closeData[i + 1] ? volumeData[i] : 0)

    totalVolume = upVolumeSum + downVolumeSum
    result = upVolumeSum > downVolumeSum ? "Pozitif" : "Negatif"
    [upVolumeSum, downVolumeSum, result]

// Mevcut sembol için hacim hesaplaması
[up1, down1, res1] = calculateVolumes(close, volume) 

// Tablo oluştur
var table volumeTable = na
if showTable
    if na(volumeTable)
        volumeTable := table.new(position=tablePosition1, columns=4, rows=2, bgcolor=tableBgColor1, border_color=tableBorderColor1, border_width=tableBorderWidth1, frame_color=frame_color1, frame_width=frame_width1)

    // Başlık satırı
    if bar_index == 0
        table.cell(volumeTable, 0, 0, "Hacim Analizi", bgcolor=headerColor, text_color=textColor, text_size=getFontSize(tableSize))
        table.cell(volumeTable, 1, 0, "Alış Hacmi", bgcolor=headerColor, text_color=textColor, text_size=getFontSize(tableSize))
        table.cell(volumeTable, 2, 0, "Satış Hacmi", bgcolor=headerColor, text_color=textColor, text_size=getFontSize(tableSize))
        table.cell(volumeTable, 3, 0, "Sonuç", bgcolor=headerColor, text_color=textColor, text_size=getFontSize(tableSize))

    // Mevcut sembol verilerini tabloya ekle
    table.cell(volumeTable, 0, 1, s01, text_color=textColor, text_size=getFontSize(tableSize))
    table.cell(volumeTable, 1, 1, str.tostring(up1, format.volume), bgcolor=buyColor, text_color=textColor, text_size=getFontSize(tableSize))
    table.cell(volumeTable, 2, 1, str.tostring(down1, format.volume), bgcolor=sellColor, text_color=textColor, text_size=getFontSize(tableSize))
    table.cell(volumeTable, 3, 1, res1, bgcolor=res1 == "Pozitif" ? resultBuyColor : resultSellColor, text_color=textColor, text_size=getFontSize(tableSize))
else
    if not na(volumeTable)
        table.delete(volumeTable)
        volumeTable := na

// Gan 1/1
// Kullanıcı girişleri (Görseldeki ayarlara göre)
showLevel = input.bool(false, title="1/1 Seviyesi")
lineColor = input.color(color.rgb(255, 255, 255, 69), title="Renk", inline="lineSettings")
lineWidth = input.int(2, title="", minval=1, maxval=5, inline="lineSettings")
lineStyle = input.string("Düz Çizgi", options=["Düz Çizgi", "Kesikli Çizgi"], title="", inline="lineSettings")

showIntersection = input.bool(true, title="1/1 Kesişimi")
labelColor = input.color(color.rgb(251, 251, 249, 88), title="Renk", inline="labelSettings")
labelPosition = input.string("Bar üstü", options=["Bar üstü"], title="", inline="labelSettings")

// Çizgi stili seçimi
lineStyleOption = lineStyle == "Düz Çizgi" ? line.style_solid : line.style_dotted

// Pivot periyodu
pivotPeriod = input.int(144, title="Pivot Periyodu", minval=1)

// En düşük ve en yüksek fiyat hesaplaması (Mevcut 1/1 Seviyesi)
lowestLow1 = ta.lowest(low, pivotPeriod)
highestHigh1 = ta.highest(high, pivotPeriod)
gannLevel = (lowestLow1 + highestHigh1) / 2

// 144 periyotluk Gann seviyesi hesaplaması
lowestLow144 = ta.lowest(low, 144)
highestHigh144 = ta.highest(high, 144)
gann144Level = (lowestLow144 + highestHigh144) / 2

// Önceki çizgiyi silme
var line gannLine = na
var line gann144Line = na

if not na(gannLine)
    line.delete(gannLine)
if not na(gann144Line)
    line.delete(gann144Line)

// Yeni çizgiyi oluşturma (Mevcut 1/1 Seviyesi)
if showLevel
    gannLine := line.new(x1=bar_index - pivotPeriod, y1=gannLevel, x2=bar_index, y2=gannLevel, extend=extend.right, color=lineColor, width=lineWidth, style=lineStyleOption)

// Yeni çizgiyi oluşturma (144 Periyot Gann Seviyesi)
if showLevel
    gann144Line := line.new(x1=bar_index - 144, y1=gann144Level, x2=bar_index, y2=gann144Level, extend=extend.right, color=lineColor, width=lineWidth, style=lineStyleOption)

// Sadece çizgiyi yukarı kesen mumlarda etiket oluşturma (Mevcut 1/1 Seviyesi)
if showIntersection and close > gannLevel and close[1] <= gannLevel[1]
    label.new(x=bar_index, y=low, text="1/1", color=labelColor, textcolor=color.black, style=label.style_label_up, size=size.small)

// Sadece çizgiyi yukarı kesen mumlarda etiket oluşturma (144 Periyot Gann Seviyesi)
if showIntersection and close > gann144Level and close[1] <= gann144Level[1]
    label.new(x=bar_index, y=low, text="1/1", color=labelColor, textcolor=color.black, style=label.style_label_up, size=size.small)

// EMA 8 için parametreler
emaFast_tf = input.timeframe("1W", "EMA 10 Timeframe", inline="ema10")
emaFastLength = input.int(10, "Periyot", inline="ema10")
ema8Color = input.color(#20b725, "Renk", inline="ema10")

// EMA 14 için parametreler
emaSlow_tf = input.timeframe("1W", "EMA 14 Timeframe", inline="ema14")
emaSlowLength = input.int(14, "Periyot", inline="ema14")
ema14Color = input.color(color.orange, "Renk", inline="ema14")

// Günlük EMA 34 için parametreler
emaDaily_tf = input.timeframe("1D", "EMA 34 Timeframe", inline="ema34")
emaDailyLength = input.int(34, "Periyot", inline="ema34")
ema34Color = input.color(#f32121, "Renk", inline="ema34")

// Günlük EMA 610 için parametreler
emaH5_tf = input.timeframe("1W", "EMA 8 Timeframe", inline="Ema8")
emaH5Length = input.int(8, "Periyot", inline="Ema8")
emaH5Color = input.color(color.rgb(10, 243, 255), "Renk", inline="Ema8")

// Günlük EMA 610 için parametreler
ema5144dak_tf = input.timeframe("5", "EMA 610 Timeframe", inline="Ema144")
ema5144dakLength = input.int(610, "Periyot", inline="Ema144")
ema5144Color = input.color(color.rgb(255, 255, 255), "Renk", inline="Ema144")

// Kijun için parametreler
kijun_tf = input.timeframe("1W", "Kijun Timeframe", inline="kijun")
kijunPeriod = input.int(21, "Periyot", inline="kijun")
kijunColor = input.color(#9b27b084, "Renk", inline="kijun", display=display.none)

ghostColor = input.color(color.green, "Ghost Çizgi Rengi", display=display.none)

// EMA hesaplamaları
ema_8 = request.security(syminfo.tickerid, emaFast_tf, ta.ema(close, emaFastLength), barmerge.gaps_off)
ema_14 = request.security(syminfo.tickerid, emaSlow_tf, ta.ema(close, emaSlowLength), barmerge.gaps_off)
ema_34 = request.security(syminfo.tickerid, emaDaily_tf, ta.ema(close, emaDailyLength), barmerge.gaps_off)
ema_5 = request.security(syminfo.tickerid, emaH5_tf, ta.ema(close, emaH5Length), barmerge.gaps_off)
ema_144 = request.security(syminfo.tickerid, ema5144dak_tf, ta.ema(close, ema5144dakLength), barmerge.gaps_off)

// Kijun hesaplaması
kijun = request.security(syminfo.tickerid, kijun_tf, math.avg(ta.lowest(low, kijunPeriod), ta.highest(high, kijunPeriod)), barmerge.gaps_off)

// EMA Ghost hesaplaması
emaGhost = ema_8 * 1.10

// Çizgilerin çizilmesi
plot(ema_8, "EMA H_10", color=ema8Color, linewidth=2)
plot(ema_14, "EMA H_14", color=ema14Color, linewidth=2)
plot(ema_34, "EMA G_34", color=ema34Color, linewidth=2)
plot(ema_5, "EMA H_8", color=emaH5Color, linewidth=2)
plot(ema_144, "EMA 5D_610", color=ema5144Color, linewidth=2)
plot(kijun, "Kijun", color=kijunColor, linewidth=2)
plot(emaGhost, "EMA Ghost", color=ghostColor, linewidth=2, style=plot.style_circles, display=display.none)


fibfilter = close > ema_8
fibfilter1 = close > ema_14 
macdflt = close > ema_34


haftaemaal = ta.crossover(close, ema_8)
haftaemasat = ta.crossover(close , fib7) and bankerentry_3d

// Haftalık Ema 8 14 Ucgen olarak cizimi

plotshape(haftaemaal, style=shape.triangleup, location=location.belowbar, color=color.rgb(27, 255, 2, 70), size=size.small)
plotshape(haftaemasat, style=shape.triangledown, location=location.abovebar, color=color.rgb(184, 37, 29, 70), size=size.small)


// Percentage changes for different timeframes
weeklyClose = request.security(syminfo.tickerid, 'D', close[5])
monthlyClose = request.security(syminfo.tickerid, 'D', close[22])
quarterlyClose = request.security(syminfo.tickerid, 'D', close[66])

weeklyChange = (close - weeklyClose) / weeklyClose * 100
monthlyChange = (close - monthlyClose) / monthlyClose * 100
quarterChange = (close - quarterlyClose) / quarterlyClose * 100

highestHight = ta.highest(high, 500)
distanceFromPeak = (highestHight - close) / close * 100

getHigherTimeframe() =>
    higherTimeFrame = timeframe.isweekly ? 'M' : timeframe.isdaily ? 'W' : timeframe.isintraday ? 'D' : 'D'
    higherTimeFrame

// 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")

// XU100 yüzdesel değişimi hesaplama
xu100_change = (xu100 - nz(xu100[1])) / nz(xu100[1]) * 100  // Yüzdesel değişim
xu100_value = xu100                                          // Gerçek XU100 değeri

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

Komp55_change = (((comp_ema55 * xu100) / close) - 1) * 100  // Yüzdesel değişim
Komp55_value = comp_ema55 * xu100                                          // Gerçek XU100 değeri


Fib880_change = ((fib7 / close) - 1) * 100  // Yüzdesel değişim
Fib880_value = fib7                                        // Gerçek XU100 değeri

Fib386_change = ((fib3 / close) - 1) * 100  // Yüzdesel değişim
Fib386_value = fib3                                        // Gerçek XU100 değeri

Fib1276_change = ((fib9 / close) - 1) * 100  // Yüzdesel değişim
Fib1276_value = fib9  

Fib214_change = ((fib1 / close) - 1) * 100  // Yüzdesel değişim stop
Fib214_value = fib1  

closep = close * 1.1
ghost_change = ((closep / close) - 1) * 100  // Yüzdesel değişim stop
ghost_value = closep 






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 == 'bottom_right' ? position.bottom_right : position.bottom_left

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, 'Macd', text_color=color.orange, text_size = fontSizeMap)
    table.cell(tbl, 1, 0, 'Ema 55', text_color = color.orange, text_size = fontSizeMap)
    table.cell(tbl, 2, 0, 'KOMP-34', text_color=color.orange, text_size = fontSizeMap)
    table.cell(tbl, 3, 0, 'KOMP-55', text_color = color.orange, text_size = fontSizeMap)
    table.cell(tbl, 4, 0, 'KOMP-233', text_color = color.orange, text_size = fontSizeMap)
    table.cell(tbl, 5, 0, 'KOM RSI', text_color = color.orange, text_size = fontSizeMap)
    table.cell(tbl, 6, 0, 'RSI', text_color = color.orange, text_size = fontSizeMap)
    table.cell(tbl, 7, 0, 'XU100', text_color = color.orange, text_size = fontSizeMap)
    
    
    
    table.cell(tbl, 0, 2, 'Ema 34', text_color = color.orange, text_size = fontSizeMap)
    table.cell(tbl, 1, 2, 'Hafta Ema-8', text_color=color.orange, text_size = fontSizeMap)
    table.cell(tbl, 2, 2, 'Hafta Ema-14', text_color=color.orange, text_size = fontSizeMap)
    table.cell(tbl, 3, 2, 'GİRİŞ', text_color=color.orange, text_size = fontSizeMap)
    table.cell(tbl, 4, 2, 'TUZAK 1', text_color=color.orange, text_size = fontSizeMap)
    table.cell(tbl, 5, 2, 'TUZAK 2', text_color = color.orange, text_size = fontSizeMap)
    table.cell(tbl, 6, 2, 'STOP', text_color = color.orange, text_size = fontSizeMap)
    table.cell(tbl, 7, 2, 'KAR AL', text_color = color.orange, text_size = fontSizeMap)

// EMA 34 değerini tabloya ekleme
table.cell(tbl, 0, 1, str.tostring(macdLine, '#.##'), text_color = macdLine >= 0 ? color.green : color.red, text_size = fontSizeMap)
table.cell(tbl, 1, 1, str.tostring(ema55, '#.##'), text_color = ema55 >= close ? color.red : color.green, text_size = fontSizeMap)
table.cell(tbl, 2, 1, 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, 3, 1, str.tostring(Komp55_value, '#.##') + "\n" + "" + str.tostring(Komp55_change, '#.##') + " %", text_color = comp_ema55 <= close/xu100 ? color.green : color.red, text_size = fontSizeMap)
table.cell(tbl, 4, 1, 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, 5, 1, str.tostring(higherRSI, '#.##'), text_color = higherRSI >= 50 ? color.green : color.red, text_size = fontSizeMap)
table.cell(tbl, 6, 1, str.tostring(rsi, '#.##'), text_color = rsi >= 50 ? color.green : color.red, text_size = fontSizeMap)
table.cell(tbl, 7, 1, str.tostring(xu100_value, '#.##') + "\n" + "" + str.tostring(xu100_change, '#.##') + " %", text_color = xu100_change > 0 ? color.green : color.red, text_size = fontSizeMap)


table.cell(tbl, 0, 3, str.tostring(ema34, '#.##'), text_color = ema34 >= close ? color.red : color.green, text_size = fontSizeMap)
table.cell(tbl, 1, 3, str.tostring(ema_8, '#.##'), text_color = ema_8 >= close ? color.red : color.green, text_size = fontSizeMap)
table.cell(tbl, 2, 3, str.tostring(ema_14, '#.##'), text_color = ema_14 >= close ? color.red : color.green, text_size = fontSizeMap)
table.cell(tbl, 3, 3, str.tostring(Fib386_value, '#.##') + "\n" + "" + str.tostring(Fib386_change, '#.##') + " %", text_color = Fib386_change > 0 ? #f23645 : color.green, text_size = fontSizeMap)
table.cell(tbl, 4, 3, str.tostring(Fib880_value, '#.##') + "\n" + "" + str.tostring(Fib880_change, '#.##') + " %", text_color = Fib880_change > 0 ? color.red : color.green, text_size = fontSizeMap)
table.cell(tbl, 5, 3, str.tostring(Fib1276_value, '#.##') + "\n" + "" + str.tostring(Fib1276_change, '#.##') + " %", text_color = Fib1276_change > 0 ? color.red : color.green, text_size = fontSizeMap)
table.cell(tbl, 6, 3, str.tostring(Fib214_value, '#.##') + "\n" + "" + str.tostring(Fib214_change, '#.##') + " %", text_color = Fib214_change > 0 ? color.red : color.green, text_size = fontSizeMap)
table.cell(tbl, 7, 3, str.tostring(ghost_value, '#.##') + "\n" + "" + str.tostring(ghost_change, '#.##') + " %", text_color = ghost_change > 0 ? color.red : color.green, text_size = fontSizeMap)


// Alarm ayarları (Enable/Disable)
enableEma5Alarm = input.bool(true, title = 'Haftalık EMA 5 Alarm', group="Trade Alarm Ayarları")
enableEma8Alarm = input.bool(true, title = 'Haftalık EMA 8 Alarm', group="Trade Alarm Ayarları")
enableEma14Alarm = input.bool(true, title = 'Hfatlık EMA 14 Alarm', group="Trade Alarm Ayarları")
enablefibogirisAlarm = input.bool(true, title = 'Fibo Giriş Alarm', group="Fibo Alarm Ayarları")
enablefibotuzak1Alarm = input.bool(true, title = 'Fibo Tuzak 1 Alarm', group="Fibo Alarm Ayarları")
enablefibotuzak2Alarm = input.bool(true, title = 'Fibo Altın Oran Alarm', group="Fibo Alarm Ayarları")
enablefibostopAlarm = input.bool(true, title = 'Fibo Stop Alarm', group="Fibo Alarm Ayarları")
enabledikyesilzigiAlarm = input.bool(true, title = 'Toplama Bölgesi Alarm', group="MAl Toplama Stama Alarm Ayarları")
enabledikkirmiicizgiAlarm = input.bool(true, title = 'Satım Bölgesi Alarm', group="MAl Toplama Stama Alarm Ayarları")
enableEma34Alarm = input.bool(true, title = 'EMA 34 Alarm', group="Temel Alarm Ayarları")
enableEma55Alarm = input.bool(true, title = 'EMA 55 Alarm', group="Temel Alarm Ayarları")
enablekomp34Alarm = input.bool(true, title = 'KOMP 34 Alarm', group="Kompozit Alarm Ayarları")
enablekomp55Alarm = input.bool(true, title = 'KOMP 55 Alarm', group="Kompozit Alarm Ayarları")
enablekomp89Alarm = input.bool(true, title = 'KOMP 89 Alarm', group="Kompozit Alarm Ayarları")
enablekomp233Alarm = input.bool(true, title = 'KOMP 233 Alarm', group="Kompozit Alarm Ayarları")
enablekomp377Alarm = input.bool(true, title = 'KOMP 377 Alarm', group="Kompozit Alarm Ayarları")

// Alarmları etkinleştirme ayarları
enableBuyAlarm = input.bool(true, title="TEKRAR AL Alarmını", group="Alarm Ayarları")
enableSellAlarm = input.bool(true, title="KAR AL Alarmını", group="Alarm Ayarları")
enableTrendAlarm = input.bool(true, title="Trend Alarmını", group="Alarm Ayarları")


// Mal SAtım Alarm Koşulları
emadikyesilcizgiCrossUp =  bankerexit // Mal Toplama Bölgei

if emadikyesilcizgiCrossUp
    if (enabledikkirmiicizgiAlarm)
        alert("Tepe Mal Satım Bölgesi!", alert.freq_once_per_bar)

// Mal Toplama Alarm Koşulları
emadikkirmizicizgiCrossUp = bankerentry // Mal Satım Bölgei

if emadikkirmizicizgiCrossUp
    if (enabledikyesilzigiAlarm)
        alert("Dip Mal Toplama Bölgesi!", alert.freq_once_per_bar)

// Fibo Giriş Alarm Koşulları
emafibostopCrossUp = ta.crossunder(open, fib1) // Fiyat 0.236'ün üzerine çıkıyor

if enablefibostopAlarm
    if (emafibostopCrossUp)
        alert("FİYAT Stop Oldu!", alert.freq_once_per_bar)



// Fibo Giriş Alarm Koşulları
emafibogirisCrossUp = ta.crossover(open, fib3) // Fiyat 0.236'ün üzerine çıkıyor

if enablefibogirisAlarm
    if (emafibogirisCrossUp)
        alert("FİYAT YUKARI KESTİ Fibo Giriş!", alert.freq_once_per_bar)

// Fibo Tuzak 1 Alarm Koşulları
emafibotuzak1CrossUp = ta.crossover(open, fib7) // Fiyat Fibo 0.880'ün üzerine çıkıyor

if enablefibotuzak1Alarm
    if (emafibotuzak1CrossUp)
        alert("FİYAT YUKARI KESTİ Fibo Tuzak 1!", alert.freq_once_per_bar)

// Fibo Tuzak 2 Alarm Koşulları
emafibotuzak2CrossUp = ta.crossover(open, fib6) // Fiyat Altın Oran ın üzerine çıkıyor
emafibotuzak2Crossdown = ta.crossunder(open, fib6) // Fiyat Altın Oran ın üzerine çıkıyor

if enablefibotuzak2Alarm
    if (emafibotuzak2CrossUp)
        alert("FİYAT YUKARI KESTİ Fibo Altın Oran!", alert.freq_once_per_bar)
    if emafibotuzak2Crossdown
        alert('FİYAT AŞAĞI KESTİ Fibo Altın Oran!', alert.freq_once_per_bar)


// EMA 5 Alarm Koşulları
ema5CrossUp = ta.crossover(open, ema_5) // Fiyat EMA 5'ün üzerine çıkıyor
ema5CrossDown = ta.crossunder(open, ema_5) // Fiyat EMA 5'ün altına iniyor

if enableEma5Alarm
    if (ema5CrossUp)
        alert("FİYAT YUKARI KESTİ HAFTA EMA 8!", alert.freq_once_per_bar)
    if ema5CrossDown
        alert('FİYAT AŞAĞI KESTİ HAFTA EMA 8!', alert.freq_once_per_bar)


// EMA 8 Alarm Koşulları
ema8CrossUp = ta.crossover(open, ema_8) // Fiyat EMA 8'ün üzerine çıkıyor
ema8CrossDown = ta.crossunder(open, ema_8) // Fiyat EMA 8'ün altına iniyor

if enableEma8Alarm
    if (ema8CrossUp)
        alert("FİYAT YUKARI KESTİ HAFTA EMA 10!", alert.freq_once_per_bar)
    if ema8CrossDown
        alert('FİYAT AŞAĞI KESTİ HAFTA EMA 10!', alert.freq_once_per_bar)


// EMA 14 Alarm Koşulları
ema14CrossUp = ta.crossover(open, ema_14) // Fiyat EMA 14'ün üzerine çıkıyor
ema14CrossDown = ta.crossunder(open, ema_14) // Fiyat EMA 14'ün altına iniyor

if enableEma14Alarm
    if (ema14CrossUp)
        alert("FİYAT YUKARI KESTİ HAFTA EMA 14!", alert.freq_once_per_bar)
    if ema14CrossDown
        alert('FİYAT AŞAĞI KESTİ HAFTA EMA 14!', alert.freq_once_per_bar)


// EMA 34 Alarm Koşulları
ema34CrossUp = ta.crossover(open, ema34) // Fiyat EMA 34'ün üzerine çıkıyor
ema34CrossDown = ta.crossunder(open, 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)

// EMA 55 Alarm Koşulları
ema55CrossUp = ta.crossover(close, ema55) // Fiyat EMA 55'in üzerine çıkıyor
ema55CrossDown = ta.crossunder(close, ema55) // Fiyat EMA 55'in altına iniyor

if enableEma55Alarm
    if (ema55CrossUp)
        alert("FİYAT YUKARI KESTİ EMA 55!", alert.freq_once_per_bar)
    if ema55CrossDown
        alert('FİYAT AŞAĞI KESTİ EMA 55!', 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)

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

if enablekomp89Alarm
    if (komp89CrossUp)
        alert("FİYAT YUKARI KESTİ KOMP 89!", alert.freq_once_per_bar)
    if komp89CrossDown
        alert('FİYAT AŞAĞI KESTİ KOMP 89!', 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)

komp55CrossUp = ta.crossover(close, comp_ema55) // Fiyat EMA 55'in üzerine çıkıyor
komp55CrossDown = ta.crossunder(close, comp_ema55) // Fiyat EMA 55'in altına iniyor

if enablekomp55Alarm
    if (komp55CrossUp)
        alert("FİYAT YUKARI KESTİ KOMP 55!", alert.freq_once_per_bar)
    if komp55CrossDown
        alert('FİYAT AŞAĞI KESTİ KOMP 55!', alert.freq_once_per_bar)

komp377CrossUp = ta.crossover(close, comp_ema377) // Fiyat EMA 55'in üzerine çıkıyor
komp377CrossDown = ta.crossunder(close, comp_ema377) // Fiyat EMA 55'in altına iniyor

if enablekomp377Alarm
    if (komp377CrossUp)
        alert("FİYAT YUKARI KESTİ KOMP 377!", alert.freq_once_per_bar)
    if komp377CrossDown
        alert('FİYAT AŞAĞI KESTİ KOMP 377!', alert.freq_once_per_bar)


// Alarm Koşulları
if enableBuyAlarm and buySignal34
    alert('TEKRAR AL sinyali oluştu!', alert.freq_once_per_bar)

if enableSellAlarm and sellSignal34
    alert('KAR AL Sat sinyali oluştu!', alert.freq_once_per_bar)

// Trend Alarmı Koşulları
if enableTrendAlarm and buySignalm
    alert('Trend Alarm: Al Sşyanli Oluştu!', alert.freq_once_per_bar)

if enableTrendAlarm and sellSignalm
    alert('Trend Alarm: Sat Sinyali Oluştu!', alert.freq_once_per_bar)

// EMA 8 altındaysa mum rengini kırmızı yap
bar_color_condition = close < ema_8
bar_color = bar_color_condition ? color.red : na

// Plot candlesticks with trend color
plotcandle(open, high, low, close,
           title = 'Title', 
           color = bar_color_condition ? color.red : trend_color, // EMA 8 altındaysa kırmızı, aksi takdirde trend renginde
           wickcolor = bar_color_condition ? color.red : trend_color, // Aynı şekilde fitil rengini de ayarlıyoruz
           bordercolor = bar_color_condition ? color.red : trend_color) // Aynı şekilde mumun kenar rengini ayarlıyoruz


// // Strategy logic: Long on green (uptrend) candles, close on red (downtrend) candles
// if trend and not na(close)
//     strategy.entry("Long", strategy.long)
// if not trend and strategy.position_size > 0
//     strategy.close("Long")
Leave a Comment