PHP Code:
// © Kinetik Komuta Merkezi - Master Hub (v6.7 - Quantum Regression Pro)
//@version=6
indicator("KKM Master Hub v6.7", overlay=false, max_boxes_count=500, max_lines_count=500)
// ─────────────────────────────────────────────────────────────────
// 1. KAMA TABANLI ADAPTέF KάTLE (Hacimsiz Fizik)
// ─────────────────────────────────────────────────────────────────
f_kama_kinetik(src, len, f, s) =>
mom = math.abs(ta.change(src, len))
vol = math.sum(math.abs(ta.change(src)), len)
er = vol != 0 ? mom / vol : 0
fastA = 2 / (f + 1), slowA = 2 / (s + 1)
alpha = math.pow(er * (fastA - slowA) + slowA, 2)
var float k = na
k := alpha * src + (1 - alpha) * nz(k[1], src)
k
// KAMA ile gόηlendirilmiώ Kinetik Zemin
float kin_z = f_kama_kinetik(hl2, 10, 2, 30)
var int trend = 0
trend := kin_z > kin_z[1] ? 1 : kin_z < kin_z[1] ? -1 : nz(trend[1])
// ─────────────────────────────────────────────────────────────────
// 2. POLέNOMέK REGRESYON MOTORU (OLS Metodu)
// ─────────────────────────────────────────────────────────────────
f_polyreg(src, len) =>
float sumX = 0.0, float sumY = 0.0, float sumXY = 0.0, float sumX2 = 0.0
for i = 0 to len - 1
sumX += i
sumY += src[i]
sumXY += i * src[i]
sumX2 += i * i
slope = (len * sumXY - sumX * sumY) / (len * sumX2 - sumX * sumY)
intercept = (sumY - slope * sumX) / len
[slope, intercept]
[p_slope, p_int] = f_polyreg(close, 20)
// Regresyon Sapmasύ (Kalkan Geniώliπi)
float reg_dist = ta.highest(ta.sma(high - low, 20), 20) * 1.5
// ─────────────────────────────────────────────────────────────────
// 3. DERέN ΦΠRENME (Tanh) & REGRESYON HέBRέT N-BAR
// ─────────────────────────────────────────────────────────────────
f_tanh(v) => (1 - math.exp(-2 * v)) / (1 + math.exp(-2 * v))
k_diff = (kin_z - kin_z[1]) / (kin_z[1] + 1e-9)
n_in = f_tanh(k_diff * 100)
// N-BAR Projeksiyon Hesaplama
float f_p_open = close
float f_p_close = close * (1 + (f_tanh(n_in * 4.16) * 0.01))
// Regresyon Onaylύ Kόtle Bloπu (Fitil-Gφvde Entegre)
float f_p_max = math.max(f_p_open, f_p_close) + (reg_dist * 0.2)
float f_p_min = math.min(f_p_open, f_p_close) - (reg_dist * 0.2)
// --- GEΗMέή N-BAR έZLERέ (Kutular) ---
color nbar_col = f_p_close > f_p_open ? color.new(color.lime, 75) : color.new(color.red, 75)
box.new(bar_index + 1, f_p_max, bar_index + 1, f_p_min, border_color=nbar_col, bgcolor=nbar_col, border_width=4)
// ─────────────────────────────────────────────────────────────────
// 4. v6.5 ANTI-CHOP & REGRESYON KALKANI
// ─────────────────────────────────────────────────────────────────
psar_agresif = ta.sar(0.0, 0.1, 0.9)
bool kutle_hareketli = ta.change(kin_z) != 0
// KAMA Efficiency Ratio (ER) ile desteklenen Testere Filtresi
er_val = math.abs(ta.change(close, 10)) / math.sum(math.abs(ta.change(close)), 10)
bool is_wait = (er_val < 0.2 or not kutle_hareketli) and ((trend == 1 and close < psar_agresif) or (trend == -1 and close > psar_agresif))
color bar_col = is_wait ? color.rgb(241, 191, 9) : (trend == 1 ? color.rgb(72, 248, 3) : color.rgb(252, 7, 7))
barcolor(bar_col)
// ─────────────────────────────────────────────────────────────────
// GΦRSELLEήTέRME & REGRESYON RADARI
// ─────────────────────────────────────────────────────────────────
plot(kin_z, "Kinetik Zemin", color=color.orange, style=plot.style_stepline, linewidth=1)
// Regresyon Hedef Ηizgileri (Noktalύ Gόmόώ Radar)
var line reg_line = na
if barstate.islast
line.delete(reg_line)
reg_line := line.new(bar_index, close, bar_index + 5, close - p_slope * 5, color=color.new(color.silver, 50), style=line.style_dotted, width=2)
// --- KKM v6.7 DEΠER ODAKLI KUANTUM PANELέ ---
group_panel = "Kuantum Panel"
show_panel = input.bool(true, "Paneli Gφster?", group=group_panel)
// Kritik Periyotlar
tf_5 = "5"
tf_60 = "60"
tf_D = "D"
// Kόtle ve Deπiώim Verilerini Ηekiyoruz
[kin_5, chg_5] = request.security(syminfo.tickerid, tf_5, [kin_z, ta.change(kin_z)])
[kin_60, chg_60] = request.security(syminfo.tickerid, tf_60, [kin_z, ta.change(kin_z)])
[kin_D, chg_D] = request.security(syminfo.tickerid, tf_D, [kin_z, ta.change(kin_z)])
// Panel Oluώturma (3 Sόtun: Periyot, Yφn, Deπer)
var table mtf_table = table.new(position.top_right, 3, 4, frame_color=color.gray, frame_width=1, border_width=1)
if barstate.islast and show_panel
// Baώlύklar
table.cell(mtf_table, 0, 0, "PERέYOT", text_color=color.white, bgcolor=color.black)
table.cell(mtf_table, 1, 0, "YΦN", text_color=color.white, bgcolor=color.black)
table.cell(mtf_table, 2, 0, "KάTLE VAL", text_color=color.white, bgcolor=color.black)
// 5 DK Satύrύ
table.cell(mtf_table, 0, 1, "5M", text_color=color.white)
table.cell(mtf_table, 1, 1, chg_5 > 0 ? "▲" : "▼", text_color=chg_5 > 0 ? color.lime : color.red)
table.cell(mtf_table, 2, 1, str.tostring(kin_5, format.mintick), text_color=color.silver)
// 1 Saat Satύrύ
table.cell(mtf_table, 0, 2, "1H", text_color=color.white)
table.cell(mtf_table, 1, 2, chg_60 > 0 ? "▲" : "▼", text_color=chg_60 > 0 ? color.lime : color.red)
table.cell(mtf_table, 2, 2, str.tostring(kin_60, format.mintick), text_color=color.silver)
// Gόnlόk Satύr
table.cell(mtf_table, 0, 3, "1D", text_color=color.white)
table.cell(mtf_table, 1, 3, chg_D > 0 ? "▲" : "▼", text_color=chg_D > 0 ? color.lime : color.red)
table.cell(mtf_table, 2, 3, str.tostring(kin_D, format.mintick), text_color=color.silver)
//////////
// 2. DERέN ΦΠRENME (Tanh) & KέNETέK ΗEKέRDEK KANALI (Yeni)
// ─────────────────────────────────────────────────────────────────
//f_tanh(v) => (1 - math.exp(-2 * v)) / (1 + math.exp(-2 * v))
td_fn(s) => nz((s - nz(s[1])) / (nz(s[1]) + 1e-9))
// DL Giriώleri (Fiyat έvmesi)
in_o = f_tanh(td_fn(open)), in_h = f_tanh(td_fn(high)), in_l = f_tanh(td_fn(low)), in_c = f_tanh(td_fn(close))
h0 = f_tanh((in_o * 22.427) + (in_h * -26.691) + (in_l * 4.937) + (in_c * 9.034) - 10.692)
h1 = f_tanh((in_o * -38.288) + (in_h * 10.050) + (in_l * -44.706) + (in_c * -17.816) + 30.566)
dl_val = f_tanh((h0 * -22.053) + (h1 * 3.652) - 0.415)
// Renkli Ηekirdek Kanalύ (Atmosfer) Hesaplamasύ
float atmos_range = ta.atr(14) * (0.5 + math.abs(dl_val))
float atmos_top = close + atmos_range
float atmos_bot = close - atmos_range
// Kanal Ηizimi
p_top = plot(atmos_top, "Kanal άst", color=color.new(color.silver, 90))
p_bot = plot(atmos_bot, "Kanal Alt", color=color.new(color.silver, 90))
fill(p_top, p_bot, color=trend == 1 ? color.new(color.lime, 85) : color.new(color.red, 85), title="Ηekirdek Dolgu")
//////////
////////////sarlar////////////////
sar_fast = ta.sar(0.02, 0.02, 0.20)
sar_mid = ta.sar(0.03, 0.03, 0.25)
sar_slow = ta.sar(0.04, 0.04, 0.30)
plot(sar_fast, 'C', color = color.rgb(255, 238, 0), style = plot.style_cross, linewidth = 1)
plot(sar_mid, 'B', color = color.rgb(0, 255, 238), style = plot.style_cross, linewidth = 1)
plot(sar_slow, 'A', color = color.rgb(255, 0, 0), style = plot.style_cross, linewidth = 1)
///////////////////////////////KΦPEKBALIΠI///////////////////////////////////////////////////
bgcolorEnabled = input(true, title = 'Background ')
bgcolorColor = input.color(color.new(#d3f803, 70), title = 'ARKA RENK')
barcolorEnabled = input(true, title = 'Bar ')
barcolorColor = input.color(color.rgb(240, 241, 154), title = 'Bar RENK')
targetLinesEnabled = input(true, title = 'HEDEF')
targetLineColor = input.color(color.yellow, title = 'RENK')
targetLineThickness = input.int(4, title = 'ΗέZGέ', minval = 1, maxval = 5)
// KALIP KURALI//////////
ISP32 = low[2] < low[1] and low[1] < low and high[2] > high[1] and high[1] > high
// BARLARI KALIPLA TAKέP ET///
var color barColorCurrent = na
var color barColor1 = na
var color barColor2 = na
barColorCurrent := barcolorEnabled and (ISP32 or ISP32[1] or ISP32[2]) ? barcolorColor : na
barColor1 := barcolorEnabled and (ISP32[1] or ISP32[2]) ? barcolorColor : na
barColor2 := barcolorEnabled and ISP32[2] ? barcolorColor : na
if ISP32
boxlen = 0
future_bar_index_lines = bar_index + 3
future_bar_index_fill = bar_index + boxlen
line.new(x1 = bar_index[2], y1 = low[2], x2 = future_bar_index_lines, y2 = low[2], color = color.blue, width = 3, extend = extend.none)
line.new(x1 = bar_index[2], y1 = high[2], x2 = future_bar_index_lines, y2 = high[2], color = color.yellow, width = 3, extend = extend.none)
if targetLinesEnabled
line.new(x1 = bar_index[2], y1 = high[2] + high[2] - low[2], x2 = future_bar_index_lines, y2 = high[2] + high[2] - low[2], color = targetLineColor, width = targetLineThickness, style = line.style_dotted, extend = extend.none)
line.new(x1 = bar_index[2], y1 = low[2] - (high[2] - low[2]), x2 = future_bar_index_lines, y2 = low[2] - (high[2] - low[2]), color = targetLineColor, width = targetLineThickness, style = line.style_dotted, extend = extend.none)
// KALIBI OLUήTUR
if bgcolorEnabled
box.new(left = bar_index[2], top = high[2], right = future_bar_index_fill, bottom = low[2], bgcolor = bgcolorColor)
//////////////////////////////////////////////////////////////////////////BAR RENKLENDέR////////////////////
// Ortak baώlangύη deπeri
start = 0.01
// 4. SAR ve EMA(5) ile yumuώatma
sar4_raw = ta.sar(start, 1, 1)
sar4_ema = ta.ema(sar4_raw, 3)
// SAR4 EMA ηizgi rengi: fiyatύn όstόnde yeώil, altύnda kύrmύzύ
sar4_color = close > sar4_ema ? color.white : color.fuchsia
///////
// 5 SAR hesapla
sar18 = ta.sar(0.1, 0.1, 0.1)
sar28 = ta.sar(0.1, 0.3, 0.3)
sar38 = ta.sar(0.1, 0.5, 0.5)
sar48 = ta.sar(0.1, 0.7, 0.7)
sar58 = ta.sar(0.1, 1.0, 1.0)
// SAR ortalamasύ ve EMA(3) ile smooth
sarAvg8 = (sar18 + sar28 + sar38 + sar48 + sar58) / 5
smoothedSar8 = ta.ema(sarAvg8, 10)
// EMA(1) (fiyat ηizgisi)
ema18 = ta.ema(close, 1)
// Ηizgiler
// === SAR'lar
sar19 = ta.sar(0., 0.1, 0.1)
sar59 = ta.sar(0., 0.1, 0.1)
sar109 = ta.sar(0., 0.1, 0.1)
// === Gerηek eώitlik kontrolό
equalAll = sar19 == sar59 and sar59 == sar109
sort9 = (sar19 + sar59 + sar109) / 3
TREND789=(smoothedSar8+sort9+sar4_ema)/3
plot(TREND789, title = '@yφrόk@', color = sar4_color, style = plot.style_stepline, linewidth = 1)
// Sinyaller
longSignal8 = ta.crossover(ema18, smoothedSar8) // AL
shortSignal8 = ta.crossunder(ema18, smoothedSar8) // SAT
A111 = input(0.)
B111 = input(0.01)
C111 = input(0.1, ".")
ABC111 = ta.sar(A111, B111, C111)
plot(ABC111, "@yφrόk@", style=plot.style_cross, color=sar4_color, linewidth = 2)
//////////////
// ─────────────────────────────────────────────────────────────────
// 0. FONKSέYONLAR (KάTLE VE ΦZEL SAR BέRLEήTέRέLMέή)
// ─────────────────────────────────────────────────────────────────
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
// HATA DάZELTέLDέ: Virgόl ayrύmύ Pine Script'te hata verir, alt alta yazύlmalύ.
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
// Klonlanan f_ozel_sar1 iptal edildi. Bu fonksiyon hem deπeri hem trendi dφndόrόr.
f_ozel_sar(src_h, src_l, _start, _inc, _max) =>
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
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]
f_zlema(series float src, simple int len) =>
float ema1 = ta.ema(src, len)
float ema2 = ta.ema(ema1, len)
ema1 + (ema1 - ema2)
// ─────────────────────────────────────────────────────────────────
// 1. GέRDέLER VE RENK PALETέ
// ─────────────────────────────────────────────────────────────────
color col_up = color.new(#00e676, 0)
color col_dn = color.new(#ff1744, 0)
color col_gri = color.new(color.white, 0)
int atrLen = input.int(20, "Kinetik Hafύza (ATR)")
float atrMult = input.float(3.5, "Kinetik Gόrόltό Duvarύ", step=0.1)
float mu = input.float(0.6, "Yakύnsaklύk (μ)", step=0.1)
// ─────────────────────────────────────────────────────────────────
// 3. KUANTUM KALKANLARI (Mavi ve Sarύ Ortalamalar)
// ─────────────────────────────────────────────────────────────────
// Fonksiyon gόncellendiπi iηin ηaπrύlar ηoklu deπiώken [deπer, _] olarak ayarlandύ
[s_mavi1, _] = f_ozel_sar(kin_z, kin_z, 0.003, 0.003, 0.02)
[s_mavi2, _] = f_ozel_sar(kin_z, kin_z, 0.001, 0.001, 0.02)
[s_mavi3, _] = f_ozel_sar(kin_z, kin_z, 0.0005, 0.0005, 0.02)
float mavi_kalkan = (s_mavi1 + s_mavi2 + s_mavi3) / 3
[s_sari1, _] = f_ozel_sar(kin_z, kin_z, 0.01, 0.01, 0.2)
[s_sari2, _] = f_ozel_sar(kin_z, kin_z, 0.01, 0.02, 0.2)
[s_sari3, _] = f_ozel_sar(kin_z, kin_z, 0.01, 0.03, 0.2)
float sari_kalkan = (s_sari1 + s_sari2 + s_sari3) / 3
plot(mavi_kalkan, "Mavi Kalkan (Aπύr Ηekim)", color=hl2 > mavi_kalkan ? col_up : col_dn, linewidth=1)
plot(sari_kalkan, "Sarύ Kalkan (Orta Ηekim)", color=hl2 > sari_kalkan ? col_up : col_dn, linewidth=1)
//////// ΗέFT KATMANLI SAR MATRέSέ (Aπύr Ηekim ve Standart)
float sarFusya = ta.sar(0.001, 0.0005, 0.02)
plot(sarFusya, "Y", color.new(#040cfb, 0), 1, plot.style_cross)
float roSarFast = ta.sar(0.01, 0.03, 0.2)
plot(roSarFast, title="X", style=plot.style_cross, color=color.new(color.yellow, 0), linewidth=1)
// ─────────────────────────────────────────────────────────────────
// 4. GέRDέLER VE έSTέHBARAT (Z-RS)
// ─────────────────────────────────────────────────────────────────
string symB = input.symbol("BIST:XU100", "Kύyaslanacak Endeks / Hisse")
int zLenFast = input.int(55, "ZLEMA Hύzlύ (Kύsa Vade)", minval=1)
int zLenSlow = input.int(233, "ZLEMA Yavaώ (Uzun Vade)", minval=1)
[o2, h2, l2, c2, hl2_2] = request.security(symB, timeframe.period, [open, high, low, close, hl2], lookahead=barmerge.lookahead_off)
// ─────────────────────────────────────────────────────────────────
// 5. KέNETέK ORAN (RELATIVE STRENGTH) MATEMATέΠέ
// ─────────────────────────────────────────────────────────────────
float rs_c = close / c2
float rs_hl2 = hl2 / hl2_2
// ─────────────────────────────────────────────────────────────────
// 6. ZLEMA MOTORU VE KESέήέM MATEMATέΠέ
// ─────────────────────────────────────────────────────────────────
float zlema_fast = f_zlema(rs_hl2, zLenFast)
float zlema_slow = f_zlema(rs_hl2, zLenSlow)
bool isBullFast = rs_c > zlema_fast
bool isBullSlow = rs_c > zlema_slow
color colSari = color.new(color.yellow, 0)
color colFusya = color.new(color.fuchsia, 0)
color colYesil = color.new(#00e676, 0)
color colKirmizi= color.new(#ff1744, 0)
color barCol = (isBullFast and isBullSlow) ? colSari : (not isBullFast and not isBullSlow) ? colFusya : isBullFast ? colYesil : colKirmizi
barcolor(barCol)
// ─────────────────────────────────────────────────────────────────
// 7. YέN-YANG AYNASI VE ΗέZέMέ
// ─────────────────────────────────────────────────────────────────
[sar_hizli, trend_hizli] = f_ozel_sar(high, low, 0.06, 0.06, 0.30)
float ayna_hizli = trend_hizli > 0 ? hl2 + math.abs(hl2 - sar_hizli) : hl2 - math.abs(hl2 - sar_hizli)
bool isMirrorAbove = ayna_hizli > hl2
bool isMirrorBelow = ayna_hizli < hl2
color aynaColor = isMirrorAbove ? colYesil : isMirrorBelow ? colKirmizi : color.white
plot(ayna_hizli, "Yin-Yang Aynasύ", color=aynaColor, linewidth=1)
//////////
// 4. ΗέZέMLER: MAKRO OMURGA, 1M TWAP, SAR MATRέSέ VE AYNA
// =========================================================================
float z_mid4 = f_zlema(ta.median(hl2, 5), 233)
plot(z_mid4, "Omurga", color=color.new(color.fuchsia, 100), linewidth=1)
/////////
// έMZA PANELE EKLENDέ
var table ytd_table = table.new(position.bottom_center, 1, 1)
if barstate.islast
table.cell(ytd_table, 0, 0, "(Aέ, (Gemini Pro) ile yapύlmύώ, Eπitim ηalύώmasύdύr.) Yatύrύm tavsiyesi olarak KULLANILAMAZ.", text_color=color.new(color.white, 0), text_size=size.normal)
Yer έmleri