PHP Code:
//@version=6
indicator("Yφrόk [Ηift Motorlu Hibrit]", overlay=true, max_labels_count=500)
// ═════════════════════════════════════════════════════════════════════════
// BΦLάM 1: GέRDέLER VE ORTAK PARAMETRELER
// ═════════════════════════════════════════════════════════════════════════
k_start = input.float(0.0, "Kral Baώlangύη", step=0.01, group="Otonom Beyin (Zύrh Yφnό)")
k_inc = input.float(0.02, "Kral έvme", step=0.01, group="Otonom Beyin (Zύrh Yφnό)")
k_max = input.float(0.20, "Kral Max", step=0.01, group="Otonom Beyin (Zύrh Yφnό)")
hhma_ten = input.float(2.8, "Yφrόk Kύlύη Keskinliπi (Gerilim)", step=0.1, group="Hiperbolik Kύlύη (@yφrόk@)")
h_start = input.float(0.06, "Hύzlύ SAR Baώlangύη", group="Yin-Yang SAR (Tetik)")
h_inc = input.float(0.06, "Hύzlύ SAR έvme", group="Yin-Yang SAR (Tetik)")
h_max = input.float(0.30, "Hύzlύ SAR Max", group="Yin-Yang SAR (Tetik)")
y_start = input.float(0.01, "Yavaώ SAR Baώlangύη", group="Yin-Yang SAR (Tetik)")
y_inc = input.float(0.01, "Yavaώ SAR έvme", group="Yin-Yang SAR (Tetik)")
y_max = input.float(0.10, "Yavaώ SAR Max", group="Yin-Yang SAR (Tetik)")
multTight = input.float(0.7, "Zύrh έvme Ηarpanύ (+)", step=0.1, group="RMDT Kuantum Boπumu")
multWide = input.float(-0.7, "Zύrh Yorulma Ηarpanύ (-)", step=0.1, group="RMDT Kuantum Boπumu")
string tf = timeframe.period
int z_len = tf == "1" ? 34 : tf == "3" ? 21 : tf == "5" ? 13 : tf == "15" ? 8 : tf == "60" ? 5 : tf == "240" ? 3 : 2
int k_len = tf == "1" ? 21 : tf == "3" ? 13 : tf == "5" ? 8 : tf == "15" ? 5 : tf == "60" ? 3 : tf == "240" ? 2 : 2
// ═════════════════════════════════════════════════════════════════════════
// BΦLάM 2: MOTOR A - KERNEL, SAR VE RMDT (ESKέ SέSTEM)
// ═════════════════════════════════════════════════════════════════════════
rawATR = ta.atr(14)
atrNorm = rawATR / close
atrFactor = ta.ema(atrNorm, 14)
adaptScale = 1.0 + (atrFactor * 200.0)
h_val = 8.0 * adaptScale
float nwSum = 0.0
float nwWeight = 0.0
for i = 0 to z_len - 1
float kw = math.exp(-math.pow(i, 2) / (2.0 * math.pow(h_val, 2)))
nwSum += kw * nz(close[i])
nwWeight += kw
float nwRaw = nwSum / nwWeight
float aktif_zirh = ta.ema(nwRaw, 3)
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 isInit = false
bool t_change = 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]
isInit := 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
isInit := true
t_change := 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
isInit := true
t_change := 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 t_change
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 = math.max(0.01, 1.0 - (state.trend_age / decay_limit))
float y_inc = accel_inc * decay
if not isInit
if state.isLong
if high_val > state.extreme_point
state.extreme_point := high_val
state.accel_factor := math.min(state.accel_factor + y_inc, accel_max)
else
if low_val < state.extreme_point
state.extreme_point := low_val
state.accel_factor := math.min(state.accel_factor + y_inc, accel_max)
if bar_index > 2
if state.isLong
state.sar_value := math.min(math.min(state.sar_value, low_val[1]), low_val[2])
else
state.sar_value := math.max(math.max(state.sar_value, high_val[1]), high_val[2])
state
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
states.get(i).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
bool kral_yon = states.get(king_idx).isLong
f_rmsd(src, bench, len) =>
float sum_sq = 0.0
for i = 0 to len - 1
sum_sq += math.pow(nz(src[i]) - nz(bench[i]), 2)
math.sqrt(sum_sq / len)
rmsdVal = f_rmsd(close, aktif_zirh, 20)
devRaw = rmsdVal > 0 ? (close - aktif_zirh) / rmsdVal : 0.0
devSig = ta.ema(devRaw, 6)
sigAbs = math.abs(devSig)
sigPeak = ta.highest(sigAbs, 50)
sigNorm = sigPeak > 0 ? math.min(sigAbs / sigPeak, 1.0) : 0.0
mult = multWide - sigNorm * (multWide - multTight)
bandwidth = rmsdVal * mult
float trailRaw = kral_yon ? (aktif_zirh - bandwidth) : (aktif_zirh + bandwidth)
float trail = ta.ema(trailRaw, 3)
f_sinh_weight(series float _src, int _len, float _t) =>
float _weightSum = 0.0
float _weightedVal = 0.0
for i = 0 to _len - 1
float _x = (_len - i) / _len * _t
float _w = (math.exp(_x) - math.exp(-_x)) / 2.0
_weightedVal += nz(_src[i]) * _w
_weightSum += _w
_weightedVal / _weightSum
int halfLen = math.max(1, math.floor(k_len / 2))
int sqrtLen = math.max(1, math.floor(math.sqrt(k_len)))
float fastSinh = f_sinh_weight(close, halfLen, hhma_ten)
float slowSinh = f_sinh_weight(close, k_len, hhma_ten)
float rawHull = 2.0 * fastSinh - slowSinh
float hhma_val = f_sinh_weight(rawHull, sqrtLen, hhma_ten)
color col_yoruk = hhma_val > hhma_val[1] ? color.rgb(0, 230, 119, 100) : color.rgb(255, 82, 82, 100)
f_ozel_sar(src_h, src_l, _start, _inc, _max, _reset) =>
var int trend = 0
var float sar_v = 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_v := trend > 0 ? src_l[1] : src_h[1]
ep := trend > 0 ? src_h[1] : src_l[1]
af := _start
else
if _reset
af := _start
float n_sar = sar_v
if trend > 0
if src_h[1] > ep
ep := src_h[1]
af := math.min(_max, af + _inc)
n_sar := sar_v + af * (ep - sar_v)
n_sar := math.min(math.min(src_l[1], src_l[2]), n_sar)
if n_sar > src_l
trend := -1
n_sar := ep
ep := src_l
af := _start
else
if src_l[1] < ep
ep := src_l[1]
af := math.min(_max, af + _inc)
n_sar := sar_v + af * (ep - sar_v)
n_sar := math.max(math.max(src_h[1], src_h[2]), n_sar)
if n_sar < src_h
trend := 1
n_sar := ep
ep := src_h
af := _start
sar_v := n_sar
[sar_v, trend]
[sar_hizli, tr_hizli] = f_ozel_sar(high, low, h_start, h_inc, h_max, ta.change(time("D")) != 0)
[sar_yavas, tr_yavas] = f_ozel_sar(high, low, y_start, y_inc, y_max, ta.change(time("D")) != 0)
color col_ana = kral_yon ? color.lime : color.red
bool ahenk_boga = (tr_hizli > 0) and (tr_yavas > 0)
bool ahenk_ayi = (tr_hizli < 0) and (tr_yavas < 0)
// Motor A'nύn Mum Boyamasύ (Pine Script kurallarύ gereπi Motor B tarafύndan ezilecektir, koda dokunulmadύ)
barcolor(ahenk_boga ? color.lime : ahenk_ayi ? color.red : color.new(color.yellow, 00))
float cloudTop = math.max(trail, aktif_zirh)
float cloudBot = math.min(trail, aktif_zirh)
bool touchesCloud = (low <= cloudTop and high >= cloudBot)
bool touchedCloudRecently = touchesCloud or touchesCloud[1] or touchesCloud[2]
bool yyBullTrigger = ahenk_boga and not ahenk_boga[1] and touchedCloudRecently
bool yyBearTrigger = ahenk_ayi and not ahenk_ayi[1] and touchedCloudRecently
// ═════════════════════════════════════════════════════════════════════════
// BΦLάM 3: MOTOR B - 7 KATMANLI FRAKTAL ALMA/HMA MATRέSέ (YENέ SέSTEM)
// ═════════════════════════════════════════════════════════════════════════
src = hlc3
f_titan_dalga(_f, _s) =>
kilic = ta.hma(src, _f)
zirh = ta.alma(src, _s, 0.85, 6)
kilic - zirh
ao1 = f_titan_dalga(2, 56)
ao2 = f_titan_dalga(3, 58)
ao3 = f_titan_dalga(5, 60)
ao4 = f_titan_dalga(8, 63)
ao5 = f_titan_dalga(13, 68)
ao6 = f_titan_dalga(21, 76)
ao7 = f_titan_dalga(34, 89)
master_wave = (ao1 + ao2 + ao3 + ao4 + ao5 + ao6 + ao7) / 7
hepsi_yukari = (ao1 > ao1[1]) and (ao2 > ao2[1]) and (ao3 > ao3[1]) and (ao4 > ao4[1]) and (ao5 > ao5[1]) and (ao6 > ao6[1]) and (ao7 > ao7[1])
hepsi_asagi = (ao1 < ao1[1]) and (ao2 < ao2[1]) and (ao3 < ao3[1]) and (ao4 < ao4[1]) and (ao5 < ao5[1]) and (ao6 < ao6[1]) and (ao7 < ao7[1])
bool guclu_boga = master_wave > 0 and master_wave > master_wave[1]
bool yorulan_boga = master_wave > 0 and master_wave <= master_wave[1]
bool guclu_ayi = master_wave < 0 and master_wave < master_wave[1]
bool yorulan_ayi = master_wave < 0 and master_wave >= master_wave[1]
color dalga_rengi = guclu_boga ? color.new(#00ffaa, 0) : yorulan_boga ? color.new(#0530f2, 0) : guclu_ayi ? color.new(#ff0055, 0) : yorulan_ayi ? color.new(#eded04, 0) : color.gray
// Motor B'nin Mum Boyamasύ (Grafikte bu renkler geηerli olacaktύr)
barcolor(dalga_rengi)
var int kilit_durumu = 0
bool al_tetik = false
bool sat_tetik = false
if hepsi_yukari and kilit_durumu != 1
al_tetik := true
kilit_durumu := 1
if hepsi_asagi and kilit_durumu != -1
sat_tetik := true
kilit_durumu := -1
// ═════════════════════════════════════════════════════════════════════════
// BΦLάM 4: TάM MOTORLARIN EKRANA ΗέZέMέ (VέSUALIZATION)
// ═════════════════════════════════════════════════════════════════════════
// Motor A Ηizimleri
p_mats = plot(aktif_zirh, title="0", color=color.new(col_ana, 100), linewidth=1)
p_trail = plot(trail, title="1", color=color.new(col_ana, 100), linewidth=1)
fill(p_mats, p_trail, color=color.new(col_ana, 65), title="Adaptif Zύrh Bulutu")
plot(hhma_val, "@yφrόk@", color=col_yoruk, style=plot.style_line, linewidth=1)
plotshape(yyBullTrigger, title="Ahenk Boπa Tetiπi", style=shape.triangleup, location=location.belowbar, color=#00d4ff, size=size.small)
plotshape(yyBearTrigger, title="Ahenk Ayύ Tetiπi", style=shape.triangledown, location=location.abovebar, color=#ff2d78, size=size.small)
// Motor B Ηizimleri
omurga = ta.alma(src, 55, 0.85, 6)
plot(omurga, "Tr", color=color.new(dalga_rengi, 20), linewidth=2)
plotshape(al_tetik, "Tam Ahenk (AL)", style=shape.triangleup, location=location.belowbar, color=#00ffaa, size=size.small, text="L", textcolor=#00ffaa)
plotshape(sat_tetik, "Tam Ahenk (SAT)", style=shape.triangledown, location=location.abovebar, color=#ff0055, size=size.small, text="S", textcolor=#ff0055)
// Ortak έmzalar ve Alarmlar
var table ytd_table = table.new(position.bottom_center, 1, 1)
if barstate.islast
table.cell(ytd_table, 0, 0, "(Aέ) Eπitim ηalύώmasύdύr. Yatύrύm tavsiyesi KULLANILAMAZ.", text_color=color.new(color.white, 00), text_size=size.normal)
alertcondition(yyBullTrigger, "Titan AL Onayύ!", "Yφrόk: Fiyat Kalkan'dan sekti, Hiperbolik Kύlύη kesiώti ve Ahenk saπlandύ.")
alertcondition(yyBearTrigger, "Titan SAT Onayύ!", "Yφrόk: Fiyat Kalkan'dan sekti, Hiperbolik Kύlύη kesiώti ve Ahenk saπlandύ.")
alertcondition(al_tetik, "Keskin Niώancύ: AL!", "Yφrόk: 7 Katmanlύ Ahenk BOΠA yφnόnde kilitlendi. Tetiπi ηek!")
alertcondition(sat_tetik, "Keskin Niώancύ: SAT!", "Yφrόk: 7 Katmanlύ Ahenk AYI yφnόnde kilitlendi. Tetiπi ηek!")
Yer έmleri