PHP Code:
//@version=6
indicator("Yörük [3'lü ICS Bulutu: 13-21-34]", shorttitle=".", overlay=true, max_lines_count=20, max_bars_back=500)
// ─────────────────────────────────────────────────────────────────
// 1. SABÝTLER VE GÝRDÝLER
// ─────────────────────────────────────────────────────────────────
const float MIN_SIGMA = 1e-10
const float PI = math.pi
color i_fillUp = input.color(#26a69a, "Yükseliþ Bulutu")
color i_fillDn = input.color(#ef5350, "Düþüþ Bulutu")
color i_fillRng = input.color(#888888, "Yatay Bulut")
int i_fillTr = input.int(85, "Bulut Þeffaflýðý", minval = 0, maxval = 100)
// ─────────────────────────────────────────────────────────────────
// 2. ÝZOTROPÝK KOORDÝNAT SÝSTEMÝ (ICS) MATEMATÝÐÝ
// ─────────────────────────────────────────────────────────────────
f_icsLine(float p1, int x1, float p2, int x2, int targetX, float sig) =>
float out = p1
if x1 != x2 and p1 > 0 and p2 > 0 and sig > MIN_SIGMA
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(float p1, int x1, float p2, int x2, float sig) =>
float out = 0.0
if x1 != x2 and p1 > 0 and p2 > 0 and sig > MIN_SIGMA
float y1 = math.log(p1) / sig
float y2 = math.log(p2) / sig
out := math.atan((y2 - y1) / (x2 - x1)) * 180.0 / PI
out
// ─────────────────────────────────────────────────────────────────
// 3. YANG-ZHANG VOLATÝLÝTE (σ) MANTIÐI
// ─────────────────────────────────────────────────────────────────
int i_sigmaLen = 20
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, i_sigmaLen)
float _sqCO = ta.variance(_yzCO, i_sigmaLen)
float _sqRS = ta.sma(_yzHO * _yzHC + _yzLO * _yzLC, i_sigmaLen)
float _k = 0.34 / (1.34 + (i_sigmaLen + 1.0) / math.max(i_sigmaLen - 1.0, 1.0))
float _sq = nz(_sqOR) + _k * nz(_sqCO) + (1.0 - _k) * nz(_sqRS)
float sigma = math.max(math.sqrt(math.max(_sq, 0.0)), MIN_SIGMA)
// ─────────────────────────────────────────────────────────────────
// 4. 13-21-34 PERÝYOTLARI ÝÇÝN GEÇMÝÞ BLOK VERÝLERÝ
// ─────────────────────────────────────────────────────────────────
float hh13 = ta.highest(high, 13)
float ll13 = ta.lowest(low, 13)
float hh21 = ta.highest(high, 21)
float ll21 = ta.lowest(low, 21)
float hh34 = ta.highest(high, 34)
float ll34 = ta.lowest(low, 34)
max_bars_back(hh13, 500)
max_bars_back(ll13, 500)
max_bars_back(hh21, 500)
max_bars_back(ll21, 500)
max_bars_back(hh34, 500)
max_bars_back(ll34, 500)
// ─────────────────────────────────────────────────────────────────
// 5. ÇOKLU BULUT ÇÝZÝM MOTORU (NESNE YÖNELÝMLÝ YAPI)
// ─────────────────────────────────────────────────────────────────
type CloudDrawing
line upLn
line loLn
line upPj
line loPj
linefill chFill
linefill pjFill
method updateCloud(CloudDrawing this, int P, series float hhS, series float llS, float sig, color cUp, color cDn, color cRng, int transp) =>
int groups = 5
float thresh = 0.5
int pjOff = 34 // Ýleri Projeksiyon 34 Mum olarak sabitlendi
bool _ok = bar_index >= groups * P
if barstate.islastconfirmedhistory or barstate.islast
line.delete(this.upLn)
line.delete(this.loLn)
line.delete(this.upPj)
line.delete(this.loPj)
linefill.delete(this.chFill)
linefill.delete(this.pjFill)
array<float> _bGm = array.new<float>()
array<float> _bHi = array.new<float>()
array<float> _bLo = array.new<float>()
array<int> _bCx = array.new<int>()
if _ok
for i = 0 to groups - 1
int off = i * P
float hi = hhS[off]
float lo = llS[off]
_bGm.push((hi > 0 and lo > 0) ? math.exp((math.log(hi) + math.log(lo)) / 2.0) : na)
_bHi.push(hi)
_bLo.push(lo)
_bCx.push(bar_index - off - int(P / 2))
int _dir = 0
float _ang = 0.0
int _seg = 0
if _bGm.size() >= 2
float g0 = _bGm.get(0)
float g1 = _bGm.get(1)
if not na(g0) and not na(g1) and g0 != g1
int pd = g0 > g1 ? 1 : -1
_seg := 1
if groups > 2
for i = 1 to groups - 2
float a = _bGm.get(i)
float b = _bGm.get(i + 1)
if not na(a) and not na(b)
if (a > b ? 1 : (a < b ? -1 : 0)) == pd
_seg := i + 1
else
break
else
break
if _bGm.size() > _seg
_ang := f_icsAngle(_bGm.get(_seg), _bCx.get(_seg), _bGm.get(0), _bCx.get(0), sig)
_dir := math.abs(_ang) <= thresh ? 0 : pd
if _seg >= 1 and _bHi.size() > _seg
float fHH = na, float fLH = na, float fHL = na, float fLL = na
int xHH = na, int xLH = na, int xHL = na, int xLL = na
for i = 0 to _seg
float h = _bHi.get(i)
float l = _bLo.get(i)
int x = _bCx.get(i)
if na(fHH) or h > fHH
fHH := h, xHH := x
if na(fLH) or h < fLH
fLH := h, xLH := x
if na(fHL) or l > fHL
fHL := l, xHL := x
if na(fLL) or l < fLL
fLL := l, xLL := x
int sLx = _bCx.get(_seg)
int sRx = _bCx.get(0)
float uY1 = na, float uY2 = na, float lY1 = na, float lY2 = na
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)
else
uY1 := nz(fHH), uY2 := nz(fHH)
lY1 := nz(fLL), lY2 := nz(fLL)
int ax = bar_index
float uYa = f_icsLine(uY1, sLx, uY2, sRx, ax, sig)
float lYa = f_icsLine(lY1, sLx, lY2, sRx, ax, sig)
this.upLn := line.new(sLx, uY1, ax, uYa, color = na)
this.loLn := line.new(sLx, lY1, ax, lYa, color = na)
int eX = ax + pjOff
float uYe = f_icsLine(uY1, sLx, uY2, sRx, eX, sig)
float lYe = f_icsLine(lY1, sLx, lY2, sRx, eX, sig)
this.upPj := line.new(ax, uYa, eX, uYe, color = na)
this.loPj := line.new(ax, lYa, eX, lYe, color = na)
color baseColor = _dir == 1 ? cUp : _dir == -1 ? cDn : cRng
color fc = color.new(baseColor, transp)
this.chFill := linefill.new(this.upLn, this.loLn, fc)
this.pjFill := linefill.new(this.upPj, this.loPj, fc)
// ─────────────────────────────────────────────────────────────────
// 6. BULUTLARI BAÞLAT VE GÜNCELLE
// ─────────────────────────────────────────────────────────────────
var c13 = CloudDrawing.new(na, na, na, na, na, na)
var c21 = CloudDrawing.new(na, na, na, na, na, na)
var c34 = CloudDrawing.new(na, na, na, na, na, na)
// Fiyata eþ zamanlý olarak 3 ayrý katmanda iþleniyor
c13.updateCloud(13, hh13, ll13, sigma, i_fillUp, i_fillDn, i_fillRng, i_fillTr)
c21.updateCloud(21, hh21, ll21, sigma, i_fillUp, i_fillDn, i_fillRng, i_fillTr)
c34.updateCloud(34, hh34, ll34, sigma, i_fillUp, i_fillDn, i_fillRng, i_fillTr)
///////////////////
// ─────────────────────────────────────────────────────────────────
// 1. 5'LÝ SAR MOTORU
// ─────────────────────────────────────────────────────────────────
roSarSlow = ta.sar(0.01, 0.001, 0.02)
roSarModerate = ta.sar(0.01, 0.002, 0.02)
roSarFast = ta.sar(0.01, 0.003, 0.02)
roSarFast2 = ta.sar(0.01, 0.00001, 0.02)
roSarFast23 = ta.sar(0.001, 0.00001, 0.02)
// SAR Seviyeleri
plot(roSarSlow, "SAR Yavaþ", color=color.new(color.blue, 0), linewidth=1, style=plot.style_cross)
plot(roSarModerate, "SAR Orta", color=color.new(color.green, 0), linewidth=1, style=plot.style_cross)
plot(roSarFast, "SAR Hýzlý", color=color.new(color.red, 0), linewidth=1, style=plot.style_cross)
plot(roSarFast2, "SAR Trend", color=color.new(color.yellow, 0), linewidth=1, style=plot.style_cross)
plot(roSarFast23, "SAR Yörük", color=color.new(color.fuchsia, 0), linewidth=1, style=plot.style_cross)
// ─────────────────────────────────────────────────────────────────
// 2. MATEMATÝKSEL ÇAKIÞMA KONTROLÜ (5'in 3'lü Kombinasyonlarý)
// ─────────────────────────────────────────────────────────────────
// Float (Küsürat) hassasiyeti için 1 tik yanýlma payý
isEq(v1, v2) => math.abs(v1 - v2) <= syminfo.mintick
// 3 Deðerin de birbirine eþit olma durumu
isEq3(v1, v2, v3) => isEq(v1, v2) and isEq(v1, v3)
s1 = roSarSlow
s2 = roSarModerate
s3 = roSarFast
s4 = roSarFast2
s5 = roSarFast23
// 10 Olasý 3'lü Çakýþma Senaryosu (Kombinasyon C(5,3) = 10)
c1 = isEq3(s1, s2, s3)
c2 = isEq3(s1, s2, s4)
c3 = isEq3(s1, s2, s5)
c4 = isEq3(s1, s3, s4)
c5 = isEq3(s1, s3, s5)
c6 = isEq3(s1, s4, s5)
c7 = isEq3(s2, s3, s4)
c8 = isEq3(s2, s3, s5)
c9 = isEq3(s2, s4, s5)
c10 = isEq3(s3, s4, s5)
// Herhangi bir 3'lü çakýþma var mý?
any3 = c1 or c2 or c3 or c4 or c5 or c6 or c7 or c8 or c9 or c10
// Çakýþan deðeri bul (Elmasý ekranda tam olarak o fiyata basabilmek için)
float matchVal = na
if c1 or c2 or c3 or c4 or c5 or c6
matchVal := s1
else if c7 or c8 or c9
matchVal := s2
else if c10
matchVal := s3
// Sinyali, çakýþmanýn gerçekleþtiði ve yeni baþladýðý barda tetikle
trigger = any3 and not any3[1]
// ─────────────────────────────────────────────────────────────────
// 3. GÖRSELLEÞTÝRME VE ALARM
// ─────────────────────────────────────────────────────────────────
// Çakýþma anýnda fiyat çakýþma noktasýnýn üstündeyse Destek (Yeþil), altýndaysa Direnç (Kýrmýzý)
isSupport = close > matchVal
diamondColor = isSupport ? color.green : color.red
// Sinyal (Elmas)
plotshape(trigger ? matchVal : na, "3'lü Çakýþma Sinyali", shape.diamond, location.absolute, color=diamondColor, size=size.small)
// Alarmlar
alertcondition(trigger and isSupport, "Çakýþma: Destek", "5 SAR'dan 3'ü çakýþtý. Fiyat üstte, YEÞÝL (Destek) elmas oluþtu.")
alertcondition(trigger and not isSupport, "Çakýþma: Direnç", "5 SAR'dan 3'ü çakýþtý. Fiyat altta, KIRMIZI (Direnç) elmas oluþtu.")
//////////////
// ─────────────────────────────────────────────────────────────────
// 1. GÝRDÝLER
// ─────────────────────────────────────────────────────────────────
volLength = input.int(20, "Oynaklýk Uzunluðu", minval = 5)
projBars = input.int(5, "Ýleriye Projeksiyon (Mum Yakýnlýðý)", minval = 1)
barsPerYear = input.int(50, "Yýllýk Mum Çarpaný", minval = 10)
// ─────────────────────────────────────────────────────────────────
// 2. YÖN TAYÝNÝ (0.02 - 0.02 - 0.2 SAR)
// ─────────────────────────────────────────────────────────────────
// Belirttiðiniz deðerlerle klasik SAR motoru
hedefSar = ta.sar(0.02, 0.02, 0.2)
isLong = close > hedefSar
// SAR'ý grafikte göster (yönü teyit etmek için þeffaf bir haç olarak)
plot(hedefSar, "SAR", color=isLong ? color.new(color.white, 00) : color.new(color.white, 0), style=plot.style_cross, linewidth=1)
// ─────────────────────────────────────────────────────────────────
// 3. ÝSTATÝSTÝKSEL VOLATÝLÝTE (%68) VE HEDEFLER
// ─────────────────────────────────────────────────────────────────
// Logaritmik getiri ve volatilite hesaplamasý
logReturn = math.log(close / nz(close[1], close))
rawVol = ta.stdev(logReturn, volLength)
annualVol = rawVol * math.sqrt(barsPerYear)
// Koni formülü (Belirli bir zaman t sonrasýndaki tahmini sapma)
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>()
var line[] sigmaLines = array.new<line>()
// Sadece aktif (son) barda projeksiyonu hesapla ve çiz
if barstate.islast
// Eski etiket ve çizgileri temizle
if sigmaLabels.size() > 0
for i = 0 to sigmaLabels.size() - 1
label.delete(sigmaLabels.get(i))
line.delete(sigmaLines.get(i))
sigmaLabels.clear()
sigmaLines.clear()
// 1 Standart Sapma (%68 olasýlýk) fiyat seviyeleri
float tip1up = conePrice(close, annualVol, projBars, 1.0, 1)
float tip1dn = conePrice(close, annualVol, projBars, 1.0, -1)
int tipX = bar_index + projBars
// SAR Yönüne göre hedef belirle, etiket ve kýlavuz çizgi at
if isLong
sigmaLabels.push(label.new(tipX, tip1up, "(YTD. @yörük@)\n" + str.tostring(tip1up, format.mintick), color=color.new(color.lime, 80), textcolor=color.lime, style=label.style_label_left, size=size.small))
sigmaLines.push(line.new(bar_index, close, tipX, tip1up, color=color.new(color.lime, 50), style=line.style_dotted))
else
sigmaLabels.push(label.new(tipX, tip1dn, "(YTD. @yörük@)\n" + str.tostring(tip1dn, format.mintick), color=color.new(color.red, 80), textcolor=color.red, style=label.style_label_left, size=size.small))
sigmaLines.push(line.new(bar_index, close, tipX, tip1dn, color=color.new(color.red, 50), style=line.style_dotted))
//////////////////
// ─────────────────────────────────────────────────────────────────
// 1. OTONOM ZAMAN DÝLÝMÝ (SABÝT BELLEK KÝLÝDÝ)
// ─────────────────────────────────────────────────────────────────
// Çarpanlar ve Zýrh ana uzunluðu
simple int z_len = switch timeframe.period
"1" => 34
"3" => 21
"5" => 13
"15" => 8
"60" => 5
"240" => 3
=> 2
// ─────────────────────────────────────────────────────────────────
// 2. 7 KATMANLI FRAKTAL MATRÝS (HMA vs ALMA)
// ─────────────────────────────────────────────────────────────────
src = hlc3
// Her katmanda HMA (Kýlýç) ve ALMA (Zýrh) çarpýþýr, aradaki mesafe (Ývme) ölçülür
f_titan_dalga(_f, _s) => ta.hma(src, _f) - ta.alma(src, _s, 0.85, 6)
// Fraktal Fibonacci Katmanlarý
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)
// ─────────────────────────────────────────────────────────────────
// 3. SÜPERPOZÝSYON (MASTER DALGA) VE KÝNETÝK EVRELER
// ─────────────────────────────────────────────────────────────────
// 7 Katmanýn toplam gücü
float master_wave = (ao1 + ao2 + ao3 + ao4 + ao5 + ao6 + ao7) / 7
// Master Dalga'nýn 4 Kinetik Evresi
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]
// Kinetik Renk Paleti (Mumlar için)
color dalga_rengi = guclu_boga ? color.new(#00ffaa, 0) : yorulan_boga ? color.new(#eafa03, 0) : guclu_ayi ? color.new(#ff0055, 0) : yorulan_ayi ? color.new(#c604ed, 0) : color.gray
// ─────────────────────────────────────────────────────────────────
// 4. FÝYATA PROJEKSÝYON (MUM BOYAMA VE OMURGA)
// ─────────────────────────────────────────────────────────────────
// Bütün zekâyý mumlarýn gövdesine aktarýyoruz
barcolor(dalga_rengi)
// Fiyatýn ortasýndan geçen referans Gauss Zýrhý (Trendi görsel tutmak için)
omurga = ta.alma(src, 55, 0.85, 6)
//plot(omurga, "Yörük", color=color.new(dalga_rengi, 0), linewidth=1)
// ─────────────────────────────────────────────────────────────────
// ─────────────────────────────────────────────────────────────────
h_start = input.float(0.06, "Hýzlý SAR Baþlangýç", step=0.01, group="Yin-Yang SAR")
h_inc = input.float(0.06, "Hýzlý SAR Ývme", step=0.01, group="Yin-Yang SAR")
h_max = input.float(0.30, "Hýzlý SAR Max", step=0.1, group="Yin-Yang SAR")
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]
yeni_gun = ta.change(time("D")) != 0
[sar_hizli, trend_hizli] = f_ozel_sar(high, low, h_start, h_inc, h_max, yeni_gun)
ayna_hizli = trend_hizli > 0 ? close + math.abs(close - sar_hizli) : close - math.abs(close - sar_hizli)
// 3. Trend Çizgisi (Hýzlý Ayna)
color col_hizli = (ayna_hizli > close) ? color.lime : color.red
plot(ayna_hizli, title="Ayna", color=col_hizli, style=plot.style_line, linewidth=1)
///////////////////
Yer Ýmleri