PHP Code:
//@version=6
indicator("Yrk [Kuantum apal 4xSAR]", overlay=true, max_labels_count=500)
// ─────────────────────────────────────────────────────────────────
// 1. GRDLER & HESAPLAMA APASI (ANTI-REPAINT ENTEGRASYONU)
// ─────────────────────────────────────────────────────────────────
string i_calcBar = input.string("Live Bar", "Hesaplama apas", options = ["Live Bar", "Close Bar"], group = "Kuantum Optimizasyonu", tooltip="Live Bar: Anlk tiklerde hesaplar (Standart).\nClose Bar: Sadece kapanm mumda hesaplar. Tablodaki titremeleri ve sahte sinyalleri (Repaint) %100 engeller.")
int _anchor = i_calcBar == "Live Bar" ? 0 : 1
k_start = input.float(0.01, "SAR Balang", step=0.01, group="Otonom Beyin (Fibo SAR)")
k_inc = input.float(0.01, "SAR vme", step=0.01, group="Otonom Beyin (Fibo SAR)")
k_max = input.float(0.20, "SAR Max", step=0.01, group="Otonom Beyin (Fibo SAR)")
fibo_0 = input.float(1.0, "SAR 0 Yalanma (Fibo 1)", step=1.0, group="Fibo Yalanma Snrlar")
fibo_1 = input.float(2.0, "SAR 1 Yalanma (Fibo 2)", step=1.0, group="Fibo Yalanma Snrlar")
fibo_2 = input.float(3.0, "SAR 2 Yalanma (Fibo 3)", step=1.0, group="Fibo Yalanma Snrlar")
fibo_3 = input.float(5.0, "SAR 3 Yalanma (Fibo 5)", step=1.0, group="Fibo Yalanma Snrlar")
// ─────────────────────────────────────────────────────────────────
// 2. OTONOM BEYN: APALI FIBONACCI MOTORU
// ─────────────────────────────────────────────────────────────────
// Tm high/low referanslar _anchor ile koruma altna alnd
f_sar(d_limit) =>
var int trend = 0
var float sar_val = 0.0
var float ep = 0.0
var float af = 0.0
var int trend_age = 0
float c_h = nz(high[_anchor])
float c_l = nz(low[_anchor])
float p_h = nz(high[_anchor + 1])
float p_l = nz(low[_anchor + 1])
float p2_h = nz(high[_anchor + 2])
float p2_l = nz(low[_anchor + 2])
if trend == 0 and p_h > 0
trend := c_h >= p_h or c_l >= p_l ? 1 : -1
sar_val := trend > 0 ? p_l : p_h
ep := trend > 0 ? p_h : p_l
af := k_start
trend_age := 0
else
trend_age += 1
float nextsar = sar_val
float decay_factor = math.max(0.01, 1.0 - (trend_age / d_limit))
float yasli_inc = k_inc * decay_factor
if trend > 0
if p_h > ep
ep := p_h
af := math.min(k_max, af + yasli_inc)
nextsar := sar_val + af * (ep - sar_val)
nextsar := math.min(math.min(p_l, p2_l), nextsar)
if nextsar > c_l
trend := -1
nextsar := ep
ep := c_l
af := k_start
trend_age := 0
else
if p_l < ep
ep := p_l
af := math.min(k_max, af + yasli_inc)
nextsar := sar_val + af * (ep - sar_val)
nextsar := math.max(math.max(p_h, p2_h), nextsar)
if nextsar < c_h
trend := 1
nextsar := ep
ep := c_h
af := k_start
trend_age := 0
sar_val := nextsar
[sar_val, trend]
f_mtf_paket() =>
[s0, t0] = f_sar(fibo_0)
[s1, t1] = f_sar(fibo_1)
[s2, t2] = f_sar(fibo_2)
[s3, t3] = f_sar(fibo_3)
[t3, s0, s1, s2, s3]
// ─────────────────────────────────────────────────────────────────
// 3. OKLU ZAMAN DLM (MTF) VER EKM
// ─────────────────────────────────────────────────────────────────
[cur_trend, cur_s0, cur_s1, cur_s2, cur_s3] = f_mtf_paket()
[t_1h, s0_1h, s1_1h, s2_1h, s3_1h] = request.security(syminfo.tickerid, "60", f_mtf_paket(), lookahead=barmerge.lookahead_on)
[t_4h, s0_4h, s1_4h, s2_4h, s3_4h] = request.security(syminfo.tickerid, "240", f_mtf_paket(), lookahead=barmerge.lookahead_on)
[t_1d, s0_1d, s1_1d, s2_1d, s3_1d] = request.security(syminfo.tickerid, "D", f_mtf_paket(), lookahead=barmerge.lookahead_on)
// ─────────────────────────────────────────────────────────────────
// 4. GRSELLETRME VE MUM RENKLER (MEVCUT GRAFK)
// ─────────────────────────────────────────────────────────────────
color col_ana = cur_trend > 0 ? color.lime : color.red
barcolor(col_ana)
plot(cur_s0, "SAR 0", color=color.new(color.fuchsia, 20), style=plot.style_circles, linewidth=1)
plot(cur_s1, "SAR 1", color=color.new(color.blue, 20), style=plot.style_circles, linewidth=1)
plot(cur_s2, "SAR 2", color=color.new(color.orange, 20), style=plot.style_circles, linewidth=1)
plot(cur_s3, "SAR 3", color=col_ana, style=plot.style_circles, linewidth=2)
// ─────────────────────────────────────────────────────────────────
// 5. KOMUTA MERKEZ: GRSEL FRENLEME (GARBAGE COLLECTION)
// ─────────────────────────────────────────────────────────────────
var table mtf_table = table.new(position.top_right, 6, 5, border_width=1, border_color=color.new(color.gray, 80), frame_color=color.new(color.gray, 80), frame_width=1)
if barstate.islast
// Canl Fiyat stisnas: _anchor = 1 olsa bile buras daima 'close' okur.
table.cell(mtf_table, 0, 0, "FYAT: " + str.tostring(close, format.mintick), text_color=color.yellow, text_size=size.normal, bgcolor=color.new(color.black, 40), text_halign=text.align_center)
table.merge_cells(mtf_table, 0, 0, 5, 0)
table.cell(mtf_table, 0, 1, "ZAMAN", text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 70))
table.cell(mtf_table, 1, 1, "SNYAL", text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 70))
table.cell(mtf_table, 2, 1, "SAR 0", text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 70))
table.cell(mtf_table, 3, 1, "SAR 1", text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 70))
table.cell(mtf_table, 4, 1, "SAR 2", text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 70))
table.cell(mtf_table, 5, 1, "SAR 3", text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 70))
string txt_1h = t_1h > 0 ? "AL" : "SAT"
color col_1h = t_1h > 0 ? color.lime : color.red
table.cell(mtf_table, 0, 2, "1 Saat", text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 90))
table.cell(mtf_table, 1, 2, txt_1h, text_color=col_1h, text_size=size.small, bgcolor=color.new(col_1h, 85))
table.cell(mtf_table, 2, 2, str.tostring(s0_1h, format.mintick), text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 90))
table.cell(mtf_table, 3, 2, str.tostring(s1_1h, format.mintick), text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 90))
table.cell(mtf_table, 4, 2, str.tostring(s2_1h, format.mintick), text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 90))
table.cell(mtf_table, 5, 2, str.tostring(s3_1h, format.mintick), text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 90))
string txt_4h = t_4h > 0 ? "AL" : "SAT"
color col_4h = t_4h > 0 ? color.lime : color.red
table.cell(mtf_table, 0, 3, "4 Saat", text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 90))
table.cell(mtf_table, 1, 3, txt_4h, text_color=col_4h, text_size=size.small, bgcolor=color.new(col_4h, 85))
table.cell(mtf_table, 2, 3, str.tostring(s0_4h, format.mintick), text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 90))
table.cell(mtf_table, 3, 3, str.tostring(s1_4h, format.mintick), text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 90))
table.cell(mtf_table, 4, 3, str.tostring(s2_4h, format.mintick), text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 90))
table.cell(mtf_table, 5, 3, str.tostring(s3_4h, format.mintick), text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 90))
string txt_1d = t_1d > 0 ? "AL" : "SAT"
color col_1d = t_1d > 0 ? color.lime : color.red
table.cell(mtf_table, 0, 4, "1 Gn", text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 90))
table.cell(mtf_table, 1, 4, txt_1d, text_color=col_1d, text_size=size.small, bgcolor=color.new(col_1d, 85))
table.cell(mtf_table, 2, 4, str.tostring(s0_1d, format.mintick), text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 90))
table.cell(mtf_table, 3, 4, str.tostring(s1_1d, format.mintick), text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 90))
table.cell(mtf_table, 4, 4, str.tostring(s2_1d, format.mintick), text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 90))
table.cell(mtf_table, 5, 4, str.tostring(s3_1d, format.mintick), text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 90))
Yer mleri