PHP Code:
// Kinetik Komuta Merkezi [V9.2 - Ultra-Clean Dashboard Edition]
//@version=6
indicator("Kinetik Komuta Merkezi [V9.2]", shorttitle="KKM V9.2", overlay=true, max_boxes_count=100, max_labels_count=200)
// ─────────────────────────────────────────────────────────────────
// 0. GRDLER VE AYARLAR
// ─────────────────────────────────────────────────────────────────
g_twap = "1. Maliyet Trambolini (TWAP)"
float i_dev1 = input.float(1.0, "1. Sapma (Grlt)", step=0.1, group=g_twap)
float i_dev2 = input.float(2.0, "2. Sapma (Kinetik Hedef)", step=0.1, group=g_twap)
g_fourier = "2. Fourier ekirdek"
int i_N = input.int(64, "Pencere Uzunluu (N)", group=g_fourier)
int i_harmonics = input.int(3, "Harmonik Filtresi", group=g_fourier)
g_ember = "3. Kinetik tki"
int i_atrLen = input.int(14, "ATR Uzunluu", group=g_ember)
float i_ignRange = input.float(1.5, "Ateleme Eii (ATR)", step=0.1, group=g_ember)
g_accept = "4. Kabul (Acceptance) Motoru"
float i_bandAtr = input.float(0.30, "Kabul Band (ATR)", step=0.05, group=g_accept)
float i_shelfAtr = input.float(0.50, "ptal Raf (ATR)", step=0.05, group=g_accept)
int i_minCloses = input.int(3, "Minimum Onay Mumu", group=g_accept)
// Renkler
color c_twap = color.rgb(255, 204, 0)
color c_buy = color.rgb(0, 230, 118)
color c_sell = color.rgb(255, 23, 68)
color c_watch = color.rgb(41, 98, 255)
color c_shelf = color.rgb(136, 14, 79)
color c_neutral= color.rgb(120, 123, 134)
// ─────────────────────────────────────────────────────────────────
// 1. SAF TWAP VE STATSTKSEL SAPMA
// ─────────────────────────────────────────────────────────────────
bool isNewDay = ta.change(time("D")) != 0
var float sumPrice = 0.0
var float sumPrice2 = 0.0
var int barCount = 0
if isNewDay
sumPrice := close
sumPrice2 := close * close
barCount := 1
else
sumPrice += close
sumPrice2 += close * close
barCount += 1
float twapValue = sumPrice / barCount
float variance = (sumPrice2 / barCount) - (twapValue * twapValue)
float stdev = math.sqrt(math.max(variance, 0))
float up1 = twapValue + (stdev * i_dev1)
float dn1 = twapValue - (stdev * i_dev1)
float up2 = twapValue + (stdev * i_dev2)
float dn2 = twapValue - (stdev * i_dev2)
// Sadece TWAP Merkez izgisi Ekranda Kalr (Dier Bantlar Tabloya Gitti)
plot(twapValue, "TWAP", color=color.new(c_twap, 20), linewidth=2, style=plot.style_linebr, display=display.pane)
// ─────────────────────────────────────────────────────────────────
// 2. FOURIER SPEKTRAL DNM
// ─────────────────────────────────────────────────────────────────
float dc = math.sum(close, i_N) / i_N
float a_k_sum = 0.0
for k = 1 to i_harmonics
float a_k = 0.0
for i = 0 to i_N - 1
float angle = (2.0 * math.pi * k * i) / i_N
a_k += nz(close[i]) * math.cos(angle)
a_k_sum += (2.0 / i_N) * a_k
float fourier_wave = dc + a_k_sum
float fourier_slope = fourier_wave - nz(fourier_wave[1])
bool bullBias = fourier_slope > 0
bool bearBias = fourier_slope < 0
// ─────────────────────────────────────────────────────────────────
// 3. KNETK ATELEME
// ─────────────────────────────────────────────────────────────────
float atrVal = ta.atr(i_atrLen)
float safeAtr = math.max(atrVal, syminfo.mintick)
float barRange = high - low
bool isIgnition = barRange >= (safeAtr * i_ignRange)
bool fireBull = bullBias and isIgnition and close > open and close > nz(close[1])
bool fireBear = bearBias and isIgnition and close < open and close < nz(close[1])
// ─────────────────────────────────────────────────────────────────
// 4. FYAT KABUL (ACCEPTANCE) VE PTAL RAFI DEVRES
// ─────────────────────────────────────────────────────────────────
var int activeSide = 0
var float activeLevel = na
var int startBar = na
var int beyondCloses = 0
var string plannerState = "NO SIGNAL"
var float accScore = 0.0
var box accBox = na
var box shelfBox = na
if (fireBull and activeSide != 1)
activeSide := 1
activeLevel := close
startBar := bar_index
beyondCloses := 0
plannerState := "BUILDING (BULL)"
accScore := 0.0
label.new(bar_index, low - safeAtr, "ATELEME", color=c_buy, textcolor=color.white, style=label.style_label_up, size=size.small)
else if (fireBear and activeSide != -1)
activeSide := -1
activeLevel := close
startBar := bar_index
beyondCloses := 0
plannerState := "BUILDING (BEAR)"
accScore := 0.0
label.new(bar_index, high + safeAtr, "ATELEME", color=c_sell, textcolor=color.white, style=label.style_label_down, size=size.small)
bool stateChanged = false
if activeSide != 0
int barsActive = bar_index - startBar
float shelf = activeSide == 1 ? activeLevel - (i_shelfAtr * safeAtr) : activeLevel + (i_shelfAtr * safeAtr)
float bandTop = activeLevel + (i_bandAtr * safeAtr)
float bandBot = activeLevel - (i_bandAtr * safeAtr)
bool isBeyond = activeSide == 1 ? close > activeLevel : close < activeLevel
if isBeyond
beyondCloses += 1
bool isFailed = activeSide == 1 ? close < shelf : close > shelf
float persistenceScore = math.min(50, (beyondCloses / math.max(1.0, i_minCloses)) * 50)
float distanceScore = math.min(30, (math.abs(close - activeLevel) / safeAtr) * 15)
float momentumScore = isBeyond ? 20 : 0
accScore := persistenceScore + distanceScore + momentumScore
string prevState = plannerState
if isFailed
plannerState := "REJECTED"
activeSide := 0
accScore := 0.0
else if accScore >= 80 and barsActive >= i_minCloses
plannerState := "ACCEPTED"
else if accScore >= 50
plannerState := "WATCH"
stateChanged := plannerState != prevState
color boxCol = activeSide == 1 ? color.new(c_buy, 85) : color.new(c_sell, 85)
if barsActive == 0
accBox := box.new(startBar, bandTop, bar_index + 10, bandBot, bgcolor=boxCol, border_color=color.new(boxCol, 0))
float shelfT = activeSide == 1 ? shelf : shelf + (safeAtr * 0.1)
float shelfB = activeSide == 1 ? shelf - (safeAtr * 0.1) : shelf
shelfBox := box.new(startBar, shelfT, bar_index + 10, shelfB, bgcolor=color.new(c_shelf, 85), border_color=color.new(c_shelf, 20))
else if activeSide != 0
box.set_right(accBox, bar_index + 6)
box.set_right(shelfBox, bar_index + 6)
box.set_text(accBox, str.tostring(math.round(accScore)) + "/100")
box.set_text_color(accBox, color.new(color.white, 30))
box.set_text_size(accBox, size.small)
if stateChanged
if plannerState == "ACCEPTED"
label.new(bar_index, activeSide == 1 ? low - safeAtr : high + safeAtr, "ACCEPT", color=c_buy, textcolor=color.white, style=activeSide==1?label.style_label_up:label.style_label_down, size=size.small)
else if plannerState == "WATCH"
label.new(bar_index, activeSide == 1 ? low - safeAtr : high + safeAtr, "WATCH", color=c_watch, textcolor=color.white, style=activeSide==1?label.style_label_up:label.style_label_down, size=size.small)
if plannerState == "REJECTED" and prevState != "REJECTED"
label.new(bar_index, activeSide[1] == 1 ? low - safeAtr : high + safeAtr, "REJECTED", color=color.maroon, textcolor=color.white, style=activeSide[1]==1?label.style_label_up:label.style_label_down, size=size.small)
// ─────────────────────────────────────────────────────────────────
// 5. FOURIER DALGASI (KNETK NEON)
// ─────────────────────────────────────────────────────────────────
color waveCol = bullBias ? c_buy : bearBias ? c_sell : c_neutral
plot(fourier_wave, "Glow D", color=color.new(waveCol, 85), linewidth=6, display=display.pane)
plot(fourier_wave, "Glow ", color=color.new(waveCol, 60), linewidth=3, display=display.pane)
plot(fourier_wave, "ekirdek", color=color.new(waveCol, 0), linewidth=1, display=display.pane)
barcolor(activeSide != 0 ? (activeSide == 1 ? color.new(c_buy, 30) : color.new(c_sell, 30)) : na)
// ─────────────────────────────────────────────────────────────────
// 6. KNETK KONTROL PANEL (DASHBOARD)
// ─────────────────────────────────────────────────────────────────
if barstate.islast
var table kkmDash = table.new(position.top_right, 2, 7, bgcolor=color.new(color.black, 15), border_color=color.new(color.gray, 80), border_width=1)
// Pano Bal
table.cell(kkmDash, 0, 0, "KKM V9 Terminal", text_color=color.white, text_size=size.small, text_halign=text.align_center)
table.merge_cells(kkmDash, 0, 0, 1, 0)
// TWAP Durumu
table.cell(kkmDash, 0, 1, "TWAP Merkez", text_color=color.gray, text_size=size.small, text_halign=text.align_left)
table.cell(kkmDash, 1, 1, str.tostring(math.round(twapValue, 2)), text_color=c_twap, text_size=size.small, text_halign=text.align_right)
// st Sapmalar (+1 / +2)
table.cell(kkmDash, 0, 2, "st Sapma (+1σ | +2σ)", text_color=color.gray, text_size=size.small, text_halign=text.align_left)
table.cell(kkmDash, 1, 2, str.tostring(math.round(up1, 2)) + " | " + str.tostring(math.round(up2, 2)), text_color=c_buy, text_size=size.small, text_halign=text.align_right)
// Alt Sapmalar (-1 / -2)
table.cell(kkmDash, 0, 3, "Alt Sapma (-1σ | -2σ)", text_color=color.gray, text_size=size.small, text_halign=text.align_left)
table.cell(kkmDash, 1, 3, str.tostring(math.round(dn1, 2)) + " | " + str.tostring(math.round(dn2, 2)), text_color=c_sell, text_size=size.small, text_halign=text.align_right)
// Fourier vmesi
table.cell(kkmDash, 0, 4, "Fourier vme", text_color=color.gray, text_size=size.small, text_halign=text.align_left)
table.cell(kkmDash, 1, 4, bullBias ? "BULL" : bearBias ? "BEAR" : "NTR", text_color=waveCol, text_size=size.small, text_halign=text.align_right)
// Kabul Skoru
table.cell(kkmDash, 0, 5, "Kabul Skoru", text_color=color.gray, text_size=size.small, text_halign=text.align_left)
table.cell(kkmDash, 1, 5, activeSide != 0 ? str.tostring(math.round(accScore)) + "/100" : "-", text_color=activeSide != 0 ? color.white : color.gray, text_size=size.small, text_halign=text.align_right)
// En Son Durum (State)
color stateCol = plannerState == "ACCEPTED" ? c_buy : plannerState == "REJECTED" ? c_sell : plannerState == "WATCH" ? c_watch : color.gray
table.cell(kkmDash, 0, 6, "Son Durum", text_color=color.gray, text_size=size.small, text_halign=text.align_left)
table.cell(kkmDash, 1, 6, plannerState, text_color=stateCol, text_size=size.small, text_halign=text.align_right)
Yer mleri