PHP Code:
// © Kinetik Komuta Merkezi [Masterpiece V5.1 - Kuantum Edition & Kara Kutu]
//@version=6
indicator("KKM Masterpiece V5.1", shorttitle="KKM Nihai Zeka", overlay=true, max_labels_count=100)
// ─────────────────────────────────────────────────────────────────
// 1. GέRDέLER
// ─────────────────────────────────────────────────────────────────
group_l1 = "1. L1 Kinetik Filtre (@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_core = "2. Sύfύr Gecikmeli Ηekirdek (ZLEMA)"
int i_coreLen = input.int(55, "Ηekirdek Uzunluπu", group=group_core)
group_trade = "3. Vur-Kaη Hedefi"
float i_tpPct = input.float(1.0, "Kiώisel Hedef (%)", step=0.1, group=group_trade)
group_stat = "4. έstatistiksel Volatilite (Kutup Yύldύzύ)"
int volLength = input.int(500, "Volatilite Periyodu", group=group_stat)
int projBars = input.int(3, "έleriye Dφnόk Mum (T)", group=group_stat)
int barsPerYear = input.int(525600, "Yύllύk Mum (1dk=525600)", group=group_stat)
// ─────────────────────────────────────────────────────────────────
// 2. MATEMATέKSEL MOTOR (MTF Uyumlu, HL2 Kόtle Merkezi)
// ─────────────────────────────────────────────────────────────────
f_calc() =>
// A. ZLEMA (Kinetik TP / Momentum Ηekirdeπi)
float ema1 = ta.ema(hl2, i_coreLen)
float ema2 = ta.ema(ema1, i_coreLen)
float val_core = ema1 + (ema1 - ema2)
// B. L1 @yφrόk@ (Kinetik Stop / Dinamik Zύrh)
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
// C. Saatlik Saf TWAP
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 val_twap_h = sumPriceH / barCountH
// D. Gόnlόk Saf TWAP
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 val_twap_d = sumPriceD / barCountD
[val_core, z, val_twap_h, val_twap_d, hl2]
// ─────────────────────────────────────────────────────────────────
// 3. MEVCUT GRAFέK έΗέN HESAPLAMA VE ΗέZέM
// ─────────────────────────────────────────────────────────────────
[curCore, curYoruk, curTwapH, curTwapD, curPrice] = f_calc()
plot(curTwapD, "Gόnlόk TWAP", color=color.rgb(255, 152, 0), linewidth=3, style=plot.style_linebr)
plot(curTwapH, "Saatlik TWAP", color=color.rgb(255, 204, 0), linewidth=1, style=plot.style_linebr)
plot(curYoruk, "@yφrόk@", color=color.fuchsia, linewidth=2, style=plot.style_stepline)
plot(curCore, "Ηekirdek", color=color.aqua, linewidth=2)
// ─────────────────────────────────────────────────────────────────
// 4. έSTATέSTέKSEL VOLATέLέTE VE NORMALέZASYON (KέNETέK GάΗ)
// ─────────────────────────────────────────────────────────────────
float logReturn = math.log(close / nz(close[1], close))
float rawVol = ta.stdev(logReturn, volLength)
float annualVol = rawVol * math.sqrt(barsPerYear)
float drift = 1.0 * annualVol * math.sqrt(float(projBars) / float(barsPerYear))
float expMovePct= (math.exp(drift) - 1) * 100
float safeAtr = math.max(ta.atr(14), syminfo.mintick)
// Normalizasyon (0-100 Skoru): Momentum + Oynaklύk + TWAP Katύlύmύ
float atrDist = math.min(math.abs(close - curCore) / safeAtr, 3.0)
float scoreMomentum = (atrDist / 3.0) * 100
float scoreVol = math.min(expMovePct / i_tpPct, 1.5) / 1.5 * 100
// Yeni Modόl: Saatlik TWAP'tan Kopuώ (Katύlύm / Tόkeniώ)
float twapDistAtr = math.abs(close - curTwapH) / safeAtr
bool isExhaustion = twapDistAtr > 2.5 and scoreVol > 80 // TWAP'tan ηok kopmuώ ve Oynaklύk zirvede = Tόkeniώ
float scoreTwap = isExhaustion ? 0 : math.min(twapDistAtr / 2.0, 1.0) * 100 // Gerginlik artarsa skor dόώer
float kinPowerScore = math.round((scoreMomentum * 0.4) + (scoreVol * 0.4) + (scoreTwap * 0.2))
// ─────────────────────────────────────────────────────────────────
// 5. KέNETέK ATEήLEME & OTONOM KARA KUTU HAFIZASI
// ─────────────────────────────────────────────────────────────────
bool trendBull = curPrice > curCore and curPrice > curYoruk and curPrice > curTwapH and curPrice > curTwapD
bool trendBear = curPrice < curCore and curPrice < curYoruk and curPrice < curTwapH and curPrice < curTwapD
bool isIgnition = (high - low) >= (safeAtr * 1.5)
bool fireBull = trendBull and isIgnition and close > open
bool fireBear = trendBear and isIgnition and close < open
var int activeSide = 0
var float shelfLevel = na
var float statTp = na
var float accScore = 0.0
// Genel Kara Kutu (Ledger) Deπiώkenleri
var float[] history_pnl = array.new_float()
var int[] history_dur = array.new_int()
var float entryPrice = na
var int entryBar = na
// SON έήLEMέ TAKέP EDEN ΦZEL DEΠέήKENLER
var string lastSigStatus = "BEKLENέYOR"
var float lastSigPnl = 0.0
var float lastSigEntry = na
var float lastSigTp = na
var float lastSigSl = na
var int lastSigBar = na
if (fireBull and activeSide != 1)
activeSide := 1, shelfLevel := curCore, statTp := close * (1 + (i_tpPct / 100)), accScore := 0.0
entryPrice := close, entryBar := bar_index
lastSigStatus := isExhaustion ? "AKTέF (BOΠA) ⚠️ TάKENέή" : "AKTέF (BOΠA)"
lastSigEntry := close, lastSigBar := bar_index, lastSigTp := statTp, lastSigSl := curYoruk
else if (fireBear and activeSide != -1)
activeSide := -1, shelfLevel := curCore, statTp := close * (1 - (i_tpPct / 100)), accScore := 0.0
entryPrice := close, entryBar := bar_index
lastSigStatus := isExhaustion ? "AKTέF (AYI) ⚠️ TάKENέή" : "AKTέF (AYI)"
lastSigEntry := close, lastSigBar := bar_index, lastSigTp := statTp, lastSigSl := curYoruk
if activeSide != 0
lastSigPnl := activeSide == 1 ? ((close - entryPrice) / entryPrice) * 100 : ((entryPrice - close) / entryPrice) * 100
lastSigSl := curYoruk
bool isBeyond = activeSide == 1 ? close > entryPrice : close < entryPrice
if isBeyond
accScore := math.min(100, accScore + 20)
bool stopOut = (activeSide == 1 and curPrice < curYoruk) or (activeSide == -1 and curPrice > curYoruk)
bool shelfFail = activeSide == 1 ? close < shelfLevel : close > shelfLevel
bool tpOut = (activeSide == 1 and high >= statTp) or (activeSide == -1 and low <= statTp)
if stopOut or shelfFail or tpOut
float finalPnl = activeSide == 1 ? ((close - entryPrice) / entryPrice) * 100 : ((entryPrice - close) / entryPrice) * 100
int finalDur = bar_index - entryBar
array.push(history_pnl, finalPnl)
array.push(history_dur, finalDur)
if array.size(history_pnl) > 20
array.shift(history_pnl)
array.shift(history_dur)
lastSigStatus := tpOut ? "KΒR ALINDI (TP)" : stopOut ? "STOP OLDU" : "RAF έPTALέ"
lastSigPnl := finalPnl
activeSide := 0, accScore := 0.0
color bCol = trendBull ? #00e676 : trendBear ? #ff1744 : #787b86
barcolor(bCol)
// Kara Kutu έstatistik Hesaplamalarύ
float totalPnl = 0.0
int winCount = 0
int totalDur = 0
int tradeCount = array.size(history_pnl)
if tradeCount > 0
for i = 0 to tradeCount - 1
float p = array.get(history_pnl, i)
totalPnl += p
if p > 0
winCount += 1
totalDur += array.get(history_dur, i)
float winRate = tradeCount > 0 ? (winCount / tradeCount) * 100 : 0.0
int avgDur = tradeCount > 0 ? math.round(totalDur / tradeCount) : 0
// ─────────────────────────────────────────────────────────────────
// 6. MTF VERέ ΗEKέMέ
// ─────────────────────────────────────────────────────────────────
[f1, y1, th1, td1, c1] = request.security(syminfo.tickerid, "1", f_calc())
[f3, y3, th3, td3, c3] = request.security(syminfo.tickerid, "3", f_calc())
[f5, y5, th5, td5, c5] = request.security(syminfo.tickerid, "5", f_calc())
[f15, y15, th15, td15, c15] = request.security(syminfo.tickerid, "15", f_calc())
[f30, y30, th30, td30, c30] = request.security(syminfo.tickerid, "30", f_calc())
[f60, y60, th60, td60, c60] = request.security(syminfo.tickerid, "60", f_calc())
// ─────────────────────────────────────────────────────────────────
// 7. NέHAέ MTF RADARI & OTONOM KARA KUTU PANOSU (23 SATIR)
// ─────────────────────────────────────────────────────────────────
var table mtfDash = table.new(position.top_right, 5, 23, bgcolor=color.new(color.black, 15), border_color=color.new(color.gray, 80), border_width=1)
f_draw_row(table t, int row, string tf, float core, float yoruk, float twapH, float twapD, float ref_c) =>
color rowBg = row % 2 == 0 ? color.new(color.black, 40) : color.new(color.gray, 90)
color c_c = ref_c >= core ? #00e676 : #ff1744
color c_y = ref_c >= yoruk ? #00e676 : #ff1744
color c_th = ref_c >= twapH ? #00e676 : #ff1744
color c_td = ref_c >= twapD ? #00e676 : #ff1744
table.cell(t, 0, row, tf, text_color=color.white, text_size=size.small, bgcolor=rowBg)
table.cell(t, 1, row, str.tostring(math.round(core, 2)), text_color=c_c, text_size=size.small, bgcolor=rowBg)
table.cell(t, 2, row, str.tostring(math.round(yoruk, 2)), text_color=c_y, text_size=size.small, bgcolor=rowBg)
table.cell(t, 3, row, str.tostring(math.round(twapH, 2)), text_color=c_th, text_size=size.small, bgcolor=rowBg)
table.cell(t, 4, row, str.tostring(math.round(twapD, 2)), text_color=c_td, text_size=size.small, bgcolor=rowBg)
if barstate.islast
table.cell(mtfDash, 0, 0, "MTF", text_color=color.white, text_size=size.small, bgcolor=color.new(color.gray, 80))
table.cell(mtfDash, 1, 0, "ΗEKέRDEK", text_color=color.white, text_size=size.small, bgcolor=color.new(color.gray, 80))
table.cell(mtfDash, 2, 0, "YΦRάK", text_color=color.white, text_size=size.small, bgcolor=color.new(color.gray, 80))
table.cell(mtfDash, 3, 0, "S-TWAP", text_color=color.white, text_size=size.small, bgcolor=color.new(color.gray, 80))
table.cell(mtfDash, 4, 0, "G-TWAP", text_color=color.white, text_size=size.small, bgcolor=color.new(color.gray, 80))
f_draw_row(mtfDash, 1, "1m", f1, y1, th1, td1, c1)
f_draw_row(mtfDash, 2, "3m", f3, y3, th3, td3, c3)
f_draw_row(mtfDash, 3, "5m", f5, y5, th5, td5, c5)
f_draw_row(mtfDash, 4, "15m", f15, y15, th15, td15, c15)
f_draw_row(mtfDash, 5, "30m", f30, y30, th30, td30, c30)
f_draw_row(mtfDash, 6, "1S", f60, y60, th60, td60, c60)
table.cell(mtfDash, 0, 7, "── VUR-KAΗ RADARI ──", text_color=color.gray, text_size=size.small, bgcolor=color.new(color.black, 40))
table.merge_cells(mtfDash, 0, 7, 4, 7)
string sigText = activeSide == 1 ? "ALIM AKTέF" : activeSide == -1 ? "SATIή AKTέF" : "BEKLENέYOR"
color sigCol = activeSide == 1 ? #00e676 : activeSide == -1 ? #ff1744 : #787b86
table.cell(mtfDash, 0, 8, "SέNYAL", text_color=color.white, text_size=size.small, bgcolor=color.new(color.gray, 90))
table.cell(mtfDash, 1, 8, sigText, text_color=sigCol, text_size=size.small, bgcolor=color.new(color.gray, 90))
table.merge_cells(mtfDash, 1, 8, 4, 8)
string kinText = activeSide != 0 ? "%" + str.tostring(kinPowerScore) + (kinPowerScore >= 70 ? " (GάΗLά)" : " (ZAYIF)") : "-"
color kinCol = kinPowerScore >= 70 ? color.aqua : color.orange
table.cell(mtfDash, 0, 9, "KέN. GάΗ (AI)", text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 40))
table.cell(mtfDash, 1, 9, kinText, text_color=kinCol, text_size=size.small, bgcolor=color.new(color.black, 40))
table.merge_cells(mtfDash, 1, 9, 4, 9)
color scoreCol = accScore >= 80 ? #00e676 : accScore >= 40 ? color.orange : #ff1744
table.cell(mtfDash, 0, 10, "KABUL SKORU", text_color=color.white, text_size=size.small, bgcolor=color.new(color.gray, 90))
table.cell(mtfDash, 1, 10, activeSide != 0 ? str.tostring(accScore) + "/100" : "-", text_color=scoreCol, text_size=size.small, bgcolor=color.new(color.gray, 90))
table.merge_cells(mtfDash, 1, 10, 4, 10)
table.cell(mtfDash, 0, 11, "KέN. STOP", text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 40))
table.cell(mtfDash, 1, 11, activeSide != 0 ? str.tostring(math.round(curYoruk, 2)) : "-", text_color=#ff1744, text_size=size.small, bgcolor=color.new(color.black, 40))
table.merge_cells(mtfDash, 1, 11, 4, 11)
table.cell(mtfDash, 0, 12, "KέN. TP (RAF)", text_color=color.white, text_size=size.small, bgcolor=color.new(color.gray, 90))
table.cell(mtfDash, 1, 12, activeSide != 0 ? str.tostring(math.round(shelfLevel, 2)) : "-", text_color=color.aqua, text_size=size.small, bgcolor=color.new(color.gray, 90))
table.merge_cells(mtfDash, 1, 12, 4, 12)
table.cell(mtfDash, 0, 13, "1σ έVME", text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 40))
table.cell(mtfDash, 1, 13, "%" + str.tostring(expMovePct, "#.##"), text_color=color.yellow, text_size=size.small, bgcolor=color.new(color.black, 40))
table.merge_cells(mtfDash, 1, 13, 4, 13)
table.cell(mtfDash, 0, 14, "── OTONOM KARA KUTU ──", text_color=color.gray, text_size=size.small, bgcolor=color.new(color.gray, 90))
table.merge_cells(mtfDash, 0, 14, 4, 14)
table.cell(mtfDash, 0, 15, "SON " + str.tostring(tradeCount) + " έήLEM", text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 40))
table.cell(mtfDash, 1, 15, "%" + str.tostring(math.round(winRate, 1)) + " BAήARI", text_color=winRate >= 50 ? #00e676 : #ff1744, text_size=size.small, bgcolor=color.new(color.black, 40))
table.merge_cells(mtfDash, 1, 15, 4, 15)
table.cell(mtfDash, 0, 16, "ORTALAMA SάRE", text_color=color.white, text_size=size.small, bgcolor=color.new(color.gray, 90))
table.cell(mtfDash, 1, 16, str.tostring(avgDur) + " MUM", text_color=color.silver, text_size=size.small, bgcolor=color.new(color.gray, 90))
table.merge_cells(mtfDash, 1, 16, 4, 16)
table.cell(mtfDash, 0, 17, "NET DURUM", text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 40))
table.cell(mtfDash, 1, 17, (totalPnl > 0 ? "+" : "") + str.tostring(math.round(totalPnl, 2)) + "% KΒR/ZARAR", text_color=totalPnl >= 0 ? #00e676 : #ff1744, text_size=size.small, bgcolor=color.new(color.black, 40))
table.merge_cells(mtfDash, 1, 17, 4, 17)
table.cell(mtfDash, 0, 18, "── SON έήLEM DETAYI ──", text_color=color.gray, text_size=size.small, bgcolor=color.new(color.gray, 90))
table.merge_cells(mtfDash, 0, 18, 4, 18)
// TάKENέή UYARISI RENKLENDέRMESέ
bool isDanger = str.contains(lastSigStatus, "TάKENέή")
table.cell(mtfDash, 0, 19, "DURUM", text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 40))
table.cell(mtfDash, 1, 19, lastSigStatus, text_color=isDanger ? color.orange : (str.contains(lastSigStatus, "AKTέF") ? color.aqua : color.silver), text_size=size.small, bgcolor=color.new(color.black, 40))
table.merge_cells(mtfDash, 1, 19, 4, 19)
string entryStr = na(lastSigEntry) ? "-" : str.tostring(math.round(lastSigEntry, 2)) + " (" + str.tostring(bar_index - lastSigBar) + " Mum Φnce)"
table.cell(mtfDash, 0, 20, "GέRέή / ZAMAN", text_color=color.white, text_size=size.small, bgcolor=color.new(color.gray, 90))
table.cell(mtfDash, 1, 20, entryStr, text_color=color.white, text_size=size.small, bgcolor=color.new(color.gray, 90))
table.merge_cells(mtfDash, 1, 20, 4, 20)
string tpSlStr = na(lastSigEntry) ? "-" : "TP: " + str.tostring(math.round(lastSigTp, 2)) + " | SL: " + str.tostring(math.round(lastSigSl, 2))
table.cell(mtfDash, 0, 21, "HEDEF / STOP", text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 40))
table.cell(mtfDash, 1, 21, tpSlStr, text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 40))
table.merge_cells(mtfDash, 1, 21, 4, 21)
string pnlStr = na(lastSigEntry) ? "-" : (lastSigPnl > 0 ? "+" : "") + str.tostring(lastSigPnl, "#.##") + "%"
color pnlC = lastSigPnl > 0 ? #00e676 : lastSigPnl < 0 ? #ff1744 : color.silver
table.cell(mtfDash, 0, 22, "GERΗEKLEήME", text_color=color.white, text_size=size.small, bgcolor=color.new(color.gray, 90))
table.cell(mtfDash, 1, 22, pnlStr, text_color=pnlC, text_size=size.small, bgcolor=color.new(color.gray, 90))
table.merge_cells(mtfDash, 1, 22, 4, 22)
Yer έmleri