PHP Code:
// © Kinetik Komuta Merkezi [Masterpiece V6.9 Terminal + Z-Vortex + Z-Div]
//@version=6
indicator("yφrόk", shorttitle=".", overlay=true, max_labels_count=50, max_lines_count=50)
// ─────────────────────────────────────────────────────────────────
// 7. SAR HESAPLAMALARI VE ΗέZέMLER
// ─────────────────────────────────────────────────────────────────
float roSarSlow = ta.sar(0.01, 0.01, 0.2)
float roSarModerate = ta.sar(0.01, 0.02, 0.2)
float roSarFast = ta.sar(0.01, 0.03, 0.2)
plot(roSarSlow, title="C", style=plot.style_cross, color=color.yellow, linewidth=1)
plot(roSarModerate, title="B", style=plot.style_cross, color=color.yellow, linewidth=1)
plot(roSarFast, title="A", style=plot.style_cross, color=color.yellow, linewidth=1)
float sarMavi = ta.sar(0.0, 0.003, 0.02), sarSari = ta.sar(0.0, 0.001, 0.02), sarFusya = ta.sar(0.001, 0.0005, 0.02)
plot(sarMavi, "X", color.new(#040cfb, 0), 1, plot.style_cross)
plot(sarSari, "Y", color.new(#040cfb, 0), 1, plot.style_cross)
plot(sarFusya, "Z", color.new(#040cfb, 0), 1, plot.style_cross)
// 1. GέRDέLER
// ─────────────────────────────────────────────────────────────────
group_l1 = "1. Kinetik Motor (Yφrόk)"
int atrLen = input.int(20, "L1 Hafύza (ATR)", group=group_l1)
float atrMult = input.float(3.5, "L1 Gόrόltό Duvarύ", step=0.1, group=group_l1)
float mu = input.float(0.6, "L1 Yakύnsaklύk (μ)", step=0.1, group=group_l1)
group_holy = "3. Kurumsal S-TWAP Filtresi"
float maxTension = input.float(2.0, "Maksimum Gerginlik Sύnύrύ", step=0.1, group=group_holy)
// ─────────────────────────────────────────────────────────────────
// 2. ARKA PLAN HESAPLAMALARI (SAF YΦRάK VE TWAP)
// ─────────────────────────────────────────────────────────────────
f_yoruk_pure() =>
float threshold = ta.atr(atrLen) * atrMult
var float z = na
var float v = 0.0
if bar_index == 0
z := hl2
else
float zPrev = z[1], float vPrev = v[1]
float zPred = zPrev + vPrev
float zTemp = zPred + mu * (hl2 - zPred)
float diff = zTemp - zPrev
if math.abs(diff) > threshold
v := math.sign(diff) * (math.abs(diff) - threshold)
else
v := 0.0
z := zPrev + v
z
bool isNew15m = ta.change(time("15")) != 0
var float sumPrice15m = 0.0, var float barCount15m = 0.0
if isNew15m or bar_index == 0
sumPrice15m := hl2, barCount15m := 1.0
else
sumPrice15m += hl2, barCount15m += 1.0
float curTwap15m = sumPrice15m / barCount15m
bool isNewHour = ta.change(time("60")) != 0
var float sumPriceH = 0.0, var float barCountH = 0.0
if isNewHour or bar_index == 0
sumPriceH := hl2, barCountH := 1.0
else
sumPriceH += hl2, barCountH += 1.0
float curTwapH = sumPriceH / barCountH
bool isNewDay = ta.change(time("D")) != 0
var float sumPriceD = 0.0, var float barCountD = 0.0
if isNewDay or bar_index == 0
sumPriceD := hl2, barCountD := 1.0
else
sumPriceD += hl2, barCountD += 1.0
float curTwapD = sumPriceD / barCountD
// ─────────────────────────────────────────────────────────────────
// GέRDέLER VE RENKLER
// ─────────────────────────────────────────────────────────────────
int len = input.int(89, "Maliyet Uzunluπu")
color col_up = input.color(#00e676, "Yόkseliώ Rengi (Yeώil)")
color col_dn = input.color(#ff1744, "Dόώόώ Rengi (Kύrmύzύ)")
color col_mid = input.color(color.fuchsia, "Merkez Ηizgi Rengi")
// ─────────────────────────────────────────────────────────────────
// HESAPLAMA (Sύfύr Gecikmeli Pόrόzsόz Merkez)
// ─────────────────────────────────────────────────────────────────
float mid = ta.hma(ta.median(hl2, len * 2), 233)
// ─────────────────────────────────────────────────────────────────
// ΗέZέM VE BOYA
// ─────────────────────────────────────────────────────────────────
// Tek beyaz merkez hattύ
plot(mid, title = "Maliyet", color = col_mid, linewidth = 1)
// Sadece Kύrmύzύ ve Yeώil mantύπύ
color bar_col = close > mid ? col_up : close < mid ? col_dn : color.gray
// Mumlarύ ve sύnύrlarύ boya
//plotcandle(open, high, low, close, title='Renk Mumlarύ', color = bar_col, wickcolor=bar_col, bordercolor = bar_col)
barcolor(bar_col)
// 4. ήELALE ΗέZέMLERέ (Yφrόk MTF)
// ─────────────────────────────────────────────────────────────────
float y1 = f_yoruk_pure()
float y3 = request.security(syminfo.tickerid, "3", f_yoruk_pure(), lookahead=barmerge.lookahead_off)
float y5 = request.security(syminfo.tickerid, "5", f_yoruk_pure(), lookahead=barmerge.lookahead_off)
float y15 = request.security(syminfo.tickerid, "15", f_yoruk_pure(), lookahead=barmerge.lookahead_off)
float y60 = request.security(syminfo.tickerid, "60", f_yoruk_pure(), lookahead=barmerge.lookahead_off)
float y240 = request.security(syminfo.tickerid, "240", f_yoruk_pure(), lookahead=barmerge.lookahead_off)
float yD = request.security(syminfo.tickerid, "D", f_yoruk_pure(), lookahead=barmerge.lookahead_off)
plot(y1, "1m Yφrόk", color=color.new(#03d3f8, 0), linewidth=1, style=plot.style_stepline)
// ─────────────────────────────────────────────────────────────────
// 5. MέKRO ATEήLEME & MANYETέK HEDEFLEME MANTIΠI
// ─────────────────────────────────────────────────────────────────
float safeAtr = math.max(ta.atr(14), syminfo.mintick)
bool isIgnition = (high - low) >= (safeAtr * 1.5)
float atrH = request.security(syminfo.tickerid, "60", ta.atr(14), lookahead=barmerge.lookahead_off)
float twapDistAtr = atrH > 0 ? math.abs(close - curTwapH) / atrH : 0
bool tensionOk = twapDistAtr <= maxTension
bool breakBull = close > y1 and close > y3 and (open < y1 or open < y3 or close[1] < y1)
bool breakBear = close < y1 and close < y3 and (open > y1 or open > y3 or close[1] > y1)
bool fireBull = breakBull and isIgnition and close > curTwapH and close > open and tensionOk
bool fireBear = breakBear and isIgnition and close < curTwapH and close < open and tensionOk
//bgcolor(fireBull ? color.new(#00e676, 85) : fireBear ? color.new(#ff1744, 85) : na, title="Ateώleme Zemin Flaώύ")
var int activeSide = 0
var float entryPrice = na
var bool hasMagnet = false
var line lineEntry = na, var label lblEntry = na
if (fireBull and activeSide != 1)
activeSide := 1, entryPrice := close, hasMagnet := y60 > close
if not na(lineEntry)
line.delete(lineEntry), label.delete(lblEntry)
lineEntry := line.new(bar_index, entryPrice, bar_index + 5, entryPrice, color=color.new(#00e676, 0), width=2)
lblEntry := label.new(bar_index + 5, entryPrice, "GέRέή: " + str.tostring(math.round(entryPrice, 2)), color=color.new(#00e676, 80), textcolor=color.white, style=label.style_label_left, size=size.small)
else if (fireBear and activeSide != -1)
activeSide := -1, entryPrice := close, hasMagnet := y60 < close
if not na(lineEntry)
line.delete(lineEntry), label.delete(lblEntry)
lineEntry := line.new(bar_index, entryPrice, bar_index + 5, entryPrice, color=color.new(#ff1744, 0), width=2)
lblEntry := label.new(bar_index + 5, entryPrice, "GέRέή: " + str.tostring(math.round(entryPrice, 2)), color=color.new(#ff1744, 80), textcolor=color.white, style=label.style_label_left, size=size.small)
if activeSide != 0
line.set_x2(lineEntry, bar_index + 5), label.set_x(lblEntry, bar_index + 5)
bool magnetHitBull = activeSide == 1 and hasMagnet and high >= y60
bool magnetHitBear = activeSide == -1 and hasMagnet and low <= y60
bool microStopBull = activeSide == 1 and close < y1
bool microStopBear = activeSide == -1 and close > y1
if magnetHitBull or magnetHitBear
activeSide := 0
line.set_color(lineEntry, color.new(color.gray, 60)), label.set_color(lblEntry, color.new(color.gray, 60))
else if microStopBull or microStopBear
activeSide := 0
line.set_color(lineEntry, color.new(color.gray, 60)), label.set_color(lblEntry, color.new(color.gray, 60))
// ─────────────────────────────────────────────────────────────────
// 6. TERMINAL PUSULASI (TAM KONTROL HUD)
// ─────────────────────────────────────────────────────────────────
var table terminal = table.new(position.bottom_right, 2, 11, bgcolor=color.new(color.black, 60), border_color=color.new(color.gray, 80), border_width=1)
f_col(val) => close > val ? #00e676 : close < val ? #ff1744 : color.silver
if barstate.islast
table.cell(terminal, 0, 0, "KKM MICRO SNIPER PRO", text_color=color.gray, text_size=size.small, bgcolor=color.new(color.black, 40))
table.merge_cells(terminal, 0, 0, 1, 0)
string entryState = activeSide == 1 ? " (AKTέF/AL)" : activeSide == -1 ? " (AKTέF/SAT)" : " (KAPALI)"
string entryStr = not na(entryPrice) ? str.tostring(math.round(entryPrice, 2)) + entryState : "BEKLENέYOR"
color entryCol = activeSide == 1 ? #00e676 : activeSide == -1 ? #ff1744 : color.silver
table.cell(terminal, 0, 1, "SON GέRέή", text_color=color.white, text_size=size.small)
table.cell(terminal, 1, 1, entryStr, text_color=entryCol, text_size=size.small)
float stopAvg = (y1 + y3) / 2
table.cell(terminal, 0, 2, "STOP (1m+3m)", text_color=color.white, text_size=size.small)
table.cell(terminal, 1, 2, str.tostring(math.round(stopAvg, 2)), text_color=color.orange, text_size=size.small)
table.cell(terminal, 0, 3, "1m Yφrόk", text_color=color.white, text_size=size.small)
table.cell(terminal, 1, 3, str.tostring(math.round(y1, 2)), text_color=f_col(y1), text_size=size.small)
table.cell(terminal, 0, 4, "3m Yφrόk", text_color=color.white, text_size=size.small)
table.cell(terminal, 1, 4, str.tostring(math.round(y3, 2)), text_color=f_col(y3), text_size=size.small)
table.cell(terminal, 0, 5, "5m Yφrόk", text_color=color.white, text_size=size.small)
table.cell(terminal, 1, 5, str.tostring(math.round(y5, 2)), text_color=f_col(y5), text_size=size.small)
table.cell(terminal, 0, 6, "15m Yφrόk", text_color=color.white, text_size=size.small)
table.cell(terminal, 1, 6, str.tostring(math.round(y15, 2)), text_color=f_col(y15), text_size=size.small)
table.cell(terminal, 0, 7, "60m Yφrόk", text_color=color.white, text_size=size.small)
table.cell(terminal, 1, 7, str.tostring(math.round(y60, 2)), text_color=f_col(y60), text_size=size.small)
table.cell(terminal, 0, 8, "4S Yφrόk", text_color=color.white, text_size=size.small)
table.cell(terminal, 1, 8, str.tostring(math.round(y240, 2)), text_color=f_col(y240), text_size=size.small)
table.cell(terminal, 0, 9, "1G Yφrόk", text_color=color.white, text_size=size.small)
table.cell(terminal, 1, 9, str.tostring(math.round(yD, 2)), text_color=f_col(yD), text_size=size.small)
table.cell(terminal, 0, 10, "YTD", text_color=color.gray, text_size=size.tiny)
table.merge_cells(terminal, 0, 10, 1, 10)
//////////////
// ─────────────────────────────────────────────────────────────────
// 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)
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, 70), title="Dinamik Trade Kanalύ")
// ─────────────────────────────────────────────────────────────────
// 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, "(YTD)\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, "(YTD)\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)
/////////////////
// 3. MOTOR: 3'Lά SAR ΗAKIήMASI (YAKIN TAKέP ELMAS TETέK)
// ─────────────────────────────────────────────────────────────────
// Fiyatύ ensesinden takip eden 3 hiper-aktif SAR (Step ve Max deπerleri yόkseltildi)
roSar1 = ta.sar(0.03, 0.003, 0.3) // Hύzlύ Avcύ
roSar2 = ta.sar(0.05, 0.005, 0.5) // Yakύn Gφlge
roSar3 = ta.sar(0.10, 0.010, 1.0) // Vakum (Fiyata yapύώύk)
// Kuantum Tolerans Motoru
isEq(v1, v2) => math.abs(v1 - v2) <= syminfo.mintick
isEq3(v1, v2, v3) => isEq(v1, v2) and isEq(v1, v3)
// Sadece bu 3 SAR'ύn aynύ anda όst όste binme (ηakύώma) durumu
all3Match = isEq3(roSar1, roSar2, roSar3)
float matchVal = all3Match ? roSar1 : na
trigger = all3Match and not all3Match[1]
isSupport = close > matchVal
diamondColor = isSupport ? color.rgb(0, 230, 118, 20) : color.rgb(255, 23, 68, 20)
plotshape(trigger ? matchVal : na, "3'lό SAR Elmasύ", shape.diamond, location.absolute, color=diamondColor, size=size.small, display=display.pane)
///////////////
// ─────────────────────────────────────────────────────────────────
// 1. ASYMMETRIC TREND ENGINE (GΦRάNMEZ HESAPLAYICI)
// ─────────────────────────────────────────────────────────────────
// Komutan Talimatύ: hl2 Kaynak, 30 Lookback, 3.5 Mult
float asy_src = hl2
int asy_lookback = 180
float asy_mult = 3.5
float asy_vol_threshold = ta.stdev(asy_src, asy_lookback) * asy_mult
var float asy_trend_line = na
var int asy_trend_dir = 0
var int asy_prev_dir = 0
if na(asy_trend_line)
asy_trend_line := asy_src
else
asy_prev_dir := asy_trend_dir
if asy_trend_dir >= 0
if asy_src > asy_trend_line + asy_vol_threshold * 0.5
asy_trend_line := math.max(asy_trend_line, asy_src - asy_vol_threshold * 0.25)
asy_trend_dir := 1
else if asy_src < asy_trend_line - asy_vol_threshold
asy_trend_line := asy_src + asy_vol_threshold * 0.25
asy_trend_dir := -1
else
if asy_src < asy_trend_line - asy_vol_threshold * 0.5
asy_trend_line := math.min(asy_trend_line, asy_src + asy_vol_threshold * 0.25)
asy_trend_dir := -1
else if asy_src > asy_trend_line + asy_vol_threshold
asy_trend_line := asy_src - asy_vol_threshold * 0.25
asy_trend_dir := 1
// Dφnόώ Teyitleri
bool turned_bullish = asy_trend_dir == 1 and asy_trend_dir[1] == -1
bool turned_bearish = asy_trend_dir == -1 and asy_trend_dir[1] == 1
bool is_reversal = asy_trend_dir != asy_prev_dir and bar_index > 0
// ─────────────────────────────────────────────────────────────────
// ─────────────────────────────────────────────────────────────────
// 3. SAF QUANT GΦRSELLEήTέRME (SADECE DΦNάήLER)
// ─────────────────────────────────────────────────────────────────
// Trend ηizgisi plot edilmiyor, sadece dφnόώ anύnda hedef belirleniyor
color rev_color = asy_trend_dir == 1 ? #00ffaa48 : #ff00003c
// Reversal Noktasύ: Sadece trend yφn deπiώtirdiπinde o barύn altύna/όstόne '⦿' koyar
plotchar(is_reversal ? (asy_trend_dir == 1 ? low : high) : na,
"KKM Reversal", "⦿", location = location.absolute,
color = rev_color, size = size.huge)
// //////
// 0. MERKEZέ FONKSέYONLAR (Sύfύr Gecikme Motoru)
// ─────────────────────────────────────────────────────────────────
f_zlema(series float src, simple int len) =>
float ema1 = ta.ema(src, len)
float ema2 = ta.ema(ema1, len)
ema1 + (ema1 - ema2)
// ─────────────────────────────────────────────────────────────────
// ─────────────────────────────────────────────────────────────────
// 1. DέNAMέK YOΠUNLUK MOTORU (Zamanύ Deπil, Maddeyi Φlηer)
// ─────────────────────────────────────────────────────────────────
// Bu motor aynύ 1m verisini alύr ama ona farklύ kutle direnηleri uygular.
f_kutu_kutle(int _atrLen, float _atrMult, float _mu) =>
float threshold = ta.atr(_atrLen) * _atrMult
var float z = na
var float v = 0.0
if bar_index == 0
z := hl2
else
float zPrev = z[1], float vPrev = v[1]
float zPred = zPrev + vPrev
float zTemp = zPred + _mu * (hl2 - zPred)
float diff = zTemp - zPrev
if math.abs(diff) > threshold
v := math.sign(diff) * (math.abs(diff) - threshold)
else
v := 0.0
z := zPrev + v
z
// ─────────────────────────────────────────────────────────────────
// 2. KάTLE MATRέSέ (Camdan Ηeliπe Kurumsal Maliyetler)
// ─────────────────────────────────────────────────────────────────
// Aynύ 1 dakikalύk grafikte, merminin (fiyatύn) deleceπi katmanlar:
float cam = f_kutu_kutle(1, 1.0, 0.05) // CAM: Ηok kύrύlgan, mermi anύnda deler.
float celik = f_kutu_kutle(1, 0.01, 0.01) // ΗELέK: Komutanύn Tank Zύrhύ! (Delinmesi en zor)
// ─────────────────────────────────────────────────────────────────
// 3. YOΠUNLUK ΗέZέMLERέ (Ekranύ Kirletmeden)
// ─────────────────────────────────────────────────────────────────
plot(celik, "Ηelik", color=color.new(#d500f9, 0), linewidth=1, style=plot.style_stepline) // Mor
plot(cam, "Cam", color=color.new(#ffeb3b, 0), linewidth=1, style=plot.style_stepline) // Beyaz
// ─────────────────────────────────────────────────────────────────
group_motor = "Kinetik Zeminler (Trinity)"
int len_fast = input.int(5, "Hύzlύ Zemin (Zemin 1)", group=group_motor)
int len_slow = input.int(20, "Yavaώ Zemin (Zemin 2)", group=group_motor)
group_dash = "Gφsterge Paneli"
bool show_dash = input.bool(true, "Paneli Gφster", group=group_dash)
string dash_pos = input.string("Top Right", "Panel Konumu", options=["Top Right", "Top Left", "Bottom Right", "Bottom Left"], group=group_dash)
group_kin = "Renk Paleti"
col_flat = input.color(#787b86, "Flat (Nφtr)", group=group_kin)
col_eq = input.color(#ff9800, "Merkez Pivot (Turuncu Denge)", group=group_kin)
// ─────────────────────────────────────────────────────────────────
// 1. MOTOR: L1 KέNETέK FέLTRE (ANA BASELINE)
// ─────────────────────────────────────────────────────────────────
float threshold = ta.atr(atrLen) * atrMult
var float z = na
var float v = 0.0
if bar_index == 0
z := close
else
float zPrev = z[1], float vPrev = v[1]
float zPred = zPrev + vPrev
float zTemp = zPred + mu * (close - zPred)
float diff = zTemp - zPrev
if math.abs(diff) > threshold
v := math.sign(diff) * (math.abs(diff) - threshold)
else
v := 0.0
z := zPrev + v
//plot(z, "0", color=color.new(color.fuchsia, 0), linewidth=1, style=plot.style_stepline)
// ─────────────────────────────────────────────────────────────────
// 2. MOTOR: TRINITY ZEMέNLER (5 - 20)
// ─────────────────────────────────────────────────────────────────
float fast_floor = ta.hma(z, len_fast)
float slow_floor = ta.hma(z, len_slow)
//p_fast = plot(fast_floor, color=color.rgb(223, 64, 251, 100), linewidth=1, title="1")
//p_slow = plot(slow_floor, color=color.new(color.fuchsia, 100), linewidth=1, title="2")
// Kinetik Bulut
bool is_bull = fast_floor > slow_floor
//fill(p_fast, p_slow, is_bull ? color.new(col_up, 85) : color.new(col_dn, 85), title="Kinetik Bulut")
// ─────────────────────────────────────────────────────────────────
// 3. ANALέZ: άΗLά KAVUήUM (YάZEN PέVOT AΠI) VE SέNYAL TAKέBέ
// ─────────────────────────────────────────────────────────────────
isEq55(v1, v2) => math.abs(v1 - v2) <= syminfo.mintick
bool trinity_aligned = isEq55(z, fast_floor) and isEq55(z, slow_floor)
var float last_eq_val = na
var float last_eq_step = na
// Ηizgi ve Etiket Deπiώkenleri
var line line_p = na, var label lbl_p = na
var line line_r1 = na, var label lbl_r1 = na
var line line_r2 = na, var label lbl_r2 = na
var line line_r3 = na, var label lbl_r3 = na
var line line_s1 = na, var label lbl_s1 = na
var line line_s2 = na, var label lbl_s2 = na
var line line_s3 = na, var label lbl_s3 = na
if trinity_aligned
last_eq_val := z
last_eq_step := threshold // L1'in kendi gόrόltό duvarύ mesafesi
// Kavuώum (Denge) deπeri varsa, yόzen aπύ her an gόncelle
if not na(last_eq_val)
int ext = 10 // Ηizgilerin uzayacaπύ bar sayύsύ
float val_p = last_eq_val
float val_r1 = last_eq_val + last_eq_step * 1
float val_r2 = last_eq_val + last_eq_step * 2
float val_r3 = last_eq_val + last_eq_step * 3
float val_s1 = last_eq_val - last_eq_step * 1
float val_s2 = last_eq_val - last_eq_step * 2
float val_s3 = last_eq_val - last_eq_step * 3
if na(line_p)
// Ηizgiler
line_p := line.new(bar_index, val_p, bar_index + ext, val_p, color=col_eq, width=2, style=line.style_dotted)
line_r1 := line.new(bar_index, val_r1, bar_index + ext, val_r1, color=color.new(col_dn, 30), width=1, style=line.style_dotted)
line_r2 := line.new(bar_index, val_r2, bar_index + ext, val_r2, color=color.new(col_dn, 30), width=1, style=line.style_dotted)
line_r3 := line.new(bar_index, val_r3, bar_index + ext, val_r3, color=color.new(col_dn, 30), width=1, style=line.style_dotted)
line_s1 := line.new(bar_index, val_s1, bar_index + ext, val_s1, color=color.new(col_up, 30), width=1, style=line.style_dotted)
line_s2 := line.new(bar_index, val_s2, bar_index + ext, val_s2, color=color.new(col_up, 30), width=1, style=line.style_dotted)
line_s3 := line.new(bar_index, val_s3, bar_index + ext, val_s3, color=color.new(col_up, 30), width=1, style=line.style_dotted)
// Etiketler
lbl_p := label.new(bar_index + ext, val_p, "P: " + str.tostring(val_p, format.mintick), color=color.new(color.white, 100), textcolor=col_eq, style=label.style_label_left, size=size.normal)
lbl_r1 := label.new(bar_index + ext, val_r1, "R1: " + str.tostring(val_r1, format.mintick), color=color.new(color.white, 100), textcolor=col_dn, style=label.style_label_left, size=size.normal)
lbl_r2 := label.new(bar_index + ext, val_r2, "R2: " + str.tostring(val_r2, format.mintick), color=color.new(color.white, 100), textcolor=col_dn, style=label.style_label_left, size=size.normal)
lbl_r3 := label.new(bar_index + ext, val_r3, "R3: " + str.tostring(val_r3, format.mintick), color=color.new(color.white, 100), textcolor=col_dn, style=label.style_label_left, size=size.normal)
lbl_s1 := label.new(bar_index + ext, val_s1, "S1: " + str.tostring(val_s1, format.mintick), color=color.new(color.white, 100), textcolor=col_up, style=label.style_label_left, size=size.normal)
lbl_s2 := label.new(bar_index + ext, val_s2, "S2: " + str.tostring(val_s2, format.mintick), color=color.new(color.white, 100), textcolor=col_up, style=label.style_label_left, size=size.normal)
lbl_s3 := label.new(bar_index + ext, val_s3, "S3: " + str.tostring(val_s3, format.mintick), color=color.new(color.white, 100), textcolor=col_up, style=label.style_label_left, size=size.normal)
else
// Aπύ ve etiketleri her bar saπa kaydύr
line.set_xy1(line_p, bar_index, val_p), line.set_xy2(line_p, bar_index + ext, val_p)
line.set_xy1(line_r1, bar_index, val_r1), line.set_xy2(line_r1, bar_index + ext, val_r1)
line.set_xy1(line_r2, bar_index, val_r2), line.set_xy2(line_r2, bar_index + ext, val_r2)
line.set_xy1(line_r3, bar_index, val_r3), line.set_xy2(line_r3, bar_index + ext, val_r3)
line.set_xy1(line_s1, bar_index, val_s1), line.set_xy2(line_s1, bar_index + ext, val_s1)
line.set_xy1(line_s2, bar_index, val_s2), line.set_xy2(line_s2, bar_index + ext, val_s2)
line.set_xy1(line_s3, bar_index, val_s3), line.set_xy2(line_s3, bar_index + ext, val_s3)
label.set_xy(lbl_p, bar_index + ext, val_p), label.set_text(lbl_p, "P: " + str.tostring(val_p, format.mintick))
label.set_xy(lbl_r1, bar_index + ext, val_r1), label.set_text(lbl_r1, "R1: " + str.tostring(val_r1, format.mintick))
label.set_xy(lbl_r2, bar_index + ext, val_r2), label.set_text(lbl_r2, "R2: " + str.tostring(val_r2, format.mintick))
label.set_xy(lbl_r3, bar_index + ext, val_r3), label.set_text(lbl_r3, "R3: " + str.tostring(val_r3, format.mintick))
label.set_xy(lbl_s1, bar_index + ext, val_s1), label.set_text(lbl_s1, "S1: " + str.tostring(val_s1, format.mintick))
label.set_xy(lbl_s2, bar_index + ext, val_s2), label.set_text(lbl_s2, "S2: " + str.tostring(val_s2, format.mintick))
label.set_xy(lbl_s3, bar_index + ext, val_s3), label.set_text(lbl_s3, "S3: " + str.tostring(val_s3, format.mintick))
// Sinyal Takibi (L1 Yφn Deπiώimi)
var int trendL1 = 0
if z > z[1]
trendL1 := 1
else if z < z[1]
trendL1 := -1
var string last_sig_type = "-"
var float last_sig_price = na
if ta.change(trendL1) != 0
last_sig_type := trendL1 == 1 ? "AL" : "SAT"
last_sig_price := close
// ─────────────────────────────────────────────────────────────────
// 4. GΦRSEL TERMέNAL (DASHBOARD)
// ─────────────────────────────────────────────────────────────────
var pos = dash_pos == "Top Right" ? position.bottom_left : dash_pos == "Top Left" ? position.top_left : dash_pos == "Bottom Right" ? position.bottom_right : position.bottom_left
var table dash55 = table.new(pos, 2, 7, bgcolor=color.new(#131722, 10), border_width=1, border_color=color.new(#363a45, 50), frame_color=color.new(#363a45, 50), frame_width=1)
if show_dash and barstate.islast
// Baώlύk
table.cell(dash55, 0, 0, "@yφrόk@ 2026 Gemini Pro Eπitim Ηalύώmasύdύr.", bgcolor=color.new(#2962ff, 50), text_color=color.white, text_size=size.normal, text_halign=text.align_center)
table.merge_cells(dash55, 0, 0, 1, 0)
// Deπerler
table.cell(dash55, 0, 1, "Fiyat", text_color=color.gray, text_size=size.normal)
table.cell(dash55, 1, 1, str.tostring(close, format.mintick), text_color=color.white, text_size=size.normal)
table.cell(dash55, 0, 2, "0", text_color=color.gray, text_size=size.normal)
table.cell(dash55, 1, 2, str.tostring(z, format.mintick), text_color=color.silver, text_size=size.normal)
table.cell(dash55, 0, 3, "(1) | (2)", text_color=color.gray, text_size=size.normal)
table.cell(dash55, 1, 3, str.tostring(fast_floor, format.mintick) + " | " + str.tostring(slow_floor, format.mintick), text_color=color.aqua, text_size=size.normal)
// άηlό Kavuώum (Denge Noktasύ)
table.cell(dash55, 0, 4, "(Denge)", text_color=color.gray, text_size=size.normal)
table.cell(dash55, 1, 4, na(last_eq_val) ? "-" : str.tostring(last_eq_val, format.mintick), text_color=col_eq, text_size=size.normal)
// Son Sinyal
color sig_col = last_sig_type == "AL" ? col_up : last_sig_type == "SAT" ? col_dn : color.gray
table.cell(dash55, 0, 5, "Son Sinyal", text_color=color.gray, text_size=size.normal)
table.cell(dash55, 1, 5, last_sig_type + " (" + str.tostring(last_sig_price, format.mintick) + ")", text_color=sig_col, text_size=size.normal)
// Alt Bilgi
table.cell(dash55, 0, 6, " Yatύrύm tavsiyesi DEΠέLDέR.", text_color=color.new(color.white, 0), text_size=size.normal)
table.merge_cells(dash55, 0, 6, 1, 6)
///////////////////////////
group_pt = "Gόvenli Bφlge (8-34 PT Filtresi)"
bool show_pt_bg = input.bool(true, "Yeώil Arka Planύ Gφster", group=group_pt)
int pt_ema_len = input.int(21, "PT Hύzlύ (EMA)", group=group_pt)
int pt_sma_len = input.int(89, "PT Yavaώ (SMA)", group=group_pt)
// ─────────────────────────────────────────────────────────────────
// 4. MOTOR: GάVENLέ BΦLGE (8-34 POWER TREND FέLTRESέ)
// ─────────────────────────────────────────────────────────────────
float emaPT = ta.ema(close, pt_ema_len), float smaPT = ta.sma(close, pt_sma_len)
var int cL = 0
cL := (low > emaPT) ? nz(cL[1]) + 1 : 0
var bool ptOn = false
ptOn := ta.crossunder(emaPT, smaPT) ? false : (cL >= 5 and emaPT > smaPT ? true : ptOn)
bgcolor(show_pt_bg and ptOn ? color.new(color.gray, 68) : na, title="Gόvenli Bφlge Arka Planύ")
////////////////////////////////////
color col_cloud_up1 = color.new(#00e676, 0)
color col_cloud_dn1 = color.new(#ff1744, 0)
group_ayna = "Makro Duvarlar (Yin-Yang Ayna)"
float h_start = input.float(0.06, "Hύzlύ SAR Baώlangύη", step=0.01, group=group_ayna)
float h_inc = input.float(0.06, "Hύzlύ SAR έvme", step=0.01, group=group_ayna)
float h_max = input.float(0.30, "Hύzlύ SAR Max", step=0.1, group=group_ayna)
int pivot_len = input.int(10, "Duvar Tespiti (Pivot Uzunluπu)", group=group_ayna)
// ─────────────────────────────────────────────────────────────────
// 5. MOTOR: YέN-YANG AYNASI VE MAKRO DUVARLAR
// ─────────────────────────────────────────────────────────────────
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]
bool yeni_gun = ta.change(time("W")) != 0
[sar_hizli, trend_hizli] = f_ozel_sar(high, low, h_start, h_inc, h_max, yeni_gun)
float ayna_hizli = trend_hizli > 0 ? close + math.abs(close - sar_hizli) : close - math.abs(close - sar_hizli)
float ph_ayna = ta.pivothigh(ayna_hizli, pivot_len, pivot_len)
float pl_ayna = ta.pivotlow(ayna_hizli, pivot_len, pivot_len)
var array<line> macro_up_walls = array.new<line>()
var array<line> macro_dn_walls = array.new<line>()
// ZARέF DOKUNUή: style=line.style_dotted olarak deπiώtirildi
if not na(ph_ayna)
line w_up = line.new(bar_index[pivot_len], ph_ayna, bar_index, ph_ayna, color=col_cloud_up1, width=1, style=line.style_dotted, extend=extend.right)
array.push(macro_up_walls, w_up)
if array.size(macro_up_walls) > 2
line.delete(array.shift(macro_up_walls))
if not na(pl_ayna)
line w_dn = line.new(bar_index[pivot_len], pl_ayna, bar_index, pl_ayna, color=col_cloud_dn1, width=1, style=line.style_dotted, extend=extend.right)
array.push(macro_dn_walls, w_dn)
if array.size(macro_dn_walls) > 2
line.delete(array.shift(macro_dn_walls))
plot(ayna_hizli, "Ayna", color=color.new(color.gray, 100), linewidth=1, display=display.pane)
// ─────────────────────────────────────────────────────────────────
grp_pos = "PENCERE VE BOYUT AYARLARI"
i_bars = input.int(50, "Gφsterilecek Mum Sayύsύ", group=grp_pos, minval=10)
i_width = input.int(100, "Pencere Geniώliπi (Bar)", group=grp_pos, minval=20)
i_offset = input.int(10, "Yatay Uzaklύk (Saπa)", group=grp_pos)
i_vScale = input.float(35.0, "Dikey Φlηekleme (%)", group=grp_pos, step=1.0)
grp_style = "RENKLER VE GΦRSELLέK"
c_up = input.color(color.new(#00e676, 0), "Yόkseliώ Mumu", group=grp_style)
c_down = input.color(color.new(#ff1744, 0), "Dόώόώ Mumu", group=grp_style)
c_bg = input.color(color.new(#0b0e14, 20), "Arka Plan Kutusu",group=grp_style)
c_border = input.color(color.new(#ffffff, 80), "Pencere Ηerηevesi",group=grp_style)
c_fillUp = input.color(color.new(#26a69a, 60), "Bulut (Yόkseliώ)", group=grp_style)
c_fillDn = input.color(color.new(#ef5350, 60), "Bulut (Dόώόώ)", group=grp_style)
c_fillRng = input.color(color.new(#888888, 60), "Bulut (Yatay)", group=grp_style)
// ========================================================================= //
// ================== ICS 21 MATEMATέΠέ (YERLEήέK HESAPLAMA) =============== //
// ========================================================================= //
// Dizi (Array) kullanmadan, doπrudan zaman serisi όzerinden ηalύώύr. Ηφkmez.
f_yz_sigma(len) =>
float _yzOR = math.log(open / nz(close[1], open))
float _yzCO = math.log(close / open)
float _yzHO = math.log(high / open)
float _yzHC = math.log(high / close)
float _yzLO = math.log(low / open)
float _yzLC = math.log(low / close)
float _sqOR = ta.variance(_yzOR, len)
float _sqCO = ta.variance(_yzCO, len)
float _sqRS = ta.sma(_yzHO * _yzHC + _yzLO * _yzLC, len)
float _k = 0.34 / (1.34 + (len + 1.0) / math.max(len - 1.0, 1.0))
float _sq = nz(_sqOR) + _k * nz(_sqCO) + (1.0 - _k) * nz(_sqRS)
math.max(math.sqrt(math.max(_sq, 0.0)), 1e-10)
f_icsLine(p1, x1, p2, x2, targetX, sig) =>
float out = p1
if x1 != x2 and p1 > 0 and p2 > 0 and sig > 1e-10
float y1 = math.log(p1) / sig
float y2 = math.log(p2) / sig
float yT = y1 + (y2 - y1) * (targetX - x1) / (x2 - x1)
out := math.exp(yT * sig)
out
f_icsAngle(p1, x1, p2, x2, sig) =>
float out = 0.0
if x1 != x2 and p1 > 0 and p2 > 0 and sig > 1e-10
float y1 = math.log(p1) / sig
float y2 = math.log(p2) / sig
out := math.atan((y2 - y1) / (x2 - x1)) * 180.0 / math.pi
out
f_ics_calc() =>
int P = 21
float sig = f_yz_sigma(20)
float h0 = ta.highest(high, P), float l0 = ta.lowest(low, P)
if bar_index < P * 5
[h0, l0, 0.0]
else
float h1 = h0[P], float l1 = l0[P]
float h2 = h0[P*2], float l2 = l0[P*2]
float h3 = h0[P*3], float l3 = l0[P*3]
float h4 = h0[P*4], float l4 = l0[P*4]
float g0 = (h0 > 0 and l0 > 0) ? math.exp((math.log(h0) + math.log(l0)) / 2.0) : na
float g1 = (h1 > 0 and l1 > 0) ? math.exp((math.log(h1) + math.log(l1)) / 2.0) : na
float g2 = (h2 > 0 and l2 > 0) ? math.exp((math.log(h2) + math.log(l2)) / 2.0) : na
float g3 = (h3 > 0 and l3 > 0) ? math.exp((math.log(h3) + math.log(l3)) / 2.0) : na
float g4 = (h4 > 0 and l4 > 0) ? math.exp((math.log(h4) + math.log(l4)) / 2.0) : na
int pd = g0 > g1 ? 1 : -1
int seg = 1
if g0 != g1
if (g1 > g2 ? 1 : (g1 < g2 ? -1 : 0)) == pd
seg := 2
if (g2 > g3 ? 1 : (g2 < g3 ? -1 : 0)) == pd
seg := 3
if (g3 > g4 ? 1 : (g3 < g4 ? -1 : 0)) == pd
seg := 4
int cx0 = int(-P/2), int cx1 = cx0 - P, int cx2 = cx1 - P, int cx3 = cx2 - P, int cx4 = cx3 - P
float fHH = h0, float fLH = h0, float fHL = l0, float fLL = l0
int xHH = cx0, int xLH = cx0, int xHL = cx0, int xLL = cx0
if seg >= 1
if h1 > fHH
fHH := h1, xHH := cx1
if h1 < fLH
fLH := h1, xLH := cx1
if l1 > fHL
fHL := l1, xHL := cx1
if l1 < fLL
fLL := l1, xLL := cx1
if seg >= 2
if h2 > fHH
fHH := h2, xHH := cx2
if h2 < fLH
fLH := h2, xLH := cx2
if l2 > fHL
fHL := l2, xHL := cx2
if l2 < fLL
fLL := l2, xLL := cx2
if seg >= 3
if h3 > fHH
fHH := h3, xHH := cx3
if h3 < fLH
fLH := h3, xLH := cx3
if l3 > fHL
fHL := l3, xHL := cx3
if l3 < fLL
fLL := l3, xLL := cx3
if seg >= 4
if h4 > fHH
fHH := h4, xHH := cx4
if h4 < fLH
fLH := h4, xLH := cx4
if l4 > fHL
fHL := l4, xHL := cx4
if l4 < fLL
fLL := l4, xLL := cx4
int sLx = seg == 1 ? cx1 : seg == 2 ? cx2 : seg == 3 ? cx3 : cx4
int sRx = cx0
float endG = seg == 1 ? g1 : seg == 2 ? g2 : seg == 3 ? g3 : g4
float ang = f_icsAngle(endG, sLx, g0, sRx, sig)
int dir = math.abs(ang) <= 0.5 ? 0 : pd
float uY1 = fHH, float uY2 = fHH, float lY1 = fLL, float lY2 = fLL
if dir == 1
uY1 := f_icsLine(fLH, xLH, fHH, xHH, sLx, sig), uY2 := f_icsLine(fLH, xLH, fHH, xHH, sRx, sig)
lY1 := f_icsLine(fLL, xLL, fHL, xHL, sLx, sig), lY2 := f_icsLine(fLL, xLL, fHL, xHL, sRx, sig)
else if dir == -1
uY1 := f_icsLine(fHH, xHH, fLH, xLH, sLx, sig), uY2 := f_icsLine(fHH, xHH, fLH, xLH, sRx, sig)
lY1 := f_icsLine(fHL, xHL, fLL, xLL, sLx, sig), lY2 := f_icsLine(fHL, xHL, fLL, xLL, sRx, sig)
float uYa = f_icsLine(uY1, sLx, uY2, sRx, 0, sig)
float lYa = f_icsLine(lY1, sLx, lY2, sRx, 0, sig)
[uYa, lYa, float(dir)]
// O anki mumun bulut deπerlerini global olarak alύyoruz
[uYa, lYa, bulut_yon] = f_ics_calc()
// ========================================================================= //
// =========================== ΗέZέM MOTORU (HέYERARήέ) ==================== //
// ========================================================================= //
var box[] kutu_bg = array.new_box()
var line[] cizgi_merkez= array.new_line()
var box[] kutu_bulut = array.new_box()
var line[] cizgi_mum = array.new_line()
var box[] kutu_mum = array.new_box()
var label[] etiketler = array.new_label()
f_temizle() =>
for b in kutu_bg
box.delete(b)
for l in cizgi_merkez
line.delete(l)
for b in kutu_bulut
box.delete(b)
for l in cizgi_mum
line.delete(l)
for b in kutu_mum
box.delete(b)
for lbl in etiketler
label.delete(lbl)
array.clear(kutu_bg), array.clear(cizgi_merkez), array.clear(kutu_bulut)
array.clear(cizgi_mum), array.clear(kutu_mum), array.clear(etiketler)
if barstate.islast
f_temizle()
// --- 1. ADIM: EKRANIN GENEL MATEMATέΠέ VE SINIRLARI ---
float max_val = high
float min_val = low
// Son 'i_bars' kadar mumu geηmiώe doπru tarayύp o bφlgenin Max ve Min deπerlerini buluyoruz
for i = 0 to i_bars - 1
float _h = high[i], float _l = low[i]
float _u = uYa[i], float _d = lYa[i]
max_val := math.max(max_val, _h)
min_val := math.min(min_val, _l)
if not na(_u)
max_val := math.max(max_val, _u), min_val := math.min(min_val, _u)
if not na(_d)
max_val := math.max(max_val, _d), min_val := math.min(min_val, _d)
// Pencereyi nereye ηizeceπiz? Ekranύn mevcut yόksekliπini referans alύyoruz
float hv = ta.highest(high, 300)
float lv = ta.lowest(low, 300)
float cr = hv - lv == 0 ? syminfo.mintick * 100 : hv - lv
float my = (hv + lv) / 2
float er = cr * (i_vScale / 100)
float top_y = my + er / 2
float bot_y = my - er / 2
float mid_y = (top_y + bot_y) / 2
int start_x = bar_index + i_offset
int end_x = start_x + i_width
int mid_x = (start_x + end_x) / 2
float hr = max_val - min_val == 0 ? syminfo.mintick : max_val - min_val
float ir = top_y - bot_y
// Mumlar arasύ geniώlik hesaplamasύ
float bs = float(i_width) / i_bars
int box_w = math.max(1, int(bs / 2))
// --- 2. ADIM: HέYERARήέK ΗέZέM ---
// Hiyerarώi 1: Ana Pencere (Zemin)
array.push(kutu_bg, box.new(start_x, top_y, end_x, bot_y, border_color=c_border, bgcolor=c_bg))
// Hiyerarώi 2: Merkez Denge Ηizgisi
array.push(cizgi_merkez, line.new(start_x, mid_y, end_x, mid_y, color=color.gray, style=line.style_dashed))
// Hiyerarώi 3: Alt ve άst Max/Min Etiketleri
array.push(etiketler, label.new(mid_x, top_y, "Max: " + str.tostring(max_val, format.mintick), color=color.new(color.black, 100), textcolor=color.gray, style=label.style_label_down, size=size.small))
array.push(etiketler, label.new(mid_x, bot_y, "Min: " + str.tostring(min_val, format.mintick), color=color.new(color.black, 100), textcolor=color.gray, style=label.style_label_up, size=size.small))
// Hiyerarώi 4 & 5: Bulutlar (Arkada) ve Mumlar (Φnde)
for i = 0 to i_bars - 1
int idx = i
float _o = open[idx], float _h = high[idx], float _l = low[idx], float _c = close[idx]
float _u = uYa[idx], float _d = lYa[idx], float _dir = bulut_yon[idx]
// Fiyatlarύ mini ekranύn y-koordinatlarύna dφnόώtόrόyoruz
float so = bot_y + ((_o - min_val) / hr) * ir
float sh = bot_y + ((_h - min_val) / hr) * ir
float sl = bot_y + ((_l - min_val) / hr) * ir
float sc = bot_y + ((_c - min_val) / hr) * ir
int xp = end_x - int(i * bs)
// A) Φnce Bulutu Ηiz (Arkada kalmasύ iηin ilk bu ηizilir)
if not na(_u) and not na(_d)
float sy_u = bot_y + ((_u - min_val) / hr) * ir
float sy_d = bot_y + ((_d - min_val) / hr) * ir
color cCloud = _dir == 1 ? c_fillUp : _dir == -1 ? c_fillDn : c_fillRng
array.push(kutu_bulut, box.new(xp - box_w, sy_u, xp + box_w, sy_d, border_color=na, bgcolor=cCloud))
// B) Sonra Mumu Ηiz (άste biner)
color col = _c >= _o ? c_up : c_down
array.push(cizgi_mum, line.new(xp, sh, xp, sl, color=col))
float box_top = math.max(so, sc)
float box_bot = math.min(so, sc)
if box_top == box_bot
// Mum doji ise ηizgi ηek
array.push(cizgi_mum, line.new(xp - 1, box_top, xp + 1, box_bot, color=col, width=2))
else
// Normal mum gφvdesi
array.push(kutu_mum, box.new(xp - 1, box_top, xp + 1, box_bot, border_color=col, bgcolor=col))
Yer έmleri