PHP Code:
//@version=6
indicator(":)", overlay=true, max_labels_count=500)
// ─────────────────────────────────────────────────────────────────
// 1. TEK KAYNAK DNA'SI VE GέRDέLER
// ─────────────────────────────────────────────────────────────────
k_start = input.float(0.0, "Kaynak Baώlangύη", step=0.01)
k_inc = input.float(0.02, "Kaynak έvme", step=0.01)
k_max = input.float(0.20, "Kaynak Max", step=0.01)
grp_vol = "έstatistiksel Hedef (Sigma)"
volLength = input.int(20, "Oynaklύk Uzunluπu", minval = 5)
projBars = input.int(5, "έleriye Projeksiyon (Yakύnlύk)", minval = 1)
barsPerYear = input.int(50, "Yύllύk Mum Ηarpanύ", minval = 50)
// ─────────────────────────────────────────────────────────────────
// 2. OTONOM BEYέN (FIBONACCI YAήLANMA VE ΗARPIήMA MOTORU)
// ─────────────────────────────────────────────────────────────────
type SARState
float sar_value
float extreme_point
float accel_factor
bool isLong
int trend_age
int bounce_count
bool was_touching
method f_updateState(SARState state, float high_val, float low_val, float close_val, float accel_start, float accel_inc, float accel_max, float decay_limit, float atr_val) =>
bool isInitialTrend = false
bool trend_changed = false
if na(state.sar_value)
if close_val > close_val[1]
state.isLong := true
state.extreme_point := high_val
state.sar_value := low_val[1]
else
state.isLong := false
state.extreme_point := low_val
state.sar_value := high_val[1]
isInitialTrend := true
state.accel_factor := accel_start
state.trend_age := 0
else
state.trend_age += 1
state.sar_value += state.accel_factor * (state.extreme_point - state.sar_value)
if state.isLong
if state.sar_value > low_val
isInitialTrend := true
trend_changed := true
state.isLong := false
state.sar_value := math.max(high_val, state.extreme_point)
state.extreme_point := low_val
state.accel_factor := accel_start
state.trend_age := 0
else
if state.sar_value < high_val
isInitialTrend := true
trend_changed := true
state.isLong := true
state.sar_value := math.min(low_val, state.extreme_point)
state.extreme_point := high_val
state.accel_factor := accel_start
state.trend_age := 0
if trend_changed
state.bounce_count := 0
state.was_touching := false
else
float tol = atr_val * 0.2
bool is_touch = state.isLong ? (low_val <= state.sar_value + tol) : (high_val >= state.sar_value - tol)
if is_touch and not state.was_touching
state.bounce_count += 1
state.was_touching := is_touch
float decay_factor = math.max(0.01, 1.0 - (state.trend_age / decay_limit))
float yasli_inc = accel_inc * decay_factor
if not isInitialTrend
if state.isLong
if high_val > state.extreme_point
state.extreme_point := high_val
state.accel_factor := math.min(state.accel_factor + yasli_inc, accel_max)
else
if low_val < state.extreme_point
state.extreme_point := low_val
state.accel_factor := math.min(state.accel_factor + yasli_inc, accel_max)
if bar_index > 1
if state.isLong
state.sar_value := math.min(state.sar_value, low_val[1])
if bar_index > 2
state.sar_value := math.min(state.sar_value, low_val[2])
else
state.sar_value := math.max(state.sar_value, high_val[1])
if bar_index > 2
state.sar_value := math.max(state.sar_value, high_val[2])
state
// ─────────────────────────────────────────────────────────────────
// 3. 9 PARALEL EVRENέN YARATILIήI VE KRAL SEΗέMέ
// ─────────────────────────────────────────────────────────────────
var float[] fibs = array.from(1.0, 2.0, 3.0, 5.0, 8.0, 13.0, 21.0, 34.0, 55.0)
var states = array.new<SARState>()
if barstate.isfirst
for i = 0 to 8
states.push(SARState.new(na, na, k_start, false, 0, 0, false))
float gercek_oynaklik = ta.atr(14)
for i = 0 to 8
SARState s = states.get(i)
s.f_updateState(high, low, close, k_start, k_inc, k_max, fibs.get(i), gercek_oynaklik)
var int king_idx = 5
int new_king = -1
for i = 0 to 8
if states.get(i).bounce_count >= 2
new_king := i
break
if new_king != -1
king_idx := new_king
float kral_sar = states.get(king_idx).sar_value
bool kral_yon = states.get(king_idx).isLong
float kral_ayna= close + (close - kral_sar)
// ─────────────────────────────────────────────────────────────────
// 4. KRALIN HAFIZASI (DέNAMέK KANALLAR)
// ─────────────────────────────────────────────────────────────────
var float channel_support = na
var float channel_resist = na
bool king_long_break = ta.crossover(close, kral_sar)
bool king_short_break = ta.crossunder(close, kral_sar)
if king_long_break
channel_support := kral_sar
if king_short_break
channel_resist := kral_sar
// ─────────────────────────────────────────────────────────────────
// 5. ANA YΦN SέNYALLERέ VE REFERANS (YΦRάK)
// ─────────────────────────────────────────────────────────────────
bool al_sinyali = kral_yon and not kral_yon[1]
bool sat_sinyali = not kral_yon and kral_yon[1]
cc = ta.sar(0.0, 0.01, 0.3)
color col_kral = kral_yon ? color.new(color.lime, 0) : color.new(color.red, 0)
color col_ayna = kral_yon ? color.new(color.lime, 50) : color.new(color.red, 50)
plot(kral_sar, title="SAR", color=col_kral, style=plot.style_circles, linewidth=3)
plot(kral_ayna, title="Ayna", color=col_ayna, style=plot.style_line, linewidth=2)
p_sup = plot(channel_support, title="Destek (Long Stop)", color=color.new(color.green, 20), style=plot.style_linebr, linewidth=2)
p_res = plot(channel_resist, title="Direnη (Short Stop)", color=color.new(color.red, 20), style=plot.style_linebr, linewidth=2)
fill(p_sup, p_res, color=color.new(color.gray, 90), title="Dinamik Trade Kanalύ")
plot(cc, title="@yφrόk@", color=color.new(color.white, 0), style=plot.style_cross, linewidth=2)
//plotshape(al_sinyali, title="Trend AL", style=shape.labelup, location=location.belowbar, color=color.lime, text="AL", textcolor=color.black, size=size.small)
//plotshape(sat_sinyali, title="Trend SAT", style=shape.labeldown, location=location.abovebar, color=color.red, text="SAT", textcolor=color.white, size=size.small)
// ─────────────────────────────────────────────────────────────────
// 6. MULTI-TIMEFRAME (MTF) GΦSTERGE PANeli (DASHBOARD)
// ─────────────────────────────────────────────────────────────────
// HATA BURADAYDI: lookahead_ignore yerine lookahead_off kullanύldύ.
[s_5m, a_5m, c_sup_5m, c_res_5m, y_5m, yon_5m] = request.security(syminfo.tickerid, "5", [kral_sar, kral_ayna, channel_support, channel_resist, cc, kral_yon], lookahead=barmerge.lookahead_off)
[s_1h, a_1h, c_sup_1h, c_res_1h, y_1h, yon_1h] = request.security(syminfo.tickerid, "60", [kral_sar, kral_ayna, channel_support, channel_resist, cc, kral_yon], lookahead=barmerge.lookahead_off)
[s_1d, a_1d, c_sup_1d, c_res_1d, y_1d, yon_1d] = request.security(syminfo.tickerid, "D", [kral_sar, kral_ayna, channel_support, channel_resist, cc, kral_yon], lookahead=barmerge.lookahead_off)
f_konum_haritasi(float sar_v, float ayna_v, float sup_v, float res_v, float yoruk_v) =>
float v_min = math.min(nz(sar_v, close), nz(ayna_v, close), nz(sup_v, close), nz(res_v, close), nz(yoruk_v, close))
float v_max = math.max(nz(sar_v, close), nz(ayna_v, close), nz(sup_v, close), nz(res_v, close), nz(yoruk_v, close))
float aralik = math.max(v_max - v_min, 0.0001)
int p_s = int(math.round(10 * (nz(sar_v, close) - v_min) / aralik))
int p_a = int(math.round(10 * (nz(ayna_v, close) - v_min) / aralik))
int p_y = int(math.round(10 * (nz(yoruk_v, close) - v_min) / aralik))
string harita = ""
for i = 0 to 10
if i == p_y
harita += "⚪"
else if i == p_s
harita += "🟣"
else if i == p_a
harita += "🔶"
else
harita += "▬"
harita
var table dash = table.new(position.top_right, 8, 4, border_width=1, border_color=color.gray, frame_color=color.gray, frame_width=1)
f_satir_doldur(int row, string tf, float s, float a, float sup, float res, float y, bool yon) =>
color c_yon = yon ? color.new(color.lime, 70) : color.new(color.red, 70)
string t_yon = yon ? "AL" : "SAT"
table.cell(dash, 0, row, tf, bgcolor=color.new(color.gray, 80), text_color=color.white, text_size=size.small)
table.cell(dash, 1, row, t_yon, bgcolor=c_yon, text_color=color.white, text_size=size.small)
table.cell(dash, 2, row, str.tostring(a, format.mintick), bgcolor=c_yon, text_color=color.white, text_size=size.small)
table.cell(dash, 3, row, str.tostring(s, format.mintick), bgcolor=c_yon, text_color=color.white, text_size=size.small)
table.cell(dash, 4, row, str.tostring(sup, format.mintick), bgcolor=color.new(color.green, 80), text_color=color.white, text_size=size.small)
table.cell(dash, 5, row, str.tostring(res, format.mintick), bgcolor=color.new(color.red, 80), text_color=color.white, text_size=size.small)
table.cell(dash, 6, row, str.tostring(y, format.mintick), bgcolor=color.new(color.gray, 80), text_color=color.white, text_size=size.small)
table.cell(dash, 7, row, f_konum_haritasi(s, a, sup, res, y), bgcolor=color.new(color.black, 60), text_color=color.white, text_size=size.small)
if barstate.islast
table.cell(dash, 0, 0, "Zaman", bgcolor=color.new(color.navy, 10), text_color=color.white, text_size=size.small)
table.cell(dash, 1, 0, "Durum", bgcolor=color.new(color.navy, 10), text_color=color.white, text_size=size.small)
table.cell(dash, 2, 0, "Ayna🔶", bgcolor=color.new(color.navy, 10), text_color=color.white, text_size=size.small)
table.cell(dash, 3, 0, "SAR🟣", bgcolor=color.new(color.navy, 10), text_color=color.white, text_size=size.small)
table.cell(dash, 4, 0, "Destek", bgcolor=color.new(color.navy, 10), text_color=color.white, text_size=size.small)
table.cell(dash, 5, 0, "Direnη", bgcolor=color.new(color.navy, 10), text_color=color.white, text_size=size.small)
table.cell(dash, 6, 0, "Yφrόk⚪", bgcolor=color.new(color.navy, 10), text_color=color.white, text_size=size.small)
table.cell(dash, 7, 0, "Konum Radarύ", bgcolor=color.new(color.navy, 10), text_color=color.white, text_size=size.small)
f_satir_doldur(1, "5Dak", s_5m, a_5m, c_sup_5m, c_res_5m, y_5m, yon_5m)
f_satir_doldur(2, "1Saat", s_1h, a_1h, c_sup_1h, c_res_1h, y_1h, yon_1h)
f_satir_doldur(3, "1Gόn", s_1d, a_1d, c_sup_1d, c_res_1d, y_1d, yon_1d)
// ─────────────────────────────────────────────────────────────────
// 7. έSTATέSTέKSEL VOLATέLέTE (%68)
// ─────────────────────────────────────────────────────────────────
logReturn = math.log(close / close[1])
rawVol = ta.stdev(logReturn, volLength)
annualVol = rawVol * math.sqrt(barsPerYear)
conePrice(float basePrice, float vol, int t, float sigmaMultiplier, int direction) =>
drift = direction * sigmaMultiplier * vol * math.sqrt(float(t) / float(barsPerYear))
basePrice * math.exp(drift)
var label[] sigmaLabels = array.new<label>()
if barstate.islast
if sigmaLabels.size() > 0
for i = 0 to sigmaLabels.size() - 1
label.delete(sigmaLabels.get(i))
sigmaLabels.clear()
float tip1up = conePrice(close, annualVol, projBars, 1.0, 1)
float tip1dn = conePrice(close, annualVol, projBars, 1.0, -1)
int tipX = bar_index + projBars
if kral_yon
sigmaLabels.push(label.new(tipX, tip1up, "(%68)\n" + str.tostring(tip1up, format.mintick), color=color.new(color.lime, 80), textcolor=color.lime, style=label.style_label_left, size=size.small))
else
sigmaLabels.push(label.new(tipX, tip1dn, "(%68)\n" + str.tostring(tip1dn, format.mintick), color=color.new(color.red, 80), textcolor=color.red, style=label.style_label_left, size=size.small))
////
// έMZA
var table ytd_table = table.new(position.bottom_center, 1, 1)
if barstate.islast
table.cell(ytd_table, 0, 0, "(Aέ, (Gemini Pro) ile tasarlanmύώ OTONOM grafik, Eπitim ηalύώmasύdύr.) Yatύrύm tavsiyesi olarak KULLANILAMAZ.", text_color=color.new(color.white, 00), text_size=size.normal)
/////////////////
// ─────────────────────────────────────────────────────────────────
// 1. GέRDέLER
// ─────────────────────────────────────────────────────────────────
h_start = input.float(0.06, "Hύzlύ SAR Baώlangύη", step=0.01, group="Hύzlύ Ayna (Kalύn)")
h_inc = input.float(0.06, "Hύzlύ SAR έvme", step=0.01, group="Hύzlύ Ayna (Kalύn)")
h_max = input.float(0.30, "Hύzlύ SAR Max", step=0.1, group="Hύzlύ Ayna (Kalύn)")
y_start = input.float(0.01, "Yavaώ SAR Baώlangύη", step=0.005, group="Yavaώ Ayna (έnce)")
y_inc = input.float(0.01, "Yavaώ SAR έvme", step=0.005, group="Yavaώ Ayna (έnce)")
y_max = input.float(0.10, "Yavaώ SAR Max", step=0.1, group="Yavaώ Ayna (έnce)")
// ─────────────────────────────────────────────────────────────────
// 2. GELέήMέή LONESOME SAR MOTORU
// ─────────────────────────────────────────────────────────────────
f_ozel_sar(src_h, src_l, _start, _inc, _max, _reset_hiz) =>
var int trend = 0
var float sar_val = 0.0
var float ep = 0.0
var float af = 0.0
if trend == 0 and not na(src_h[1])
trend := src_h >= src_h[1] or src_l >= src_l[1] ? 1 : -1
sar_val := trend > 0 ? src_l[1] : src_h[1]
ep := trend > 0 ? src_h[1] : src_l[1]
af := _start
else
if _reset_hiz
af := _start
float nextsar = sar_val
if trend > 0
if src_h[1] > ep
ep := src_h[1]
af := math.min(_max, af + _inc)
nextsar := sar_val + af * (ep - sar_val)
nextsar := math.min(math.min(src_l[1], src_l[2]), nextsar)
if nextsar > src_l
trend := -1
nextsar := ep
ep := src_l
af := _start
else
if src_l[1] < ep
ep := src_l[1]
af := math.min(_max, af + _inc)
nextsar := sar_val + af * (ep - sar_val)
nextsar := math.max(math.max(src_h[1], src_h[2]), nextsar)
if nextsar < src_h
trend := 1
nextsar := ep
ep := src_h
af := _start
sar_val := nextsar
[sar_val, trend]
// ─────────────────────────────────────────────────────────────────
// 3. ΗIPLAK AYNA HESAPLAMASI
// ─────────────────────────────────────────────────────────────────
yeni_gun = ta.change(time("D")) != 0
// Hύzlύ Ayna
[sar_hizli, trend_hizli] = f_ozel_sar(high, low, h_start, h_inc, h_max, yeni_gun)
ayna_hizli = trend_hizli > 0 ? close + math.abs(close - sar_hizli) : close - math.abs(close - sar_hizli)
// Yavaώ Ayna
[sar_yavas, trend_yavas] = f_ozel_sar(high, low, y_start, y_inc, y_max, yeni_gun)
ayna_yavas = trend_yavas > 0 ? close + math.abs(close - sar_yavas) : close - math.abs(close - sar_yavas)
// ─────────────────────────────────────────────────────────────────
// 4. RENK VE ΗέZέMLER
// ─────────────────────────────────────────────────────────────────
bool hizli_yesil = ayna_hizli > close
bool yavas_yesil = ayna_yavas > close
color col_hizli = hizli_yesil ? color.lime : color.red
color col_yavas = yavas_yesil ? color.lime : color.red
plot(ayna_hizli, title="Trend", color=col_hizli, style=plot.style_line, linewidth=1)
//plot(ayna_yavas, title="Yavaώ Ayna", color=col_yavas, style=plot.style_line, linewidth=1)
Yer έmleri