Untitled
Anonymous
Plain Text
11/28/2026 6:30 PM
165.7 KB
11
Indexable
Never
//@version=6
//@strategy_alert_message {{strategy.order.alert_message}}
// =============================================================================
// 👑 CLIMAX & OSMANLI MENKUL OTOMATİK STRATEJİ v2
// Orijinal Climax v11 göstergesinin ALARM SEÇ menüsündeki sinyallerle birebir çalışır.
// • Coin / Kripto → Mod 2: 1S+4S+G+H (0/PDA güçlü alanlar) : LONG + SHORT
// • BIST Hisse → Mod 4: 1S FORGE (SHORT) + CRUCIBLE 0 (LONG)
// Giriş : Seçili alarm modunun LONG / SHORT sinyali geldiği anda (bar kapanışında).
// Çıkış : (1) TP1 (2) Zıt alan (LONG'da Iron Floor/FORGE, SHORT'ta Climax/CRUCIBLE) (3) Stop
// Stop/TP seviyeleri sinyali üreten zaman diliminin kendi climax bandından alınır.
// =============================================================================
strategy("Climax Osmanlı Otomatik Strateji v2", shorttitle="Climax Osmanlı v2", overlay=true,
initial_capital=100000, default_qty_type=strategy.cash, default_qty_value=100000,
currency=currency.NONE, max_bars_back=5000, max_labels_count=500, max_lines_count=500, max_boxes_count=500,
pyramiding=0, calc_on_every_tick=false, process_orders_on_close=true,
margin_long=0, margin_short=0)
// =============================================================================
// 📈 PİYASA VE ENSTRÜMAN ALGILAMA
// =============================================================================
bool isBistDetected = str.contains(syminfo.prefix, "BIST") or str.endswith(syminfo.ticker, ".IS") or str.contains(syminfo.ticker, "XU100") or str.contains(syminfo.ticker, "XU030")
bool isCryptoDetected = not isBistDetected and (syminfo.type == "crypto" or
str.endswith(syminfo.ticker, "USDT") or str.endswith(syminfo.ticker, "USDT.P") or
str.endswith(syminfo.ticker, "USD") or str.endswith(syminfo.ticker, "PERP") or
str.endswith(syminfo.ticker, "BTC") or str.endswith(syminfo.ticker, "ETH") or
str.contains(syminfo.prefix, "BINANCE") or str.contains(syminfo.prefix, "BYBIT") or
str.contains(syminfo.prefix, "OKX") or str.contains(syminfo.prefix, "COINBASE") or
str.contains(syminfo.prefix, "KUCOIN"))
// =============================================================================
// ▶ ALARM VE İŞLEM MODU SEÇİMİ (orijinal Climax menüsüyle aynı numaralar)
// =============================================================================
grp_mode = "▶ ALARM VE İŞLEM MODU SEÇİMİ"
string paMode = input.string("Otomatik (Coin=Mod 2, BIST=Mod 4) [Önerilen]", "▶ ALARM SEÇ",
options=[
"Otomatik (Coin=Mod 2, BIST=Mod 4) [Önerilen]",
"2: 1S+4S+G+H (0/PDA güçlü) [Coin / Kripto]",
"4: 1S FORGE (SHORT) + CRUCIBLE 0 (LONG) [BIST Hisse]",
"1: 15dk+30dk+1S (0/PDA güçlü)",
"3: 1S CRUCIBLE 0 çizgisi (LONG)",
"Kutular (Sadece grafik zaman dilimindeki Climax Dip & Iron Floor kutuları)"
],
group=grp_mode,
tooltip="• Otomatik: Kriptoda Mod 2, BIST (ve diğer hisselerde) Mod 4 çalışır.\n• 2: 1S+4S+Günlük+Haftalık güçlü alanlar (LONG + SHORT) → Coin.\n• 4: 1S FORGE (SHORT) + 1S CRUCIBLE 0 çizgisi (LONG) → BIST.\n• Kutular: Sadece grafikteki Dip (Furnace) / Iron Floor kutusu başlangıcında işlem açar.\n\nÖNEMLİ: Mod 1/3/4 için grafik zaman dilimi 1S veya daha küçük olmalı (önerilen: 1S).")
bool mod4IncludeDip = input.bool(true, "Mod 4: 1S Dip Climax'ı da LONG sinyaline dahil et", group=grp_mode, tooltip="Açıkken (önerilen): Destek kalesi (Anvil) henüz onaylanmamış olsa bile 1S Dip Climax oluştuğunda LONG pozisyon açar. Böylece BIST hisselerinde dip fırsatları kaçmaz. Kapalıyken: Sadece Anvil ∩ Climax (Crucible) ile açar.")
bool isAutoMode = str.startswith(paMode, "Otomatik")
int paN = isAutoMode ? (isCryptoDetected ? 2 : 4) : str.startswith(paMode, "1:") ? 1 : str.startswith(paMode, "2:") ? 2 : str.startswith(paMode, "3:") ? 3 : str.startswith(paMode, "4:") ? 4 : 0
// =============================================================================
// 🎯 KÂR AL (TP1) VE STOP LOSS AYARLARI
// =============================================================================
grp_sl_tp = "🎯 Kâr Al (TP1) ve Stop Loss Ayarları"
tpSourceChoice = input.string("Climax Dinamik Seviyesi (cTP1 / xTP1) [Önerilen]", "TP Kaynağı",
options=["Climax Dinamik Seviyesi (cTP1 / xTP1) [Önerilen]", "Kapalı (Sadece Iron Floor / Furnace ile Çık)"], group=grp_sl_tp,
tooltip="Climax Dinamik Seviyesi: Sinyali üreten zaman diliminin TP1 seviyesine emir (limit) konur, fiyat değince kâr alınır.\nKapalı: Sadece zıt alan veya stop ile çıkılır.")
slSourceChoice = input.string("Bölge Tabanı Kapanış Kırılımı (Kapanış < bandBot) [Önerilen]", "Stop Loss Kaynağı",
options=[
"Bölge Tabanı Kapanış Kırılımı (Kapanış < bandBot) [Önerilen]",
"ATR Paylı Fitil Kırılımı (bandBot - 1 ATR)",
"Kapalı (Stop Yok)"
],
group=grp_sl_tp,
tooltip="• Kapanış Kırılımı: Mum, sinyal bandının dışında KAPANIRSA bar kapanışında çıkılır (LONG: bandın altı, SHORT: bandın üstü).\n• ATR Paylı: Band sınırının 1 ATR ötesine fitil değince stop emri tetiklenir.\n• Kapalı: Stop yok.")
fbSlPct = input.float(2.0, "Yedek Stop % (band seviyesi geçersizse)", minval=0.1, step=0.1, group=grp_sl_tp, tooltip="Sinyal bandından geçerli stop seviyesi çıkarılamazsa giriş fiyatından bu yüzde kadar uzağa stop konur.")
fbTpPct = input.float(2.0, "Yedek TP % (TP1 geçersizse, 0 = kapalı)", minval=0.0, step=0.1, group=grp_sl_tp, tooltip="TP1 hesaplanamazsa veya fiyatın yanlış tarafında kalırsa giriş fiyatından bu yüzde kadar uzağa hedef konur. 0 yazarsan yedek hedef kullanılmaz.")
levelTfPref = input.string("En yüksek TF", "Aynı barda birden çok TF tetiklerse Stop/TP kaynağı", options=["En yüksek TF", "En düşük TF"], group=grp_sl_tp)
// =============================================================================
// ⚙️ STRATEJİ AYARLARI
// =============================================================================
grp_strat = "⚙️ Strateji Ayarları"
strategyType = input.string("BOTH", "Strateji Türü", options=["BOTH", "LONG", "SHORT"], group=grp_strat, tooltip="BOTH: Çift yönlü.\nLONG: Sadece alış (Spot BIST için önerilir).\nSHORT: Sadece satış (Vadeli).")
exitOnIronFloor = input.bool(true, "LONG'da Iron Floor / FORGE gelince kapat (kâr al)", group=grp_strat, tooltip="LONG pozisyondayken yeni Iron Floor / FORGE (SHORT) alanı oluşursa pozisyon kapatılır.")
exitOnClimaxDip = input.bool(true, "SHORT'ta Climax Dip / CRUCIBLE gelince kapat (kâr al)", group=grp_strat, tooltip="SHORT pozisyondayken yeni Climax Dip / CRUCIBLE (LONG) alanı oluşursa pozisyon kapatılır.")
exitUseChartBoxes = input.bool(true, "Çıkışta grafik zaman dilimindeki Iron Floor / Climax kutusu başlangıcını da say", group=grp_strat)
sendInfoAlerts = input.bool(false, "Bilgi amaçlı alert() metinlerini de gönder (WEBHOOK'U BOZAR, kapalı kalsın)", group=grp_strat, tooltip="Orijinal göstergedeki uzun metin alert()'leri strateji alarmında webhook'a JSON dışı metin yollar. Osmanlı botuna giden alarmda KAPALI olmalı.")
// =============================================================================
// 🏷️ SEMBOL VE WEBHOOK AYARLARI (OSMANLI MENKUL)
// =============================================================================
grp_symbol = "🏷️ Sembol ve Webhook Ayarları"
overrideSymbol = input.bool(false, "Farklı Sembole Emir İlet", group=grp_symbol)
customSymbol = input.string("", "Sembol Kodu", group=grp_symbol, tooltip="Boş bırakılırsa grafikteki sembol kodu kullanılır.")
webhookBaseCash = input.float(100000.0, "Emir Tutarı (TL / USDT)", minval=1.0, group=grp_symbol, tooltip="Her girişte kullanılacak tutar. Lot = tutar / fiyat (BIST'te aşağı yuvarlanır). Strateji testi de aynı miktarı kullanır.")
// =============================================================================
// 🎨 GÖRÜNÜM AYARLARI
// =============================================================================
grp_view = "🎨 Görünüm Ayarları"
enableCandleColoring = input.bool(true, "Akıllı Mum Renklendirme (plotcandle)", group=grp_view, tooltip="Long = Yeşil, Short = Kırmızı, Pozisyon Yok = Doğal Mum Renkleri.")
showInfoCard = input.bool(true, "Pozisyon Durum Kartını Göster", group=grp_view)
infoCardPos = input.string("Sağ Alt", "Kart Pozisyonu", options=["Sağ Üst", "Sağ Alt", "Sol Üst", "Sol Alt"], group=grp_view)
// ═══════════════════════════════════════════════════════════════════
// HİBRİT: Climax Alanı (DİP + TEPE) + Ayna + Alt TF Mum
// ═══════════════════════════════════════════════════════════════════
// ───────────── 1. AYNA ─────────────
string grpAyna = "1. Ayna (0 Çizgisi + PDA)"
int aynaLen = input.int(10, "Pivot uzunluğu", minval=2, group=grpAyna)
string aynaBrkMode = input.string("Kapanış", "Kırılım", options=["Kapanış","Fitil"], group=grpAyna)
bool showAyna = input.bool(true, "0 çizgisi (dip yapısı)", group=grpAyna)
bool showPDA = input.bool(true, "PDA bantları (dip yapısı)", group=grpAyna)
bool showAynaTop = input.bool(true, "Tepe yapısını da çiz (ters Ayna)", group=grpAyna)
int aynaExt = input.int(20, "Sağa uzatma (bar)", minval=5, group=grpAyna)
float aynaMinDrop = input.float(6.0, "Min hareket % (tepe↔dip)", minval=0.0, step=0.5, group=grpAyna)
float pdaWidth = input.float(0.067, "PDA genişliği", minval=0.01, step=0.01, group=grpAyna)
color zeroColor = input.color(color.new(#FFFFFF, 0), "0 Çizgisi rengi", group=grpAyna)
color pda214Col = input.color(color.new(#D946EF, 70), "PDA-214 bant", group=grpAyna)
color pda1Col = input.color(color.new(#A855F7, 70), "PDA-1 bant", group=grpAyna)
color pda2Col = input.color(color.new(#F97316, 70), "PDA-2 bant", group=grpAyna)
// ───────────── 2. CLIMAX ─────────────
string grpClimax = "2. Climax Alanı"
int lenA = input.int(14, "Hesap uzunluğu", minval=2, group=grpClimax)
int fibPiv = input.int(5, "Pivot uzunluğu", minval=2, group=grpClimax)
float fibMinRange = input.float(10.0, "Min swing", minval=1.0, group=grpClimax)
float fibTol = input.float(3.5, "Seviye toleransı (±)", minval=0.1, step=0.1, group=grpClimax)
int fibMaxAge = input.int(80, "Max yaş (bar)", minval=5, group=grpClimax)
bool showClimax = input.bool(true, "DİP climax kutusunu göster (sadece son)", group=grpClimax)
bool showClimaxT = input.bool(true, "Iron Floor (tepe) kutusunu göster (sadece son)", group=grpClimax)
int bandPad = input.int(10, "Bant uzatma (bar)", minval=0, group=grpClimax)
float bandMinAtr = input.float(0.3, "Min bant kalınlığı (ATR)", minval=0.0, step=0.1, group=grpClimax)
float bandDownAtr = input.float(0.6, "Dışa sarkma (ATR)", minval=0.0, step=0.1, group=grpClimax)
color climaxCol = input.color(color.new(#7C3AED, 82), "Dip normal dolgu", group=grpClimax)
color climaxBord = input.color(color.new(#7C3AED, 40), "Dip normal kenar", group=grpClimax)
color strongCol = input.color(color.new(#22C55E, 75), "Dip GÜÇLÜ dolgu", group=grpClimax)
color strongBord = input.color(color.new(#16A34A, 20), "Dip GÜÇLÜ kenar", group=grpClimax)
color climaxColT = input.color(color.new(#F59E0B, 82), "Tepe normal dolgu", group=grpClimax)
color climaxBordT = input.color(color.new(#F59E0B, 40), "Tepe normal kenar", group=grpClimax)
color strongColT = input.color(color.new(#EF4444, 75), "Tepe GÜÇLÜ dolgu", group=grpClimax)
color strongBordT = input.color(color.new(#DC2626, 20), "Tepe GÜÇLÜ kenar", group=grpClimax)
bool showTP = input.bool(true, "TP1 çizgisi", group=grpClimax)
int tpShowBars = input.int(40, "TP gösterim süresi", minval=5, group=grpClimax)
string tpMode = input.string("Dinamik → Fiyat", "TP yöntemi", options=["Dinamik → Fiyat","Fiyat fibosu"], group=grpClimax)
color tpColor = input.color(#10B981, "Dip TP rengi", group=grpClimax)
color tpColorT = input.color(#F43F5E, "Tepe TP rengi", group=grpClimax)
bool earlyMode = input.bool(true, "ERKEN MOD: bölgeye girer girmez kutu + alert (onay beklemeden)", group=grpClimax, tooltip="Açıkken: fiyat climax bölgesine girdiği İLK barda kutu çizilir ve alert gelir (bant içindeyken). Kapalıyken: eski davranış, onay sonrası.")
bool alertLate = input.bool(false, "Erken modda ayrıca geç ONAY alert'i de ver", group=grpClimax)
int earlyGap = input.int(5, "Erken alert'ler arası min. bar", minval=1, group=grpClimax, tooltip="Aynı bölgede tekrar tekrar alert gelmesini önler.")
// ───────────── 3. ALT TF MUM ─────────────
string grpCandle = "3. Alt TF Mum Analizi (4 Mum)"
bool showCandle = input.bool(true, "Mumları göster", group=grpCandle)
bool twoCandles = input.bool(true, "Her TF için önceki+son (toplam 4 mum)", group=grpCandle)
int candleGapR = input.int(8, "Uzatma çizgilerinden sonra boşluk (bar)", minval=2, group=grpCandle, tooltip="Mumlar, 0 çizgisi / PDA bantları / TP1 çizgisinin bittiği yerden bu kadar bar sağda başlar; böylece diğer çizimlerle karışmaz.")
int candleBase = math.max(aynaExt, 45) + candleGapR // Altın Cep / POC çizgileri 45 bar uzar: mumlar onların bittiği yerden sonra başlasın
int candleW = input.int(5, "Mum genişliği", minval=2, maxval=20, group=grpCandle)
int pairGap = input.int(2, "Önceki-son arası boşluk", minval=1, group=grpCandle)
int candleGap = input.int(28, "İki TF arası boşluk", minval=6, group=grpCandle)
float candleHAtr = input.float(3.5, "Büyütülmüş yükseklik (ATR)", minval=1.0, step=0.5, group=grpCandle)
string candlePos = input.string("Üstte (büyütülmüş)", "Konum", options=["Üstte (büyütülmüş)","Fiyat seviyesinde"], group=grpCandle)
color candleUpCol = input.color(#06B6D4, "Yükselen", group=grpCandle)
color candleDnCol = input.color(#F97316, "Düşen", group=grpCandle)
bool showCandleTbl= input.bool(true, "Mum tablosu", group=grpCandle)
string cTblPosStr = input.string("Sol Alt", "Tablo konumu", options=["Sağ Üst","Sağ Alt","Sol Üst","Sol Alt","Orta Sağ"], group=grpCandle)
// ───────────── 4. GÜÇLÜ CLİMAX ─────────────
string grpStrong = "4. Güçlü Climax"
bool strongOn = input.bool(true, "Güçlü Climax tespiti", group=grpStrong)
float strongTolAtr = input.float(0.8, "0/PDA yakınlık toleransı (ATR x)", minval=0.1, step=0.1, group=grpStrong)
bool labelStrong = input.bool(true, "Climax etiketini göster", group=grpStrong)
// ───────────── 5. MUM FORMASYONLARI (RSN) ─────────────
string grpRsn = "5. Mum Formasyonları (RSN)"
bool rsnOn = input.bool(true, "Mum formasyonu tespitini aç", group=grpRsn)
bool rsnBull = input.bool(true, "Yükseliş formasyonları (Hammer, Engulfing, Morning Star...)", group=grpRsn)
bool rsnBear = input.bool(true, "Düşüş formasyonları (Shooting Star, Evening Star...)", group=grpRsn)
bool rsnIndec = input.bool(false, "Kararsızlık formasyonları (Doji, Topaç...)", group=grpRsn)
bool rsnCont = input.bool(false, "Devam formasyonları (Rising / Falling Three)", group=grpRsn)
string rsnSens = input.string("Orta", "Formasyon hassasiyeti", options=["Düşük","Orta","Yüksek"], group=grpRsn)
float rsnMinBody = input.float(0.1, "Min gövde boyutu (%)", minval=0.01, maxval=1.0, step=0.01, group=grpRsn)
int rsnMinStr = input.int(1, "Gösterilecek min formasyon gücü (1-4)", minval=1, maxval=4, group=grpRsn)
float rsnMult = rsnSens == "Düşük" ? 1.5 : rsnSens == "Yüksek" ? 0.7 : 1.0
// ───────────── 8. ONAY SKORU (Dip / Iron Floor) ─────────────
string grpConf = "8. Onay Skoru (0-5)"
bool confOn = input.bool(true, "Etikette onay skorunu göster", group=grpConf)
int confMin = input.int(0, "Min onay skoru — sadece Alert için (0 = filtre kapalı)", minval=0, maxval=5, group=grpConf, tooltip="Screener'da filtre için skor sütunlarını (17, 18) kullan: örn. >= 4.")
int lrbLen = input.int(20, "Likit bant uzunluğu", minval=5, group=grpConf)
float lrbMult = input.float(2.0, "Likit bant genişliği (σ)", minval=0.5, step=0.1, group=grpConf)
float knifeAng = input.float(20.0, "Şelale / roket koruması açısı (°)", minval=5.0, step=1.0, group=grpConf)
float rvolMin = input.float(1.35, "Min göreceli hacim (RVOL)", minval=0.5, step=0.05, group=grpConf)
int divLen = input.int(10, "Uyumsuzluk pencere (bar)", minval=3, group=grpConf)
// ═══════════════════════════════════════════════════════════════════
// AYNA MOTORU (parametrik: tepe için ters seri verilir)
// ═══════════════════════════════════════════════════════════════════
aynaCore(float hi, float lo, float cl) =>
float ph = ta.pivothigh(hi, aynaLen, aynaLen)
float pl = ta.pivotlow(lo, aynaLen, aynaLen)
float hiNow = ta.highest(hi, aynaLen)
var int aState = 0
var float aHi = na
var int aHiBar = na
var float aLo = na
var float aBounce = na
var bool aMirDone = false
var int dState = 0
var float dHi = na
var int dHiBar = na
var float dLo = na
var float dBounce = na
if not na(ph)
if aState == 0 or ph > aHi or (aState == 3 and aMirDone)
aMirDone := false
aHi := ph
aHiBar := bar_index - aynaLen
aLo := na
aBounce := na
aState := 1
if aState == 2
if hi > aBounce
aBounce := hi
bool brk = aynaBrkMode == "Kapanış" ? cl < aLo : lo < aLo
if brk
aState := 3
else if aState == 3
if lo <= aLo - (aHi - aLo) * 0.382
aMirDone := true
if cl > aBounce
aState := 0
if not na(pl) and aState == 1 and (bar_index - aynaLen) > aHiBar and (aHi - pl) / math.abs(aHi) * 100 >= aynaMinDrop
aLo := pl
aBounce := hiNow
aState := 2
if aState >= 2
dState := aState
dHi := aHi
dHiBar := aHiBar
dLo := aLo
dBounce := aBounce
[dState, dHi, dHiBar, dLo, dBounce]
// Dip yapısı (normal seri) ve Tepe yapısı (ters seri: değerler negatif uzayda)
[dState, dHi, dHiBar, dLo, dBounce] = aynaCore(high, low, close)
[xState, xHi, xHiBar, xLo, xBounce] = aynaCore(-low, -high, -close)
var array<line> aLines = array.new<line>()
var array<box> aPdas = array.new<box>()
// sg = +1 dip, -1 tepe (ters uzaydan gerçek fiyata çevirir)
f_drawAyna(float sg, int st, float hi, int hiBar, float lo, float bounce) =>
if not na(hi) and not na(lo) and hi > lo and st >= 2
float r = hi - lo
if showAyna
array.push(aLines, line.new(hiBar, sg * lo, bar_index + aynaExt, sg * lo, color=zeroColor, style=line.style_solid, width=2))
if showPDA and st == 3
float t214 = sg * (lo - r * 0.214)
float b214 = sg * (lo - r * (0.214 + pdaWidth))
array.push(aPdas, box.new(hiBar, math.max(t214, b214), bar_index + aynaExt, math.min(t214, b214), border_color=color.new(color.black, 50), bgcolor=pda214Col))
if not na(bounce) and bounce > lo
float L = (bounce - lo) / r
float t1 = sg * (lo - r * L)
float b1 = sg * (lo - r * (L + pdaWidth))
array.push(aPdas, box.new(hiBar, math.max(t1, b1), bar_index + aynaExt, math.min(t1, b1), border_color=color.new(color.black, 50), bgcolor=pda1Col))
float comp = 1.0 - L
float t2 = sg * (lo - r * comp)
float b2 = sg * (lo - r * (comp + pdaWidth))
array.push(aPdas, box.new(hiBar, math.max(t2, b2), bar_index + aynaExt, math.min(t2, b2), border_color=color.new(color.black, 50), bgcolor=pda2Col))
true
if barstate.islast
while array.size(aLines) > 0
line.delete(array.pop(aLines))
while array.size(aPdas) > 0
box.delete(array.pop(aPdas))
f_drawAyna(1.0, dState, dHi, dHiBar, dLo, dBounce)
if showAynaTop
f_drawAyna(-1.0, xState, xHi, xHiBar, xLo, xBounce)
// ═══════════════════════════════════════════════════════════════════
// CLIMAX MOTORU (parametrik: dip için normal, tepe için ters seri)
// ═══════════════════════════════════════════════════════════════════
priceAtLvl(float target, float ag, float al, float px) =>
float res = na
if not na(target) and not na(ag) and not na(al) and target > 0 and target < 100
float rs = target / (100 - target)
float x = (lenA - 1) * (al * rs - ag)
res := x >= 0 ? px + x : px + x * (100 - target) / target
res
calcClimax(float cl, float hi, float lo) =>
float oscF = ta.rsi(cl, lenA)
float phF = ta.pivothigh(oscF, fibPiv, fibPiv)
float plF = ta.pivotlow(oscF, fibPiv, fibPiv)
var float pendLow = na
var int pendLowBar = na
var float pendLowPx = na
var float fHi = na
var float fLo = na
var int hiBar = na
var float fHiPx = na
var float fLoPx = na
if not na(plF)
if na(pendLow) or plF <= pendLow
pendLow := plF
pendLowBar := bar_index - fibPiv
pendLowPx := lo[fibPiv]
if not na(phF)
int phBar = bar_index - fibPiv
if not na(pendLow) and pendLowBar < phBar
fLo := pendLow
fHi := phF
hiBar := phBar
fLoPx := pendLowPx
fHiPx := hi[fibPiv]
pendLow := na
pendLowBar := na
pendLowPx := na
else if na(pendLow) and not na(fHi) and phF > fHi
fHi := phF
hiBar := phBar
fHiPx := hi[fibPiv]
float rng = fHi - fLo
bool valid = not na(rng) and rng >= fibMinRange
float lvl = valid ? fHi - 1.618 * rng : na
bool touch = valid and lvl >= 0 and (bar_index - hiBar <= fibMaxAge) and math.abs(oscF - lvl) <= fibTol
var int tStart = na
if touch and na(tStart)
tStart := bar_index
bool conf = oscF > nz(oscF[1]) and (touch or touch[1])
int st = tStart
if not touch
tStart := na
float chgP = ta.change(cl)
float agP = ta.rma(math.max(chgP, 0), lenA)
float alP = ta.rma(math.max(-chgP, 0), lenA)
float rT1 = valid ? fHi - 0.618 * rng : na
float rT2 = valid ? fHi - 0.5 * rng : na
float rT3 = valid ? fHi - 0.382 * rng : na
float pxRng = fHiPx - fLoPx
bool pxOk = valid and not na(pxRng) and pxRng > 0
bool tpFib = tpMode == "Fiyat fibosu"
float pT1 = tpFib ? (pxOk ? fHiPx - 0.618 * pxRng : na) : priceAtLvl(rT1, agP, alP, cl)
float pT2 = tpFib ? (pxOk ? fHiPx - 0.500 * pxRng : na) : priceAtLvl(rT2, agP, alP, cl)
float pT3 = tpFib ? (pxOk ? fHiPx - 0.382 * pxRng : na) : priceAtLvl(rT3, agP, alP, cl)
[conf, st, pT1, pT2, pT3]
[cConf, cStart, cTP1, cTP2, cTP3] = calcClimax(close, high, low)
[xConfN, xStart, xTP1n, xTP2n, xTP3n] = calcClimax(-close, -low, -high)
float xTP1 = -xTP1n
float xTP2 = -xTP2n
float xTP3 = -xTP3n
bool xConf = xConfN
// Bölge: climax bölgesine girildiği ilk bardan itibaren (onay beklemeden)
bool cZone = earlyMode ? (cConf or not na(cStart)) : cConf
bool xZone = earlyMode ? (xConf or not na(xStart)) : xConf
// ═══════════════════════════════════════════════════════════════════
// ONAY SKORU: 5 bağımsız onay (dip için 1-5, tepe/Iron Floor için ayna)
// 1) Likit bant: dışına taşıp içeri dönüş
// 2) Şelale (dip) / roket (tepe) koruması: eğim aşırı dik değil
// 3) Yüksek göreceli hacim VEYA uyumsuzluk (para akışı)
// 4) Fiyat aksiyonu: önceki mum kırılımı + SMMA7 teyidi
// 5) Dönüş mumu: çekiç (dip) / kayan yıldız (tepe)
// ═══════════════════════════════════════════════════════════════════
confPack() =>
float atL = ta.atr(14)
float fv = (ta.alma(close, lrbLen, 0.85, 6) + ta.ema(close, lrbLen)) / 2
float sdv = ta.stdev(close, lrbLen)
float upB = fv + lrbMult * sdv
float loB = fv - lrbMult * sdv
bool reBuy = (close[1] < loB[1] or close[2] < loB[2]) and close > loB
bool reSell = (close[1] > upB[1] or close[2] > upB[2]) and close < upB
float slp = atL > 0 ? (fv - fv[5]) / 5 / atL : 0.0
float ang = math.todegrees(math.atan(slp))
bool noKnife = ang > -knifeAng
bool noRocket = ang < knifeAng
float rg = high - low
float dfl = rg > 0 ? volume * (2 * close - high - low) / rg : 0.0
float fl = ta.sma(dfl, 5)
float rvol = nz(volume / ta.sma(volume, 20), 1.0)
bool bullDiv = low < nz(ta.lowest(low, divLen)[1], low) and fl > nz(ta.lowest(fl, divLen)[1], fl)
bool bearDiv = high > nz(ta.highest(high, divLen)[1], high) and fl < nz(ta.highest(fl, divLen)[1], fl)
float sm7 = ta.rma(close, 7)
float bdy = math.abs(close - open)
float upW = high - math.max(open, close)
float loW = math.min(open, close) - low
bool hammer = rg > 0 and loW >= bdy * 2 and upW <= bdy * 0.5
bool star = rg > 0 and upW >= bdy * 2 and loW <= bdy * 0.5
int dSc = (reBuy ? 1 : 0) + (noKnife ? 1 : 0) + ((rvol >= rvolMin or bullDiv) ? 1 : 0) + ((close > high[1] and close > sm7) ? 1 : 0) + (hammer ? 1 : 0)
int tSc = (reSell ? 1 : 0) + (noRocket ? 1 : 0) + ((rvol >= rvolMin or bearDiv) ? 1 : 0) + ((close < low[1] and close < sm7) ? 1 : 0) + (star ? 1 : 0)
[dSc, tSc]
// Bant koordinatları
float atrV = ta.atr(14)
// DİP bandı
int nBars = na(cStart) ? 1 : math.max(bar_index - int(cStart) + 1, 1)
float lowMin = ta.lowest(low, nBars)
float lowCls = ta.lowest(close, nBars)
float bandTop = math.max(lowCls, lowMin + bandMinAtr * atrV)
float bandBot = lowMin - bandDownAtr * atrV
// TEPE bandı (ayna)
int nBarsX = na(xStart) ? 1 : math.max(bar_index - int(xStart) + 1, 1)
float highMax = ta.highest(high, nBarsX)
float highCls = ta.highest(close, nBarsX)
float xBandBot = math.min(highCls, highMax - bandMinAtr * atrV)
float xBandTop = highMax + bandDownAtr * atrV
// Güçlü Climax: bant 0 çizgisine yakın veya PDA bölgesi içinde/kesişiyor mu? (hepsi aynı uzayda)
f_strongP(float bTop, float bBot, int sState, float sHi, float sLo, float sBounce, float sAtr) =>
bool res = false
if strongOn and not na(sLo) and not na(bTop) and not na(bBot) and sState >= 2
float tol = strongTolAtr * nz(sAtr, 0.0)
float r = not na(sHi) and sHi > sLo ? sHi - sLo : 0.0
bool nearZero = math.abs(bBot - sLo) <= tol or math.abs(bTop - sLo) <= tol or (bBot <= sLo and bTop >= sLo)
bool nearPDA = false
if r > 0 and sState == 3
float p214t = sLo - r * 0.214
float p214b = sLo - r * (0.214 + pdaWidth)
nearPDA := (bBot <= p214t and bTop >= p214b) or math.abs(bBot - p214t) <= tol
if r > 0 and not na(sBounce) and sBounce > sLo and sState == 3
float L = (sBounce - sLo) / r
float p1t = sLo - r * L
float p1b = sLo - r * (L + pdaWidth)
float p2t = sLo - r * (1.0 - L)
float p2b = sLo - r * (1.0 - L + pdaWidth)
nearPDA := nearPDA or (bBot <= p1t and bTop >= p1b) or (bBot <= p2t and bTop >= p2b)
res := nearZero or nearPDA
res
f_isStrong(float bTop, float bBot) => f_strongP(bTop, bBot, dState, dHi, dLo, dBounce, atrV)
// Tepe: gerçek fiyat bandı ters uzaya çevrilir
f_isStrongX(float rTop, float rBot) => f_strongP(-rBot, -rTop, xState, xHi, xLo, xBounce, atrV)
bool isStrong = cZone and f_isStrong(bandTop, bandBot)
bool isStrongX = xZone and f_isStrongX(xBandTop, xBandBot)
// Climax süresince görülen en yüksek onay skoru
[dScNow, tScNow] = confPack()
var int dBest = 0
var int tBest = 0
if cZone
dBest := cZone[1] ? math.max(dBest, dScNow) : dScNow
if xZone
tBest := xZone[1] ? math.max(tBest, tScNow) : tScNow
// ───────────── Alan adları ve ortak alan rengi ─────────────
string grpNm = "Alan Adları / Ortak Alan"
string nmZone = input.string("ANVIL", "Yeşil destek bölgesi adı", group=grpNm)
string nmClimax = input.string("FURNACE", "Dip climax alanı adı", group=grpNm)
string nmStrongP = input.string("STRONG ", "Güçlü climax ön eki", group=grpNm)
string nmCross = input.string("CRUCIBLE", "İkisi aynı alandaysa ortak alan adı", group=grpNm, tooltip="Dip climax alanı ile yeşil destek bölgesi fiyatta kesişiyorsa, kesişen kısım bu adla ve aşağıdaki renkle çizilir.")
int cruPiv = 3 // Kale destek pivot uzunluğu (Kale sistemiyle aynı)
float cruGen = 0.5 // Kale bölge genişliği (ATR50 x 0.5)
int cruMax = 15 // saklanan maks. destek bölgesi
int cfBonus = input.int(1, "Ortak alanda onay puanı bonusu (+)", minval=0, maxval=3, group=grpNm, tooltip="Destek bölgesi ile climax alanı kesiştiğinde onay puanına eklenir (en fazla 5/5).")
bool cfShow = input.bool(true, "Ortak alanı ayrı renkte göster", group=grpNm)
color cfCol = input.color(#00D1FF, "Ortak alan rengi", group=grpNm)
color cfColX = input.color(#FF4D6D, "FORGE (Iron Floor ∩ Hammer) ortak alan rengi", group=grpNm)
f_sc(int sc) => confOn ? " • " + str.tostring(sc) + "/5" : ""
f_cTxt(bool st, int sc) => (st ? nmStrongP + nmClimax : nmClimax) + f_sc(sc)
f_xTxt(bool st, int sc) => (st ? "GÜÇLÜ IRON FLOOR" : "IRON FLOOR") + f_sc(sc)
// Son climax bantları (Screener)
var float lcTop = na
var float lcBot = na
var int lcBar = na
if cConf
if not cConf[1]
lcBar := bar_index
lcTop := bandTop
lcBot := bandBot
var float xcTop = na
var float xcBot = na
var int xcBar = na
if xConf
if not xConf[1]
xcBar := bar_index
xcTop := xBandTop
xcBot := xBandBot
// ───── DİP kutusu ─────
var box cBox = na
var label cLbl = na
var bool cLive = false
var bool cStrongL = false
if showClimax and cZone
if not cZone[1]
if not na(cBox)
box.delete(cBox)
if not na(cLbl)
label.delete(cLbl)
cStrongL := isStrong
color bg = isStrong ? strongCol : climaxCol
color bd = isStrong ? strongBord : climaxBord
int leftB = math.max((na(cStart) ? bar_index : int(cStart)) - bandPad, 0)
cBox := box.new(leftB, bandTop, bar_index + bandPad, bandBot, bgcolor=bg, border_color=bd, border_width=isStrong ? 2 : 1)
int midX = math.round((leftB + bar_index + bandPad) / 2.0)
string lblTxt = f_cTxt(isStrong, dBest)
color txtC = isStrong ? #22C55E : color.white
cLbl := label.new(midX, bandBot, labelStrong ? lblTxt : "", xloc=xloc.bar_index, style=label.style_label_up, color=color.new(color.black, 100), textcolor=txtC, size=size.small, textalign=text.align_center)
cLive := true
else if cLive and not na(cBox)
if isStrong and not cStrongL
cStrongL := true
box.set_bgcolor(cBox, strongCol)
box.set_border_color(cBox, strongBord)
box.set_border_width(cBox, 2)
label.set_text(cLbl, labelStrong ? f_cTxt(true, dBest) : "")
label.set_textcolor(cLbl, #22C55E)
box.set_right(cBox, bar_index + bandPad)
box.set_top(cBox, bandTop)
box.set_bottom(cBox, bandBot)
label.set_x(cLbl, math.round((box.get_left(cBox) + box.get_right(cBox)) / 2.0))
label.set_y(cLbl, bandBot)
else
cLive := false
if barstate.islast and showClimax and not na(cBox)
bool nowStrong = f_isStrong(box.get_top(cBox), box.get_bottom(cBox))
cStrongL := nowStrong
box.set_bgcolor(cBox, nowStrong ? strongCol : climaxCol)
box.set_border_color(cBox, nowStrong ? strongBord : climaxBord)
box.set_border_width(cBox, nowStrong ? 2 : 1)
label.set_text(cLbl, labelStrong ? f_cTxt(nowStrong, dBest) : "")
label.set_textcolor(cLbl, nowStrong ? #22C55E : color.white)
// ───── TEPE kutusu ─────
var box xBox = na
var label xLbl = na
var bool xLive = false
var bool xStrongL = false
if showClimaxT and xZone
if not xZone[1]
if not na(xBox)
box.delete(xBox)
if not na(xLbl)
label.delete(xLbl)
xStrongL := isStrongX
color bg = isStrongX ? strongColT : climaxColT
color bd = isStrongX ? strongBordT : climaxBordT
int leftB = math.max((na(xStart) ? bar_index : int(xStart)) - bandPad, 0)
xBox := box.new(leftB, xBandTop, bar_index + bandPad, xBandBot, bgcolor=bg, border_color=bd, border_width=isStrongX ? 2 : 1)
int midX = math.round((leftB + bar_index + bandPad) / 2.0)
string lblTxt = f_xTxt(isStrongX, tBest)
color txtC = isStrongX ? #EF4444 : color.white
xLbl := label.new(midX, xBandTop, labelStrong ? lblTxt : "", xloc=xloc.bar_index, style=label.style_label_down, color=color.new(color.black, 100), textcolor=txtC, size=size.small, textalign=text.align_center)
xLive := true
else if xLive and not na(xBox)
if isStrongX and not xStrongL
xStrongL := true
box.set_bgcolor(xBox, strongColT)
box.set_border_color(xBox, strongBordT)
box.set_border_width(xBox, 2)
label.set_text(xLbl, labelStrong ? f_xTxt(true, tBest) : "")
label.set_textcolor(xLbl, #EF4444)
box.set_right(xBox, bar_index + bandPad)
box.set_top(xBox, xBandTop)
box.set_bottom(xBox, xBandBot)
label.set_x(xLbl, math.round((box.get_left(xBox) + box.get_right(xBox)) / 2.0))
label.set_y(xLbl, xBandTop)
else
xLive := false
if barstate.islast and showClimaxT and not na(xBox)
bool nowStrongX = f_isStrongX(box.get_top(xBox), box.get_bottom(xBox))
xStrongL := nowStrongX
box.set_bgcolor(xBox, nowStrongX ? strongColT : climaxColT)
box.set_border_color(xBox, nowStrongX ? strongBordT : climaxBordT)
box.set_border_width(xBox, nowStrongX ? 2 : 1)
label.set_text(xLbl, labelStrong ? f_xTxt(nowStrongX, tBest) : "")
label.set_textcolor(xLbl, nowStrongX ? #EF4444 : color.white)
// ───── TP çizgileri (dip + tepe) ─────
var float tpF1 = na
var int tpBar = na
var bool tpWasStrong = false
if cZone and not cZone[1]
tpF1 := cTP1
tpBar := bar_index
tpWasStrong := isStrong
if cZone and cZone[1] and isStrong
tpWasStrong := true
if barstate.islast and showClimax and not na(cBox)
tpWasStrong := cStrongL
var float xtF1 = na
var int xtBar = na
var bool xtWasStrong = false
if xZone and not xZone[1]
xtF1 := xTP1
xtBar := bar_index
xtWasStrong := isStrongX
if xZone and xZone[1] and isStrongX
xtWasStrong := true
if barstate.islast and showClimaxT and not na(xBox)
xtWasStrong := xStrongL
var array<line> tpLines = array.new<line>()
var array<label> tpLabels = array.new<label>()
if barstate.islast
while array.size(tpLines) > 0
line.delete(array.pop(tpLines))
while array.size(tpLabels) > 0
label.delete(array.pop(tpLabels))
if showTP and not na(tpBar) and bar_index - tpBar <= tpShowBars
if not na(tpF1)
string extra = tpWasStrong ? " ★" : ""
array.push(tpLines, line.new(tpBar, tpF1, bar_index + 2, tpF1, color=tpColor, style=line.style_dashed, width=1))
array.push(tpLabels, label.new(bar_index + 3, tpF1, "TP1 " + str.tostring(tpF1, format.mintick) + extra, style=label.style_label_left, color=color.new(color.black, 100), textcolor=tpColor, size=size.small))
if showTP and not na(xtBar) and bar_index - xtBar <= tpShowBars
if not na(xtF1)
string extraX = xtWasStrong ? " ★" : ""
array.push(tpLines, line.new(xtBar, xtF1, bar_index + 2, xtF1, color=tpColorT, style=line.style_dashed, width=1))
array.push(tpLabels, label.new(bar_index + 3, xtF1, "TP1 " + str.tostring(xtF1, format.mintick) + extraX, style=label.style_label_left, color=color.new(color.black, 100), textcolor=tpColorT, size=size.small))
// ═══════════════════════════════════════════════════════════════════
// RSN MUM FORMASYONU MOTORU
// ═══════════════════════════════════════════════════════════════════
rsnStr(float base, float fct) => math.min(4, math.round(base * fct))
strBar(int s) => s >= 4 ? "●●●●" : s == 3 ? "●●●○" : s == 2 ? "●●○○" : s == 1 ? "●○○○" : "○○○○"
rsnInfo(int ix) =>
switch ix
0 => "📍 KONUM: Düşüş trendinin sonunda\n🎯 ANLAM: Satış baskısının azaldığı, alıcıların devreye girdiği\n📊 ÖZELLİK: Uzun alt fitil, kısa üst fitil\n⚡ STRATEJİ: Bir sonraki mumda onay bekle"
1 => "📍 KONUM: Düşüş trendinin sonunda\n🎯 ANLAM: Alıcılar test ediyor, satıcılar zayıflıyor\n📊 ÖZELLİK: Uzun üst fitil, kısa alt fitil\n⚡ STRATEJİ: Hacim artışı ile onay bekle"
2 => "📍 KONUM: Düşüş trendinin sonunda\n🎯 ANLAM: Alıcılar kontrolü ele aldı\n📊 ÖZELLİK: Büyük yeşil mum, önceki kırmızı mumu yutuyor\n⚡ STRATEJİ: Güçlü sinyal, hemen pozisyon al"
3 => "📍 KONUM: Düşüş trendinin sonunda\n🎯 ANLAM: Trend tersine dönüyor\n📊 ÖZELLİK: 3 mumluk formasyon\n⚡ STRATEJİ: En güvenilir sinyallerden biri"
4 => "📍 KONUM: Düşüş trendinin sonunda\n🎯 ANLAM: Kararsızlık sonrası yükseliş\n📊 ÖZELLİK: Ortada Doji olan 3 mumluk formasyon\n⚡ STRATEJİ: Doji sonrası onay bekle"
5 => "📍 KONUM: Düşüş trendinde\n🎯 ANLAM: Alıcılar güçleniyor\n📊 ÖZELLİK: Yeşil mum, önceki kırmızı mumun yarısını geçiyor\n⚡ STRATEJİ: Devam eden yükseliş için pozisyon al"
6 => "📍 KONUM: Düşüş trendinin sonunda\n🎯 ANLAM: Satış baskısı azalıyor\n📊 ÖZELLİK: Küçük yeşil mum, büyük kırmızı mumun içinde\n⚡ STRATEJİ: Onay bekle, sabırlı ol"
7 => "📍 KONUM: Düşüş trendinin sonunda\n🎯 ANLAM: Güçlü yükseliş trendi başlıyor\n📊 ÖZELLİK: Ardışık 3 güçlü yeşil mum\n⚡ STRATEJİ: Güçlü trend sinyali, büyük pozisyon al"
8 => "📍 KONUM: Her yerde\n🎯 ANLAM: Alıcılar tam kontrolde\n📊 ÖZELLİK: Fitilsiz büyük yeşil mum\n⚡ STRATEJİ: Güçlü momentum, trend devam edecek"
9 => "📍 KONUM: Yükseliş trendinin sonunda\n🎯 ANLAM: Alım baskısı azalıyor\n📊 ÖZELLİK: Uzun alt fitil, kısa üst fitil\n⚡ STRATEJİ: Bir sonraki mumda onay bekle"
10 => "📍 KONUM: Yükseliş trendinin sonunda\n🎯 ANLAM: Yüksek seviyede reddedilme\n📊 ÖZELLİK: Uzun üst fitil, kısa alt fitil\n⚡ STRATEJİ: Güçlü tepe sinyali, short pozisyon"
11 => "📍 KONUM: Yükseliş trendinin sonunda\n🎯 ANLAM: Satıcılar kontrolü ele aldı\n📊 ÖZELLİK: Büyük kırmızı mum, önceki yeşil mumu yutuyor\n⚡ STRATEJİ: Güçlü sinyal, hemen short pozisyon"
12 => "📍 KONUM: Yükseliş trendinin sonunda\n🎯 ANLAM: Trend tersine dönüyor\n📊 ÖZELLİK: 3 mumluk formasyon\n⚡ STRATEJİ: En güvenilir düşüş sinyali"
13 => "📍 KONUM: Yükseliş trendinin sonunda\n🎯 ANLAM: Kararsızlık sonrası düşüş\n📊 ÖZELLİK: Ortada Doji olan 3 mumluk formasyon\n⚡ STRATEJİ: Doji sonrası onay bekle"
14 => "📍 KONUM: Yükseliş trendinde\n🎯 ANLAM: Satıcılar güçleniyor\n📊 ÖZELLİK: Kırmızı mum, önceki yeşil mumun yarısını geçiyor\n⚡ STRATEJİ: Devam eden düşüş için short pozisyon"
15 => "📍 KONUM: Yükseliş trendinin sonunda\n🎯 ANLAM: Alım baskısı azalıyor\n📊 ÖZELLİK: Küçük kırmızı mum, büyük yeşil mumun içinde\n⚡ STRATEJİ: Onay bekle, sabırlı ol"
16 => "📍 KONUM: Yükseliş trendinin sonunda\n🎯 ANLAM: Güçlü düşüş trendi başlıyor\n📊 ÖZELLİK: Ardışık 3 güçlü kırmızı mum\n⚡ STRATEJİ: Güçlü trend sinyali, büyük short pozisyon"
17 => "📍 KONUM: Her yerde\n🎯 ANLAM: Satıcılar tam kontrolde\n📊 ÖZELLİK: Fitilsiz büyük kırmızı mum\n⚡ STRATEJİ: Güçlü momentum, trend devam edecek"
18 => "📍 KONUM: Trend değişim noktalarında\n🎯 ANLAM: Alıcı-satıcı dengesi\n📊 ÖZELLİK: Açılış ≈ Kapanış\n⚡ STRATEJİ: Sonraki mumda yön bekle"
19 => "📍 KONUM: Önemli seviyeler\n🎯 ANLAM: Yoğun mücadele\n📊 ÖZELLİK: Uzun fitiller, küçük gövde\n⚡ STRATEJİ: Büyük hareket öncesi sessizlik"
20 => "📍 KONUM: Yükseliş trendinin sonunda\n🎯 ANLAM: Yüksek seviyede reddedilme\n📊 ÖZELLİK: Uzun üst fitil, alt fitil yok\n⚡ STRATEJİ: Tepe sinyali, short pozisyon"
21 => "📍 KONUM: Düşüş trendinin sonunda\n🎯 ANLAM: Düşük seviyede destek\n📊 ÖZELLİK: Uzun alt fitil, üst fitil yok\n⚡ STRATEJİ: Dip sinyali, alım fırsatı"
22 => "📍 KONUM: Trend içinde\n🎯 ANLAM: Momentum azalıyor\n📊 ÖZELLİK: Küçük gövde, orta fitiller\n⚡ STRATEJİ: Trend devam edebilir, dikkat et"
23 => "📍 KONUM: Yükseliş trendi içinde\n🎯 ANLAM: Geçici düzeltme sonrası devam\n📊 ÖZELLİK: 5 mumluk formasyon\n⚡ STRATEJİ: Trend devam edecek, pozisyon ekle"
24 => "📍 KONUM: Düşüş trendi içinde\n🎯 ANLAM: Geçici toparlanma sonrası devam\n📊 ÖZELLİK: 5 mumluk formasyon\n⚡ STRATEJİ: Trend devam edecek, short pozisyon ekle"
=> ""
rsnPack() =>
bool oB = rsnOn and rsnBull
bool oS = rsnOn and rsnBear
bool oI = rsnOn and rsnIndec
bool oC = rsnOn and rsnCont
float atrR = ta.atr(14)
float volMaR = ta.sma(volume, 20)
float bd = math.abs(close - open)
float rg = high - low
float upW = high - math.max(open, close)
float loW = math.min(open, close) - low
bool bullC = close > open
bool bearC = close < open
float bdPct = close != 0 ? bd / close * 100 : 0.0
bool hasBd = bdPct >= rsnMinBody * rsnMult
bool dojiC = bd <= rg * 0.1
bool maruC = upW <= rg * 0.05 and loW <= rg * 0.05
float fct = (volume > volMaR ? 1.2 : 1.0) * (rg > atrR ? 1.1 : 1.0)
bool pHam = oB and loW >= bd * 2 and upW <= bd * 0.5 and hasBd and low < low[1] and low < low[2]
bool pInvH = oB and upW >= bd * 2 and loW <= bd * 0.5 and hasBd and low < low[1] and low < low[2]
bool pBEng = oB and bearC[1] and bullC and open < close[1] and close > open[1] and bd > bd[1] * 1.2
bool pMStar = oB and bearC[2] and bd[2] > atrR * 0.5 and bd[1] < bd[2] * 0.3 and bullC and bd > atrR * 0.5 and close > (open[2] + close[2]) / 2
bool pMDoji = oB and bearC[2] and bd[2] > atrR * 0.5 and dojiC[1] and bullC and bd > atrR * 0.5
bool pPierc = oB and bearC[1] and bullC and open < low[1] and close > (open[1] + close[1]) / 2 and close < open[1]
bool pBHar = oB and bearC[1] and bullC and open > close[1] and close < open[1] and bd < bd[1] * 0.7
bool pSold = oB and bullC and bullC[1] and bullC[2] and close > close[1] and close[1] > close[2] and open > open[1] and open[1] > open[2] and upW < bd * 0.3 and upW[1] < bd[1] * 0.3 and upW[2] < bd[2] * 0.3
bool pBMaru = oB and bullC and maruC and hasBd
bool pHang = oS and loW >= bd * 2 and upW <= bd * 0.5 and hasBd and high > high[1] and high > high[2]
bool pShoot = oS and upW >= bd * 2 and loW <= bd * 0.5 and hasBd and high > high[1] and high > high[2]
bool pSEng = oS and bullC[1] and bearC and open > close[1] and close < open[1] and bd > bd[1] * 1.2
bool pEStar = oS and bullC[2] and bd[2] > atrR * 0.5 and bd[1] < bd[2] * 0.3 and bearC and bd > atrR * 0.5 and close < (open[2] + close[2]) / 2
bool pEDoji = oS and bullC[2] and bd[2] > atrR * 0.5 and dojiC[1] and bearC and bd > atrR * 0.5
bool pDark = oS and bullC[1] and bearC and open > high[1] and close < (open[1] + close[1]) / 2 and close > open[1]
bool pSHar = oS and bullC[1] and bearC and open < close[1] and close > open[1] and bd < bd[1] * 0.7
bool pCrow = oS and bearC and bearC[1] and bearC[2] and close < close[1] and close[1] < close[2] and open < open[1] and open[1] < open[2] and loW < bd * 0.3 and loW[1] < bd[1] * 0.3 and loW[2] < bd[2] * 0.3
bool pSMaru = oS and bearC and maruC and hasBd
bool pDoji = oI and dojiC and rg > atrR * 0.3
bool pLDoji = oI and dojiC and upW > rg * 0.3 and loW > rg * 0.3 and rg > atrR * 0.5
bool pGrave = oI and dojiC and upW > rg * 0.7 and loW < rg * 0.1
bool pDrag = oI and dojiC and loW > rg * 0.7 and upW < rg * 0.1
bool pSpin = oI and bd < rg * 0.3 and upW > bd and loW > bd and rg > atrR * 0.2
bool pRise = oC and bullC[4] and bd[4] > atrR * 0.5 and bearC[3] and bearC[2] and bearC[1] and high[3] < high[4] and high[2] < high[4] and high[1] < high[4] and low[3] > low[4] and low[2] > low[4] and low[1] > low[4] and bullC and close > close[4]
bool pFall = oC and bearC[4] and bd[4] > atrR * 0.5 and bullC[3] and bullC[2] and bullC[1] and low[3] > low[4] and low[2] > low[4] and low[1] > low[4] and high[3] < high[4] and high[2] < high[4] and high[1] < high[4] and bearC and close < close[4]
string[] names = array.from("Çekiç (Hammer)", "Ters Çekiç (Inv. Hammer)", "Yutan Boğa (Bullish Engulfing)", "Sabah Yıldızı (Morning Star)", "Sabah Doji Yıldızı", "Delici Desen (Piercing)", "Boğa Harami", "3 Beyaz Asker", "Boğa Marubozu", "Asılı Adam (Hanging Man)", "Kayan Yıldız (Shooting Star)", "Yutan Ayı (Bearish Engulfing)", "Akşam Yıldızı (Evening Star)", "Akşam Doji Yıldızı", "Kara Bulut (Dark Cloud)", "Ayı Harami", "3 Kara Karga", "Ayı Marubozu", "Doji", "Uzun Bacaklı Doji", "Mezar Taşı Doji", "Yusufçuk Doji", "Topaç (Spinning Top)", "Yükselen 3'lü Yöntem", "Düşen 3'lü Yöntem")
int[] dirs = array.from(1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, -1, 1, 0, 1, -1)
int[] ss = array.from(pHam ? rsnStr(2.5, fct) : 0, pInvH ? rsnStr(2.0, fct) : 0, pBEng ? rsnStr(3.5, fct) : 0, pMStar ? rsnStr(4.0, fct) : 0, pMDoji ? rsnStr(3.8, fct) : 0, pPierc ? rsnStr(3.0, fct) : 0, pBHar ? rsnStr(2.5, fct) : 0, pSold ? rsnStr(4.0, fct) : 0, pBMaru ? rsnStr(3.2, fct) : 0, pHang ? rsnStr(2.5, fct) : 0, pShoot ? rsnStr(2.8, fct) : 0, pSEng ? rsnStr(3.5, fct) : 0, pEStar ? rsnStr(4.0, fct) : 0, pEDoji ? rsnStr(3.8, fct) : 0, pDark ? rsnStr(3.0, fct) : 0, pSHar ? rsnStr(2.5, fct) : 0, pCrow ? rsnStr(4.0, fct) : 0, pSMaru ? rsnStr(3.2, fct) : 0, pDoji ? rsnStr(2.0, fct) : 0, pLDoji ? rsnStr(2.5, fct) : 0, pGrave ? rsnStr(2.8, fct) : 0, pDrag ? rsnStr(2.8, fct) : 0, pSpin ? rsnStr(1.5, fct) : 0, pRise ? rsnStr(3.0, fct) : 0, pFall ? rsnStr(3.0, fct) : 0)
int bi = -1
int bs = 0
for k = 0 to array.size(ss) - 1
int v = array.get(ss, k)
if v > bs
bs := v
bi := k
bool okP = bi >= 0 and bs >= rsnMinStr
string outNm = okP ? array.get(names, math.max(bi, 0)) : "—"
int outSt = okP ? bs : 0
int outDr = okP ? array.get(dirs, math.max(bi, 0)) : 0
int outIx = okP ? bi : -1
[outNm, outSt, outDr, outIx]
// ═══════════════════════════════════════════════════════════════════
// ALT TF MUM ANALİZİ
// ═══════════════════════════════════════════════════════════════════
autoLtf() =>
int sec = timeframe.in_seconds(timeframe.period)
sec <= 60 ? "1" : sec <= 300 ? "1" : sec <= 900 ? "5" : sec <= 1800 ? "15" : sec <= 3600 ? "30" : sec <= 7200 ? "60" : sec <= 14400 ? "120" : sec <= 86400 ? "240" : sec <= 604800 ? "D" : "W"
autoLtf2(string t1) =>
switch t1
"W" => "D"
"D" => "240"
"240" => "120"
"120" => "60"
"60" => "30"
"30" => "15"
"15" => "5"
"5" => "1"
=> "1"
tfName(string tf) =>
switch tf
"D" => "Günlük"
"W" => "Haftalık"
=> timeframe.in_seconds(tf) >= 3600 ? str.tostring(timeframe.in_seconds(tf) / 3600) + "S" : tf + "dk"
string rawTF1 = autoLtf()
string rawTF2 = autoLtf2(rawTF1)
bool swapTF = timeframe.in_seconds(rawTF2) < timeframe.in_seconds(rawTF1)
string candleTF = swapTF ? rawTF2 : rawTF1
string candleTF2 = swapTF ? rawTF1 : rawTF2
string tfTxt = tfName(candleTF)
string tfTxt2 = tfName(candleTF2)
bool show2 = candleTF2 != candleTF
ltfPack() =>
[n0, s0, d0, i0] = rsnPack()
[open, high, low, close, volume, open[1], high[1], low[1], close[1], volume[1], n0, s0, d0, i0, n0[1], s0[1], d0[1], i0[1]]
[a1o, a1h, a1l, a1c, a1v, b1o, b1h, b1l, b1c, b1v, rsn1Nm, rsn1St, rsn1Dr, rsn1Ix, rsn1NmP, rsn1StP, rsn1DrP, rsn1IxP] = request.security(syminfo.tickerid, candleTF, ltfPack(), gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off, calc_bars_count=120)
[a2o, a2h, a2l, a2c, a2v, b2o, b2h, b2l, b2c, b2v, rsn2Nm, rsn2St, rsn2Dr, rsn2Ix, rsn2NmP, rsn2StP, rsn2DrP, rsn2IxP] = request.security(syminfo.tickerid, candleTF2, ltfPack(), gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off, calc_bars_count=120)
var array<line> mLines = array.new<line>()
var array<label> mLabels = array.new<label>()
var array<box> mBoxes = array.new<box>()
cTPos = switch cTblPosStr
"Sağ Üst" => position.top_right
"Sağ Alt" => position.bottom_right
"Sol Üst" => position.top_left
"Sol Alt" => position.bottom_left
"Orta Sağ" => position.middle_right
=> position.bottom_left
var table cTbl = table.new(cTPos, 5, 13, bgcolor=color.new(#0B0F19, 5), border_width=1, border_color=color.new(#1E293B, 0), frame_width=2, frame_color=color.new(#06B6D4, 0))
int refLen = math.min(50, bar_index + 1)
float midRef = (ta.highest(high, refLen) + ta.lowest(low, refLen)) / 2
float atrSafe = nz(atrV, high - low)
float cHgt = candleHAtr * atrSafe
candleType(float o, float h, float l, float c) =>
float rng = h - l
string t = "—"
if rng > 0
float bodyP = math.abs(c - o) / rng * 100
float upP = (h - math.max(o, c)) / rng * 100
float loP = (math.min(o, c) - l) / rng * 100
bool bullC = c > o
if bodyP < 10
t := loP >= 60 ? "Yusufçuk Doji" : upP >= 60 ? "Mezar Taşı Doji" : "Doji"
else if bodyP >= 85
t := bullC ? "Boğa Marubozu" : "Ayı Marubozu"
else if loP >= 55 and upP <= 20
t := "Çekiç"
else if upP >= 55 and loP <= 20
t := "Kayan Yıldız"
else if bodyP <= 30
t := "Topaç"
else
t := bullC ? "Boğa Mum" : "Ayı Mum"
t
drawCandle(float hO, float hH, float hL, float hC, float hV, string tfT, int offset, int col, string patNm, int patSt, int patDr, int patIx, float refLo, float refHi, bool isPrev) =>
float rngH = hH - hL
float dAcc = rngH > 0 ? hV * (2 * hC - hH - hL) / rngH : 0.0
float bodyP = rngH > 0 ? math.abs(hC - hO) / rngH * 100 : 0.0
float upP = rngH > 0 ? (hH - math.max(hO, hC)) / rngH * 100 : 0.0
float loP = rngH > 0 ? (math.min(hO, hC) - hL) / rngH * 100 : 0.0
float clsPos = rngH > 0 ? (hC - hL) / rngH * 100 : 50.0
bool bullH = hC >= hO
color cCol = bullH ? candleUpCol : candleDnCol
string cType = candleType(hO, hH, hL, hC)
string baskin = clsPos >= 66 ? "Alıcı baskın" : clsPos <= 34 ? "Satıcı baskın" : "Dengeli"
color baskinC = clsPos >= 66 ? color.new(#22C55E, 0) : clsPos <= 34 ? color.new(#EF4444, 0) : color.new(#9CA3AF, 0)
bool magnify = candlePos == "Üstte (büyütülmüş)"
float refR = refHi - refLo
float k = refR > 0 ? cHgt / refR : 0.0
float yBase = midRef - cHgt / 2
float yL = magnify ? yBase + (hL - refLo) * k : hL
float yH = magnify ? yBase + (hH - refLo) * k : hH
float yO = magnify ? yBase + (hO - refLo) * k : hO
float yC = magnify ? yBase + (hC - refLo) * k : hC
float yBT = math.max(yO, yC)
float yBB = math.min(yO, yC)
int x0 = bar_index + offset
int x1 = x0 + candleW
int xm = int(math.round((x0 + x1) / 2.0))
int xs = magnify ? x0 - 1 : bar_index
color patCol = patDr > 0 ? color.new(#00FF88, 0) : patDr < 0 ? color.new(#FF4444, 0) : color.new(#FFD700, 0)
string patDirTxt = patDr > 0 ? "📈 YÖN: Yükseliş Sinyali" : patDr < 0 ? "📉 YÖN: Düşüş Sinyali" : "⚖️ YÖN: Kararsızlık"
string patTip = patSt > 0 ? "🕯️ FORMASYON: " + patNm + "\n" + patDirTxt + "\n💪 GÜÇ: " + str.tostring(patSt) + "/4 " + strBar(patSt) + "\n" + rsnInfo(math.max(patIx, 0)) : "🕯️ FORMASYON: Tespit edilmedi"
string tipTxt = "🔍 " + tfT + " MUM ANALİZİ\n" + "📌 MUM TİPİ: " + cType + " (" + (bullH ? "Yükselen" : "Düşen") + ")\n" + "🔼 Yüksek: " + str.tostring(hH, format.mintick) + " 🔽 Düşük: " + str.tostring(hL, format.mintick) + "\n" + "▶ Açılış: " + str.tostring(hO, format.mintick) + " ■ Kapanış: " + str.tostring(hC, format.mintick) + "\n" + "📏 Bar Range: " + str.tostring(rngH, format.mintick) + "\n" + "🧱 Gövde: %" + str.tostring(bodyP, "#.#") + " | Üst fitil: %" + str.tostring(upP, "#.#") + " | Alt fitil: %" + str.tostring(loP, "#.#") + "\n" + "📍 Kapanış konumu: %" + str.tostring(clsPos, "#") + " (" + baskin + ")\n" + "📊 Hacim Delta: " + str.tostring(math.round(dAcc)) + "\n\n" + patTip
array.push(mLines, line.new(xm, yH, xm, yL, color=cCol, width=2))
array.push(mBoxes, box.new(x0, yBT, x1, yBB, border_color=cCol, bgcolor=cCol))
array.push(mLabels, label.new(xm, (yBT + yBB) / 2, "██████", style=label.style_label_center, color=color.new(color.black, 100), textcolor=color.new(color.white, 100), size=size.normal, tooltip=tipTxt))
if not isPrev
array.push(mLines, line.new(xs, yH, x1, yH, color=color.new(candleUpCol, 20), style=line.style_dashed))
array.push(mLines, line.new(xs, yL, x1, yL, color=color.new(candleDnCol, 20), style=line.style_dashed))
array.push(mLines, line.new(xs, yC, x1, yC, color=color.new(candleUpCol, 20), style=line.style_dashed))
array.push(mLines, line.new(xs, yO, x1, yO, color=color.new(color.gray, 20), style=line.style_dashed))
if magnify
float[] lv = array.from(yH, yC, yO, yL)
string[] tx = array.from("Yüksek: " + str.tostring(hH, format.mintick), "Kapanış: " + str.tostring(hC, format.mintick), "Açılış: " + str.tostring(hO, format.mintick), "Düşük: " + str.tostring(hL, format.mintick))
color[] cl = array.from(candleUpCol, candleUpCol, color.gray, candleDnCol)
int[] ord = array.sort_indices(lv, order.descending)
float minGap = cHgt * 0.12
float prevY = na
for j = 0 to 3
int id = array.get(ord, j)
float yy = array.get(lv, id)
float ly = na(prevY) ? yy : math.min(yy, prevY - minGap)
prevY := ly
if math.abs(ly - yy) > syminfo.mintick
array.push(mLines, line.new(x1, yy, x1 + 1, ly, color=color.new(array.get(cl, id), 40)))
array.push(mLabels, label.new(x1 + 1, ly, array.get(tx, id), style=label.style_label_left, color=color.new(color.black, 100), textcolor=array.get(cl, id), size=size.tiny, tooltip=tipTxt))
else
string lvlTxt = "Yüksek: " + str.tostring(hH, format.mintick) + "\nKapanış: " + str.tostring(hC, format.mintick) + "\nAçılış: " + str.tostring(hO, format.mintick) + "\nDüşük: " + str.tostring(hL, format.mintick)
array.push(mLabels, label.new(x1 + 1, (yH + yL) / 2, lvlTxt, style=label.style_label_left, color=color.new(color.black, 100), textcolor=color.white, size=size.tiny, textalign=text.align_left, tooltip=tipTxt))
string dTxt = "Δ " + str.tostring(math.round(dAcc))
array.push(mLabels, label.new(xm, yL, dTxt, style=label.style_label_up, color=color.new(color.black, 100), textcolor=dAcc >= 0 ? #22C55E : #EF4444, size=size.tiny, tooltip=tipTxt))
string topTxt = isPrev ? tfT : tfT + " • " + cType + (patSt > 0 ? "\n" + patNm + " " + str.tostring(patSt) + "/4" : "")
array.push(mLabels, label.new(xm, yH, topTxt, style=label.style_label_down, color=color.new(color.black, 100), textcolor=patSt > 0 and not isPrev ? patCol : color.white, size=size.tiny, tooltip=tipTxt))
if showCandleTbl
color hdr = color.new(#0F172A, 0)
// [STREAMLINED] cTbl cell neutralized
// [STREAMLINED] cTbl cell neutralized
// [STREAMLINED] cTbl cell neutralized
// [STREAMLINED] cTbl cell neutralized
// [STREAMLINED] cTbl cell neutralized
// [STREAMLINED] cTbl cell neutralized
// [STREAMLINED] cTbl cell neutralized
// [STREAMLINED] cTbl cell neutralized
// [STREAMLINED] cTbl cell neutralized
// [STREAMLINED] cTbl cell neutralized
// [STREAMLINED] cTbl cell neutralized
// [STREAMLINED] cTbl cell neutralized
true
if barstate.islast
while array.size(mLines) > 0
line.delete(array.pop(mLines))
while array.size(mLabels) > 0
label.delete(array.pop(mLabels))
while array.size(mBoxes) > 0
box.delete(array.pop(mBoxes))
table.clear(cTbl, 0, 0, 4, 12)
if showCandle
if showCandleTbl
color hdr = color.new(#0F172A, 0)
color lblC = color.new(#93C5FD, 0)
// [STREAMLINED] cTbl cell neutralized
table.merge_cells(cTbl, 0, 0, twoCandles ? 4 : 2, 0)
// [STREAMLINED] cTbl cell neutralized
// [STREAMLINED] cTbl cell neutralized
// [STREAMLINED] cTbl cell neutralized
// [STREAMLINED] cTbl cell neutralized
// [STREAMLINED] cTbl cell neutralized
// [STREAMLINED] cTbl cell neutralized
// [STREAMLINED] cTbl cell neutralized
// [STREAMLINED] cTbl cell neutralized
// [STREAMLINED] cTbl cell neutralized
// [STREAMLINED] cTbl cell neutralized
// [STREAMLINED] cTbl cell neutralized
// [STREAMLINED] cTbl cell neutralized
int pStep = candleW + pairGap
if twoCandles
int g1p = candleBase
int g1l = g1p + pStep
int g2p = g1l + candleW + candleGap
int g2l = g2p + pStep
float p1Lo = na(b1l) ? a1l : math.min(b1l, a1l)
float p1Hi = na(b1h) ? a1h : math.max(b1h, a1h)
float p2Lo = na(b2l) ? a2l : math.min(b2l, a2l)
float p2Hi = na(b2h) ? a2h : math.max(b2h, a2h)
if not na(b1c)
drawCandle(b1o, b1h, b1l, b1c, nz(b1v), tfTxt + " [-1]", g1p, 1, rsn1NmP, nz(rsn1StP), nz(rsn1DrP), nz(rsn1IxP, -1), p1Lo, p1Hi, true)
if not na(a1c)
drawCandle(a1o, a1h, a1l, a1c, nz(a1v), tfTxt, g1l, 2, rsn1Nm, nz(rsn1St), nz(rsn1Dr), nz(rsn1Ix, -1), p1Lo, p1Hi, false)
if show2 and not na(b2c)
drawCandle(b2o, b2h, b2l, b2c, nz(b2v), tfTxt2 + " [-1]", g2p, 3, rsn2NmP, nz(rsn2StP), nz(rsn2DrP), nz(rsn2IxP, -1), p2Lo, p2Hi, true)
if show2 and not na(a2c)
drawCandle(a2o, a2h, a2l, a2c, nz(a2v), tfTxt2, g2l, 4, rsn2Nm, nz(rsn2St), nz(rsn2Dr), nz(rsn2Ix, -1), p2Lo, p2Hi, false)
if candlePos == "Üstte (büyütülmüş)" and not na(b1c) and not na(a1c) and p1Hi > p1Lo
float yPC1 = (midRef - cHgt / 2) + (b1c - p1Lo) * cHgt / (p1Hi - p1Lo)
array.push(mLines, line.new(bar_index + g1p + candleW, yPC1, bar_index + g1l + candleW, yPC1, color=color.new(color.gray, 25), style=line.style_dotted))
if show2 and candlePos == "Üstte (büyütülmüş)" and not na(b2c) and not na(a2c) and p2Hi > p2Lo
float yPC2 = (midRef - cHgt / 2) + (b2c - p2Lo) * cHgt / (p2Hi - p2Lo)
array.push(mLines, line.new(bar_index + g2p + candleW, yPC2, bar_index + g2l + candleW, yPC2, color=color.new(color.gray, 25), style=line.style_dotted))
else
if not na(a1c)
drawCandle(a1o, a1h, a1l, a1c, nz(a1v), tfTxt, candleBase, 1, rsn1Nm, nz(rsn1St), nz(rsn1Dr), nz(rsn1Ix, -1), a1l, a1h, false)
if show2 and not na(a2c)
drawCandle(a2o, a2h, a2l, a2c, nz(a2v), tfTxt2, candleBase + candleW + candleGap, 2, rsn2Nm, nz(rsn2St), nz(rsn2Dr), nz(rsn2Ix, -1), a2l, a2h, false)
// ═══════════════════════════════════════════════════════════════════
// ALERT
// ═══════════════════════════════════════════════════════════════════
// [STRATEGY] alertcondition(cConf and not cConf[1], "Climax Alanı (DİP)", "Dip climax alanı oluştu")
// [STRATEGY] alertcondition(isStrong and cConf and not cConf[1], "GÜÇLÜ Climax Alanı (DİP)", "Güçlü dip climax alanı (0 çizgisi veya PDA bölgesinde)")
// [STRATEGY] alertcondition(xConf and not xConf[1], "Iron Floor (TEPE)", "Iron Floor oluştu")
// [STRATEGY] alertcondition(isStrongX and xConf and not xConf[1], "GÜÇLÜ Iron Floor (TEPE)", "Güçlü Iron Floor (ters 0 çizgisi veya PDA bölgesinde)")
// [STRATEGY] alertcondition(not na(cStart) and int(cStart) == bar_index, "ERKEN Dip bölgesi", "Dip climax bölgesine girildi (onay bekleniyor)")
// [STRATEGY] alertcondition(not na(xStart) and int(xStart) == bar_index, "ERKEN Iron Floor", "Iron Floor bölgesine girildi (onay bekleniyor)")
// ───────────── 6. ÇOKLU ZAMAN DİLİMİ ALERT ─────────────
string grpAlert = "6. Çoklu Zaman Dilimi Alert"
bool alertOn = input.bool(true, "Alert aktif", group=grpAlert)
bool alertTopOn = input.bool(true, "Iron Floor (tepe) sinyallerini de dahil et", group=grpAlert)
bool alertStrongOnly = input.bool(false, "Sadece GÜÇLÜ climax için alert ver", group=grpAlert, tooltip="Kapalıyken her yeni climax alanı alert verir (güçlü olanlar ★ ile belirtilir). Açıkken sadece 0 çizgisi / PDA bölgesindeki güçlü climax alert verir.")
bool alert1hOn = input.bool(true, "1 Saatlik sinyali dahil et", group=grpAlert)
bool alert4hOn = input.bool(true, "4 Saatlik sinyali dahil et", group=grpAlert)
bool alertDOn = input.bool(true, "Günlük sinyali dahil et", group=grpAlert)
bool alertWOn = input.bool(true, "Haftalık sinyali dahil et", group=grpAlert)
bool cruOn = input.bool(true, "POTA (ortak alan) çoklu zaman dilimi alarmı", group=grpAlert, tooltip="1S grafikte kurunca 1S + 4S + Günlük + Haftalık'ta Örs ile Ocak kesişince alarm verir.")
bool cruXOn = input.bool(true, "IRON FLOOR ortak alan (SHORT) çoklu zaman dilimi alarmı", group=grpAlert, tooltip="Kırmızı Kale direnç bölgesi ile Iron Floor (tepe climax) alanı kesişince SHORT alarmı verir.")
bool cruOnly = input.bool(true, "SADECE Pota alarmı gelsin (diğer alert() mesajlarını kapat)", group=grpAlert, tooltip="Açıkken Climax combo ve Anvil mesajları gönderilmez; alert() seçeneğiyle kurduğun tek alarmda sadece Pota (LONG + SHORT) gelir.")
bool confirmMode = input.bool(true, "Sinyal sadece bar kapanışında onaylansın (repaint önler)", group=grpAlert)
int alertFresh = input.int(3, "Alert metninde taze sinyal penceresi (son N bar)", minval=1, maxval=20, group=grpAlert)
mtfPack() =>
// DİP
[cf, st, t1, t2, t3] = calcClimax(close, high, low)
[sS, sHi, sHiB, sLo, sBn] = aynaCore(high, low, close)
float at = ta.atr(14)
[dsc, tsc] = confPack()
int nB = na(st) ? 1 : math.max(bar_index - int(st) + 1, 1)
float lm = ta.lowest(low, nB)
float lc = ta.lowest(close, nB)
float bt = math.max(lc, lm + bandMinAtr * at)
float bb = lm - bandDownAtr * at
bool stZone = f_strongP(bt, bb, sS, sHi, sLo, sBn, at)
bool stNow = cf and stZone
bool okBar = not confirmMode or barstate.isconfirmed
bool rawLate = cf and not cf[1]
var int lastB = na
bool rawEarly = earlyMode and not na(st) and int(st) == bar_index and (na(lastB) or bar_index - lastB > earlyGap)
bool rawNew = rawEarly or (rawLate and (alertLate or not earlyMode))
var bool lastErD = false
var int lastScD = 0
var bool lastStr = false
var float lp1 = na
var float lp2 = na
var float lp3 = na
if rawNew
lastB := bar_index
lastScD := dsc
lastStr := stZone
lastErD := rawEarly and not rawLate
lp1 := t1
lp2 := t2
lp3 := t3
else if cf and stNow
lastStr := true
float snc = na(lastB) ? na : bar_index - lastB
bool newE = okBar and rawNew and (confMin == 0 or dsc >= confMin)
bool strE = newE and stZone
// Son climax bandının sınırları (Screener'da "fiyat bant içinde mi" kontrolü için)
var float dTopS = na
var float dBotS = na
if rawNew or cf
dTopS := bt
dBotS := bb
// TEPE (ters seri)
[cfx, stx, u1, u2, u3] = calcClimax(-close, -low, -high)
[sSx, sHix, sHiBx, sLox, sBnx] = aynaCore(-low, -high, -close)
int nBx = na(stx) ? 1 : math.max(bar_index - int(stx) + 1, 1)
float hm = ta.highest(high, nBx)
float hc = ta.highest(close, nBx)
float bbx = math.min(hc, hm - bandMinAtr * at)
float btx = hm + bandDownAtr * at
bool stZoneX = f_strongP(-bbx, -btx, sSx, sHix, sLox, sBnx, at)
bool stNowX = cfx and stZoneX
bool rawLateX = cfx and not cfx[1]
var int lastBX = na
bool rawEarlyX = earlyMode and not na(stx) and int(stx) == bar_index and (na(lastBX) or bar_index - lastBX > earlyGap)
bool rawNewX = rawEarlyX or (rawLateX and (alertLate or not earlyMode))
var bool lastErX = false
var int lastScX = 0
var bool lastStrX = false
var float lq1 = na
var float lq2 = na
var float lq3 = na
if rawNewX
lastBX := bar_index
lastScX := tsc
lastStrX := stZoneX
lastErX := rawEarlyX and not rawLateX
lq1 := -u1
lq2 := -u2
lq3 := -u3
else if cfx and stNowX
lastStrX := true
float sncX = na(lastBX) ? na : bar_index - lastBX
bool newX = okBar and rawNewX and (confMin == 0 or tsc >= confMin)
bool strX = newX and stZoneX
var float xTopS = na
var float xBotS = na
if rawNewX or cfx
xTopS := btx
xBotS := bbx
// ── POTA: bu zaman diliminde destek bölgesi (Örs) ∩ dip climax alanı (Ocak) ──
float katr = ta.atr(50)
float kpl = ta.pivotlow(cruPiv, cruPiv)
var array<float> kzTop = array.new_float()
var array<float> kzBot = array.new_float()
if array.size(kzBot) > 0
for j = array.size(kzBot) - 1 to 0
if close < array.get(kzBot, j)
array.remove(kzBot, j)
array.remove(kzTop, j)
if not na(kpl)
float ktamp = katr[cruPiv] * cruGen
if not na(ktamp) and close >= kpl
array.unshift(kzBot, kpl)
array.unshift(kzTop, kpl + ktamp)
if array.size(kzBot) > cruMax
array.pop(kzBot)
array.pop(kzTop)
bool cZoneL = earlyMode ? (cf or not na(st)) : cf
bool cruNow = false
float cruTop = na
float cruBot = na
if cZoneL and array.size(kzBot) > 0
for j = 0 to array.size(kzBot) - 1
if bb <= array.get(kzTop, j) and bt >= array.get(kzBot, j)
cruNow := true
cruTop := math.min(bt, array.get(kzTop, j))
cruBot := math.max(bb, array.get(kzBot, j))
break
bool cruEnter = cruNow and not cruNow[1]
[newE, strE, snc, lastStr, lp1, lp2, lp3, newX, strX, sncX, lastStrX, lq1, lq2, lq3, lastScD, lastScX, lastErD, lastErX, time, open, high, low, close, volume, dTopS, dBotS, xTopS, xBotS, cruNow, cruEnter, cruTop, cruBot]
[neH4, seH4, snH4, lsH4, q14, q24, q34, nxH4, sxH4, snxH4, lsxH4, w14, w24, w34, kD4, kX4, eD4, eX4, tm4, o4, h4, l4, c4, v4, dtH4, dbH4, xtH4, xbH4, crH4, ceH4, ctH4, cbH4] = request.security(syminfo.tickerid, "240", mtfPack(), gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off, calc_bars_count=300)
[neD, seD, snD, lsD, q1D, q2D, q3D, nxD, sxD, snxD, lsxD, w1D, w2D, w3D, kDD, kXD, eDD, eXD, tmD, oD, hD, lD, cD, vD, dtD, dbD, xtD, xbD, crD, ceD, ctD, cbD] = request.security(syminfo.tickerid, "D", mtfPack(), gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off, calc_bars_count=300)
[neW, seW, snW, lsW, q1W, q2W, q3W, nxW, sxW, snxW, lsxW, w1W, w2W, w3W, kDW, kXW, eDW, eXW, tmW, oW, hW, lW, cW, vW, dtW, dbW, xtW, xbW, crW, ceW, ctW, cbW] = request.security(syminfo.tickerid, "W", mtfPack(), gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off, calc_bars_count=300)
[neM, seM, snM, lsM, q1M, q2M, q3M, nxM, sxM, snxM, lsxM, w1M, w2M, w3M, kDM, kXM, eDM, eXM, tmM, oM, hM, lM, cM, vM, dtM, dbM, xtM, xbM, crM, ceM, ctM, cbM] = request.security(syminfo.tickerid, "M", mtfPack(), gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off, calc_bars_count=300)
[ne_1h, se_1h, sn_1h, ls_1h, q1_1h, q2_1h, q3_1h, nx_1h, sx_1h, snx_1h, lsx_1h, w1_1h, w2_1h, w3_1h, kD_1h, kX_1h, eD_1h, eX_1h, tm_1h, o_1h, h_1h, l_1h, c_1h, v_1h, dt_1h, db_1h, xt_1h, xb_1h, cr_1h, ce_1h, ct_1h, cb_1h] = request.security(syminfo.tickerid, "60", mtfPack(), gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off, calc_bars_count=600)
int chartSec = timeframe.in_seconds(timeframe.period)
bool ok1h = chartSec <= 3600
bool ok4h = chartSec <= 14400
bool okD = chartSec <= 86400
bool okW = chartSec <= 604800
fmtP(float v) => na(v) ? "—" : str.tostring(v, format.mintick)
tpLine(string nm, float p, bool isTop) =>
nm + ": " + fmtP(p) + (not na(p) and (isTop ? close <= p : close >= p) ? " (✔ Aşıldı)" : "")
freshS(float sn) => not na(sn) and sn <= alertFresh - 1
candleLine(float o, float h, float l, float c, float v) =>
float rng = h - l
float clsPos = rng > 0 ? (c - l) / rng * 100 : 50.0
float dAcc = rng > 0 ? v * (2 * c - h - l) / rng : 0.0
string baskin = clsPos >= 66 ? "Alıcı baskın" : clsPos <= 34 ? "Satıcı baskın" : "Dengeli"
"Mum: " + candleType(o, h, l, c) + " (" + (c >= o ? "Yükselen" : "Düşen") + ") · " + baskin + " · Hacim Δ " + str.tostring(dAcc, format.volume)
slLine(float sl) =>
na(sl) ? "Stop: —" : "Stop: " + fmtP(sl) + " (" + str.tostring((sl / close - 1) * 100, "#.##") + "%)"
// Kâr hedefi satırı: fiyat, % getiri ve risk/ödül (R:R). isTop = SHORT (Iron Floor)
tpTrade(string nm, float p, float sl, bool isTop) =>
string r = nm + ": —"
if not na(p)
float rew = isTop ? close - p : p - close
float rsk = isTop ? sl - close : close - sl
float rr = rsk > 0 ? rew / rsk : na
float pc = (p / close - 1) * 100
r := nm + ": " + fmtP(p) + " (" + (pc >= 0 ? "+" : "") + str.tostring(pc, "#.##") + "%" + (na(rr) ? "" : " · R:R " + str.tostring(rr, "#.##")) + ")" + (rew <= 0 ? " ✔ Aşıldı" : "")
r
sigTxt(string lbl, bool isTop, float sn, bool ls, float p1, float p2, float p3, int sc, bool er, float sl) =>
string r = ""
if freshS(sn)
string whenTxt = sn == 0 ? "YENİ" : str.tostring(sn, "#") + " bar önce"
r := "\n" + (isTop ? "📉 SHORT · " : "📈 LONG · ") + lbl + " — " + whenTxt + (er ? " ⚡ ERKEN (onay bekleniyor)" : "") + " · " + (ls ? "★ GÜÇLÜ" : "normal") + (confOn ? " · Onay " + str.tostring(sc) + "/5" : "")
r += "\n Giriş: " + fmtP(close) + " | " + slLine(sl)
r += "\n " + tpTrade("TP1", p1, sl, isTop)
r += "\n " + tpTrade("TP2", p2, sl, isTop)
r += "\n " + tpTrade("TP3", p3, sl, isTop)
r
tfBlock(string nm, bool trig, float o, float h, float l, float c, float v, float sn, bool ls, float p1, float p2, float p3, int sc, bool er, float sl, float snx, bool lsx, float w1, float w2, float w3, int scx, bool erx, float slx) =>
string r = "▸ " + nm + (trig ? " [🔥 TETİKLEDİ]" : "") + "\n" + candleLine(o, h, l, c, v)
r += sigTxt("DİP CLIMAX", false, sn, ls, p1, p2, p3, sc, er, sl)
if alertTopOn
r += sigTxt("IRON FLOOR", true, snx, lsx, w1, w2, w3, scx, erx, slx)
r
potaBlock(string nm, bool isNew, float cTop, float cBot, bool ls, int sc, float p1, float p2, float p3, float sl, float o, float h, float l, float c, float v) =>
string r = "▸ " + nm + " — " + nmCross + " (" + nmZone + " + " + nmClimax + ")" + (isNew ? " [🔥 YENİ]" : "")
r += "\n" + candleLine(o, h, l, c, v)
r += "\n📈 LONG · Kesişim: " + fmtP(cBot) + " – " + fmtP(cTop) + " · " + (ls ? "★ GÜÇLÜ" : "normal") + (confOn ? " · Onay " + str.tostring(math.min(sc + cfBonus, 5)) + "/5 (Pota bonuslu)" : "")
r += "\n Giriş: " + fmtP(close) + " | " + slLine(sl)
r += "\n " + tpTrade("TP1", p1, sl, false)
r += "\n " + tpTrade("TP2", p2, sl, false)
r += "\n " + tpTrade("TP3", p3, sl, false)
r
// Başlıkta grafik zaman dilimi yerine TETİKLEYEN zaman dilimleri yazılır (tfs)
alertHead(string icon, string tag, string tfs, string lbl, string val) =>
icon + " " + tag + " | " + syminfo.ticker + " · " + tfs + "\n" + "Fiyat: " + fmtP(close) + " · " + str.format_time(time, "dd.MM HH:mm", syminfo.timezone) + "\n" + lbl + ": " + val + "\n──────────────"
addTf(string lst, bool cond, string nm) =>
cond ? lst + (lst == "" ? "" : " + ") + nm : lst
addTrig(string lst, bool cond, string nm, bool strongFlag) =>
cond ? lst + (lst == "" ? "" : " + ") + nm + (strongFlag ? " GÜÇLÜ CLİMAX ★" : " CLİMAX") : lst
addTrigX(string lst, bool cond, string nm, bool strongFlag) =>
cond ? lst + (lst == "" ? "" : " + ") + nm + (strongFlag ? " GÜÇLÜ IRON FLOOR ★" : " IRON FLOOR") : lst
var array<int> lastT = array.new_int(8, 0)
bool sigW = alertStrongOnly ? seW : neW
bool sigD = alertStrongOnly ? seD : neD
bool sig4 = alertStrongOnly ? seH4 : neH4
bool sigWx = alertStrongOnly ? sxW : nxW
bool sigDx = alertStrongOnly ? sxD : nxD
bool sig4x = alertStrongOnly ? sxH4 : nxH4
bool sig1 = alertStrongOnly ? se_1h : ne_1h
bool sig1x = alertStrongOnly ? sx_1h : nx_1h
bool trW = alertOn and alertWOn and okW and sigW and tmW != array.get(lastT, 0)
bool trD = alertOn and alertDOn and okD and sigD and tmD != array.get(lastT, 1)
bool tr4 = alertOn and alert4hOn and ok4h and sig4 and tm4 != array.get(lastT, 2)
bool trWx = alertOn and alertTopOn and alertWOn and okW and sigWx and tmW != array.get(lastT, 3)
bool trDx = alertOn and alertTopOn and alertDOn and okD and sigDx and tmD != array.get(lastT, 4)
bool tr4x = alertOn and alertTopOn and alert4hOn and ok4h and sig4x and tm4 != array.get(lastT, 5)
bool tr1 = alertOn and alert1hOn and ok1h and sig1 and tm_1h != array.get(lastT, 6)
bool tr1x = alertOn and alertTopOn and alert1hOn and ok1h and sig1x and tm_1h != array.get(lastT, 7)
string trigList = ""
trigList := addTrig(trigList, trW, "Haftalık", seW)
trigList := addTrig(trigList, trD, "1G", seD)
trigList := addTrig(trigList, tr4, "4S", seH4)
trigList := addTrig(trigList, tr1, "1S", se_1h)
trigList := addTrigX(trigList, trWx, "Haftalık", sxW)
trigList := addTrigX(trigList, trDx, "1G", sxD)
trigList := addTrigX(trigList, tr4x, "4S", sxH4)
trigList := addTrigX(trigList, tr1x, "1S", sx_1h)
if trW
array.set(lastT, 0, tmW)
if trD
array.set(lastT, 1, tmD)
if tr4
array.set(lastT, 2, tm4)
if trWx
array.set(lastT, 3, tmW)
if trDx
array.set(lastT, 4, tmD)
if tr4x
array.set(lastT, 5, tm4)
if tr1
array.set(lastT, 6, tm_1h)
if tr1x
array.set(lastT, 7, tm_1h)
if sendInfoAlerts and trigList != "" and not cruOnly and paN == 0
string body = ""
if alertWOn and okW
body += "\n\n" + tfBlock("HAFTALIK", trW or trWx, oW, hW, lW, cW, vW, snW, lsW, q1W, q2W, q3W, kDW, eDW, dbW, snxW, lsxW, w1W, w2W, w3W, kXW, eXW, xtW)
if alertDOn and okD
body += "\n\n" + tfBlock("GÜNLÜK", trD or trDx, oD, hD, lD, cD, vD, snD, lsD, q1D, q2D, q3D, kDD, eDD, dbD, snxD, lsxD, w1D, w2D, w3D, kXD, eXD, xtD)
if alert4hOn and ok4h
body += "\n\n" + tfBlock("4 SAATLİK", tr4 or tr4x, o4, h4, l4, c4, v4, snH4, lsH4, q14, q24, q34, kD4, eD4, dbH4, snxH4, lsxH4, w14, w24, w34, kX4, eX4, xtH4)
if alert1hOn and ok1h
body += "\n\n" + tfBlock("1 SAATLİK", tr1 or tr1x, o_1h, h_1h, l_1h, c_1h, v_1h, sn_1h, ls_1h, q1_1h, q2_1h, q3_1h, kD_1h, eD_1h, db_1h, snx_1h, lsx_1h, w1_1h, w2_1h, w3_1h, kX_1h, eX_1h, xt_1h)
string tfsC = ""
tfsC := addTf(tfsC, trW or trWx, "Haftalık")
tfsC := addTf(tfsC, trD or trDx, "1G")
tfsC := addTf(tfsC, tr4 or tr4x, "4S")
tfsC := addTf(tfsC, tr1 or tr1x, "1S")
alert(alertHead("🚨", "CLIMAX", tfsC, "Tetikleyen", trigList) + body, alert.freq_once_per_bar)
// ───── Iron Floor için ortak alan adları ─────
string nmZoneX = input.string("HAMMER", "Kırmızı direnç bölgesi adı (Iron Floor için)", group=grpNm)
string nmCrossX = input.string("FORGE", "Iron Floor ortak alan adı (direnç ∩ Iron Floor)", group=grpNm, tooltip="Iron Floor (tepe climax) alanı ile kırmızı Kale direnç bölgesi fiyatta kesişince bu adla SHORT alarmı gelir.")
// ───── Direnç Kalesi ∩ Iron Floor (her zaman diliminde ayrı hesaplanır) ─────
ironPack() =>
[cfx, stx, u1, u2, u3] = calcClimax(-close, -low, -high)
float at = ta.atr(14)
int nBx = na(stx) ? 1 : math.max(bar_index - int(stx) + 1, 1)
float hm = ta.highest(high, nBx)
float hc = ta.highest(close, nBx)
float bbx = math.min(hc, hm - bandMinAtr * at)
float btx = hm + bandDownAtr * at
float katr = ta.atr(50)
float kph = ta.pivothigh(cruPiv, cruPiv)
var array<float> rzTop = array.new_float()
var array<float> rzBot = array.new_float()
if array.size(rzTop) > 0
for j = array.size(rzTop) - 1 to 0
if close > array.get(rzTop, j)
array.remove(rzTop, j)
array.remove(rzBot, j)
if not na(kph)
float ktamp = katr[cruPiv] * cruGen
if not na(ktamp) and close <= kph
array.unshift(rzTop, kph)
array.unshift(rzBot, kph - ktamp)
if array.size(rzTop) > cruMax
array.pop(rzTop)
array.pop(rzBot)
bool xZoneL = earlyMode ? (cfx or not na(stx)) : cfx
bool hit = false
float oTop = na
float oBot = na
if xZoneL and array.size(rzTop) > 0
for j = 0 to array.size(rzTop) - 1
if bbx <= array.get(rzTop, j) and btx >= array.get(rzBot, j)
hit := true
oTop := math.min(btx, array.get(rzTop, j))
oBot := math.max(bbx, array.get(rzBot, j))
break
bool enter = hit and not hit[1]
[hit, enter, oTop, oBot]
[irW, ieW, itW, ibW ] = request.security(syminfo.tickerid, "W", ironPack(), gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off, calc_bars_count=300)
[irD, ieD, itD, ibD ] = request.security(syminfo.tickerid, "D", ironPack(), gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off, calc_bars_count=300)
[ir4, ie4, it4, ib4 ] = request.security(syminfo.tickerid, "240", ironPack(), gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off, calc_bars_count=300)
[ir1, ie1, it1, ib1 ] = request.security(syminfo.tickerid, "60", ironPack(), gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off, calc_bars_count=600)
// ───── Ortak detaylı blok (LONG ve SHORT için) ─────
zoneBlock(string nm, bool isTop, bool isNew, float cTop, float cBot, bool ls, int sc, float p1, float p2, float p3, float sl, float o, float h, float l, float c, float v, float sn, bool er) =>
string zn = isTop ? nmCrossX + " (" + nmZoneX + " + IRON FLOOR)" : nmCross + " (" + nmZone + " + " + nmClimax + ")"
string r = "▸ " + nm + " — " + zn + (isNew ? " [🔥 YENİ]" : "")
r += "\n" + candleLine(o, h, l, c, v)
r += "\n" + (isTop ? "📉 SHORT" : "📈 LONG") + " · " + (ls ? "★ GÜÇLÜ (0 çizgisi / PDA bölgesinde)" : "normal") + (er ? " · ⚡ ERKEN (onay bekleniyor)" : " · onaylı")
r += "\n Kesişim bölgesi: " + fmtP(cBot) + " – " + fmtP(cTop)
r += "\n Climax yaşı: " + (na(sn) ? "—" : sn == 0 ? "YENİ" : str.tostring(sn, "#") + " bar önce") + (confOn ? " · Onay " + str.tostring(math.min(sc + cfBonus, 5)) + "/5 (ortak alan bonuslu)" : "")
r += "\n Giriş: " + fmtP(close) + " | " + slLine(sl)
r += "\n " + tpTrade("TP1", p1, sl, isTop)
r += "\n " + tpTrade("TP2", p2, sl, isTop)
r += "\n " + tpTrade("TP3", p3, sl, isTop)
r
string cMsg = "" // CRUCIBLE (LONG) mesajı
string xMsg = "" // FORGE (SHORT) mesajı
// ───── LONG: Anvil ∩ Furnace (CRUCIBLE) ─────
var array<int> lastC = array.new_int(4, 0)
bool trCW = alertOn and cruOn and alertWOn and okW and ceW and tmW != array.get(lastC, 0)
bool trCD = alertOn and cruOn and alertDOn and okD and ceD and tmD != array.get(lastC, 1)
bool trC4 = alertOn and cruOn and alert4hOn and ok4h and ceH4 and tm4 != array.get(lastC, 2)
bool trC1 = alertOn and cruOn and alert1hOn and ok1h and ce_1h and tm_1h != array.get(lastC, 3)
if trCW
array.set(lastC, 0, tmW)
if trCD
array.set(lastC, 1, tmD)
if trC4
array.set(lastC, 2, tm4)
if trC1
array.set(lastC, 3, tm_1h)
if trCW or trCD or trC4 or trC1
string cTrig = ""
cTrig := addTf(cTrig, trCW, "Haftalık")
cTrig := addTf(cTrig, trCD, "1G")
cTrig := addTf(cTrig, trC4, "4S")
cTrig := addTf(cTrig, trC1, "1S")
string cNow = ""
cNow := addTf(cNow, alertWOn and okW and crW, "Haftalık")
cNow := addTf(cNow, alertDOn and okD and crD, "1G")
cNow := addTf(cNow, alert4hOn and ok4h and crH4, "4S")
cNow := addTf(cNow, alert1hOn and ok1h and cr_1h, "1S")
bool potaStr = (trCW and lsW) or (trCD and lsD) or (trC4 and lsH4) or (trC1 and ls_1h)
string cBody = ""
if alertWOn and okW and crW
cBody += "\n\n" + zoneBlock("HAFTALIK", false, trCW, ctW, cbW, lsW, kDW, q1W, q2W, q3W, dbW, oW, hW, lW, cW, vW, snW, eDW)
if alertDOn and okD and crD
cBody += "\n\n" + zoneBlock("GÜNLÜK", false, trCD, ctD, cbD, lsD, kDD, q1D, q2D, q3D, dbD, oD, hD, lD, cD, vD, snD, eDD)
if alert4hOn and ok4h and crH4
cBody += "\n\n" + zoneBlock("4 SAATLİK", false, trC4, ctH4, cbH4, lsH4, kD4, q14, q24, q34, dbH4, o4, h4, l4, c4, v4, snH4, eD4)
if alert1hOn and ok1h and cr_1h
cBody += "\n\n" + zoneBlock("1 SAATLİK", false, trC1, ct_1h, cb_1h, ls_1h, kD_1h, q1_1h, q2_1h, q3_1h, db_1h, o_1h, h_1h, l_1h, c_1h, v_1h, sn_1h, eD_1h)
cMsg := (alertHead("🔷", nmCross + " · LONG" + (potaStr ? " ★ GÜÇLÜ" : ""), cTrig, "Yön", "LONG (" + nmZone + " + " + nmClimax + ")") + "\nŞu an " + nmCross + "'da: " + cNow + cBody)
// ───── SHORT: Direnç Kalesi ∩ Iron Floor (FORGE) ─────
var array<int> lastCX = array.new_int(4, 0)
bool trXW = alertOn and cruXOn and alertWOn and okW and ieW and tmW != array.get(lastCX, 0)
bool trXD = alertOn and cruXOn and alertDOn and okD and ieD and tmD != array.get(lastCX, 1)
bool trX4 = alertOn and cruXOn and alert4hOn and ok4h and ie4 and tm4 != array.get(lastCX, 2)
bool trX1 = alertOn and cruXOn and alert1hOn and ok1h and ie1 and tm_1h != array.get(lastCX, 3)
if trXW
array.set(lastCX, 0, tmW)
if trXD
array.set(lastCX, 1, tmD)
if trX4
array.set(lastCX, 2, tm4)
if trX1
array.set(lastCX, 3, tm_1h)
if trXW or trXD or trX4 or trX1
string xTrig = ""
xTrig := addTf(xTrig, trXW, "Haftalık")
xTrig := addTf(xTrig, trXD, "1G")
xTrig := addTf(xTrig, trX4, "4S")
xTrig := addTf(xTrig, trX1, "1S")
string xNow = ""
xNow := addTf(xNow, alertWOn and okW and irW, "Haftalık")
xNow := addTf(xNow, alertDOn and okD and irD, "1G")
xNow := addTf(xNow, alert4hOn and ok4h and ir4, "4S")
xNow := addTf(xNow, alert1hOn and ok1h and ir1, "1S")
bool potaStrX = (trXW and lsxW) or (trXD and lsxD) or (trX4 and lsxH4) or (trX1 and lsx_1h)
string xBody = ""
if alertWOn and okW and irW
xBody += "\n\n" + zoneBlock("HAFTALIK", true, trXW, itW, ibW, lsxW, kXW, w1W, w2W, w3W, xtW, oW, hW, lW, cW, vW, snxW, eXW)
if alertDOn and okD and irD
xBody += "\n\n" + zoneBlock("GÜNLÜK", true, trXD, itD, ibD, lsxD, kXD, w1D, w2D, w3D, xtD, oD, hD, lD, cD, vD, snxD, eXD)
if alert4hOn and ok4h and ir4
xBody += "\n\n" + zoneBlock("4 SAATLİK", true, trX4, it4, ib4, lsxH4, kX4, w14, w24, w34, xtH4, o4, h4, l4, c4, v4, snxH4, eX4)
if alert1hOn and ok1h and ir1
xBody += "\n\n" + zoneBlock("1 SAATLİK", true, trX1, it1, ib1, lsx_1h, kX_1h, w1_1h, w2_1h, w3_1h, xt_1h, o_1h, h_1h, l_1h, c_1h, v_1h, snx_1h, eX_1h)
xMsg := (alertHead("🔻", nmCrossX + " · SHORT" + (potaStrX ? " ★ GÜÇLÜ" : ""), xTrig, "Yön", "SHORT (" + nmZoneX + " + IRON FLOOR)") + "\nŞu an " + nmCrossX + "'da: " + xNow + xBody)
// Tek bildirim: aynı barda hem LONG (CRUCIBLE) hem SHORT (FORGE) varsa ikisi birlikte gelir
bool potaLongMsg = input.bool(false, "Uzun çoklu zaman dilimi kesişim mesajını da gönder (1S+4S+G+H blokları)", group=grpAlert)
if sendInfoAlerts and potaLongMsg and paN == 0 and (cMsg != "" or xMsg != "")
alert(cMsg + (cMsg != "" and xMsg != "" ? "\n\n" : "") + xMsg, alert.freq_once_per_bar)
// ═══════════════════════════════════════════════════════════════════
// PINE SCREENER (1 / 0 çıktı; Screener'da "= 1" filtresi koy)
// DİP: 1-4 sabit, 5-8 ayarlanabilir N
// TEPE: 9-12 sabit, 13-16 ayarlanabilir N
// ═══════════════════════════════════════════════════════════════════
bool lcStrong = not na(lcBar) and f_isStrong(lcTop, lcBot)
float lcAge = na(lcBar) ? na : bar_index - lcBar
bool xcStrong = not na(xcBar) and f_isStrongX(xcTop, xcBot)
float xcAge = na(xcBar) ? na : bar_index - xcBar
plot(lcAge == 0 and lcStrong ? 1 : 0, "1) Güçlü Climax - YENİ", display=display.data_window)
plot(lcAge == 1 and lcStrong ? 1 : 0, "2) Güçlü Climax - 1 BAR ÖNCE", display=display.data_window)
plot(lcAge == 0 ? 1 : 0, "3) Climax - YENİ", display=display.data_window)
plot(lcAge == 1 ? 1 : 0, "4) Climax - 1 BAR ÖNCE", display=display.data_window)
string grpScr = "7. Screener (ayarlanabilir arama)"
int scrN = input.int(2, "N: climax alanı oluştuktan kaç bar sonra (0 = yeni, 1 = 1 bar önce...)", minval=0, maxval=30, group=grpScr)
plot(lcAge == scrN and lcStrong ? 1 : 0, "5) Güçlü Climax - TAM N BAR ÖNCE", display=display.data_window)
plot(lcAge == scrN ? 1 : 0, "6) Climax - TAM N BAR ÖNCE", display=display.data_window)
plot(not na(lcAge) and lcAge <= scrN and lcStrong ? 1 : 0, "7) Güçlü Climax - SON N BAR İÇİNDE", display=display.data_window)
plot(not na(lcAge) and lcAge <= scrN ? 1 : 0, "8) Climax - SON N BAR İÇİNDE", display=display.data_window)
plot(xcAge == 0 and xcStrong ? 1 : 0, "9) Güçlü Iron Floor - YENİ", display=display.data_window)
plot(xcAge == 1 and xcStrong ? 1 : 0, "10) Güçlü Iron Floor - 1 BAR ÖNCE", display=display.data_window)
plot(xcAge == 0 ? 1 : 0, "11) Iron Floor - YENİ", display=display.data_window)
plot(xcAge == 1 ? 1 : 0, "12) Iron Floor - 1 BAR ÖNCE", display=display.data_window)
plot(xcAge == scrN and xcStrong ? 1 : 0, "13) Güçlü Iron Floor - TAM N BAR ÖNCE", display=display.data_window)
plot(xcAge == scrN ? 1 : 0, "14) Iron Floor - TAM N BAR ÖNCE", display=display.data_window)
plot(not na(xcAge) and xcAge <= scrN and xcStrong ? 1 : 0, "15) Güçlü Iron Floor - SON N BAR İÇİNDE", display=display.data_window)
plot(not na(xcAge) and xcAge <= scrN ? 1 : 0, "16) Iron Floor - SON N BAR İÇİNDE", display=display.data_window)
plot(dBest, "17) Dip onay skoru (0-5)", display=display.data_window)
plot(tBest, "18) Iron Floor onay skoru (0-5)", display=display.data_window)
// ─── ÇOKLU ZAMAN DİLİMİ TARAMA (Aylık / Haftalık / Günlük / 4S / 1S) ────────────────────────────
// Screener'da zaman dilimini "1 Gün" seç. Diğer zaman dilimleri kodun içinden çekilir.
// "Alanda" = o zaman diliminde son N bar içinde climax alanı oluşmuş (+ isteğe bağlı: fiyat şu an bandın içinde).
int scrNM = input.int(1, "Aylık N: son kaç ay içinde oluştu (0 = bu ay)", minval=0, maxval=12, group=grpScr)
int scrNW = input.int(1, "Haftalık N: son kaç hafta içinde oluştu", minval=0, maxval=26, group=grpScr)
int scrN4 = input.int(2, "4 Saatlik N: son kaç 4S bar içinde oluştu", minval=0, maxval=60, group=grpScr)
int scrN1 = input.int(3, "1 Saatlik N: son kaç 1S bar içinde oluştu", minval=0, maxval=100, group=grpScr)
// Günlük N: yukarıdaki "N" girdisi (scrN)
bool scrInBand = input.bool(true, "Fiyat şu an climax bandının İÇİNDE olsun", group=grpScr, tooltip="Açık: son kapanış, o zaman diliminin climax bandının (alt-üst) içindeyse sayılır. Kapalı: sadece 'N bar içinde oluştu' yeterli.")
bool scrOnlyStr = input.bool(false, "Sadece GÜÇLÜ climax say (0 çizgisi / PDA)", group=grpScr)
bool scrUseM = input.bool(true, "Çoklu tarama (34/35): Aylık alanda olsun", group=grpScr)
bool scrUseW = input.bool(false, "Çoklu tarama (34/35): Haftalık alanda olsun", group=grpScr)
bool scrUseD = input.bool(true, "Çoklu tarama (34/35): Günlük alanda olsun", group=grpScr)
bool scrUse4 = input.bool(false, "Çoklu tarama (34/35): 4 Saatlik alanda olsun", group=grpScr)
bool scrUse1 = input.bool(false, "Çoklu tarama (34/35): 1 Saatlik alanda olsun", group=grpScr)
f_inArea(float sn, int n, bool ls, float tp, float bt0) =>
bool okAge = not na(sn) and sn <= n and (not scrOnlyStr or ls)
bool okBnd = not scrInBand or (not na(tp) and not na(bt0) and close >= bt0 and close <= tp)
okAge and okBnd
// DİP climax alanı (her zaman dilimi için)
bool scDipM = f_inArea(snM, scrNM, lsM, dtM, dbM)
bool scDipW = f_inArea(snW, scrNW, lsW, dtW, dbW)
bool scDipD = f_inArea(snD, scrN, lsD, dtD, dbD)
bool scDip4 = f_inArea(snH4, scrN4, lsH4, dtH4, dbH4)
bool scDip1 = f_inArea(sn_1h, scrN1, ls_1h, dt_1h, db_1h)
// TEPE (Iron Floor) alanı
bool scIronM = f_inArea(snxM, scrNM, lsxM, xtM, xbM)
bool scIronW = f_inArea(snxW, scrNW, lsxW, xtW, xbW)
bool scIronD = f_inArea(snxD, scrN, lsxD, xtD, xbD)
bool scIron4 = f_inArea(snxH4, scrN4, lsxH4, xtH4, xbH4)
bool scIron1 = f_inArea(snx_1h, scrN1, lsx_1h, xt_1h, xb_1h)
bool uAny = scrUseM or scrUseW or scrUseD or scrUse4 or scrUse1
bool dipAll = uAny and (not scrUseM or scDipM) and (not scrUseW or scDipW) and (not scrUseD or scDipD) and (not scrUse4 or scDip4) and (not scrUse1 or scDip1)
bool ironAll = uAny and (not scrUseM or scIronM) and (not scrUseW or scIronW) and (not scrUseD or scIronD) and (not scrUse4 or scIron4) and (not scrUse1 or scIron1)
plot(scDipM ? 1 : 0, "24) DİP Climax alanı: AYLIK", display=display.data_window)
plot(scDipW ? 1 : 0, "25) DİP Climax alanı: HAFTALIK", display=display.data_window)
plot(scDipD ? 1 : 0, "26) DİP Climax alanı: GÜNLÜK", display=display.data_window)
plot(scDip4 ? 1 : 0, "27) DİP Climax alanı: 4 SAATLİK", display=display.data_window)
plot(scDip1 ? 1 : 0, "28) DİP Climax alanı: 1 SAATLİK", display=display.data_window)
plot(scIronM ? 1 : 0, "29) IRON FLOOR alanı: AYLIK", display=display.data_window)
plot(scIronW ? 1 : 0, "30) IRON FLOOR alanı: HAFTALIK", display=display.data_window)
plot(scIronD ? 1 : 0, "31) IRON FLOOR alanı: GÜNLÜK", display=display.data_window)
plot(scIron4 ? 1 : 0, "32) IRON FLOOR alanı: 4 SAATLİK", display=display.data_window)
plot(scIron1 ? 1 : 0, "33) IRON FLOOR alanı: 1 SAATLİK", display=display.data_window)
plot(dipAll ? 1 : 0, "34) ÇOKLU DİP: seçili TÜM zaman dilimleri alanda", display=display.data_window)
plot(ironAll ? 1 : 0, "35) ÇOKLU IRON FLOOR: seçili TÜM zaman dilimleri alanda", display=display.data_window)
// =================================================================================================
// =================================================================================================
// =================================================================================================
// ================================= 1. GİRDİLER (INPUTS) ==========================================
// =================================================================================================
grp_kale = "Kale Ayarları / Kale Settings"
kale_goster = input.bool(true, title="Kale Bölgelerini Göster / Show Kale Zones", group=grp_kale)
kale_pivot_uzunluk = 3
kale_bolge_gen = 5
kale_uzatma = 3
kale_maks_kutu = 15
grp_gz = "Anvil (Kale Destek / Yeşil Bant)"
gz_goster = input.bool(true, "Anvil etiketini göster", group=grp_gz)
gz_padL = input.int(6, "Sola genişletme (bar)", minval=0, maxval=100, group=grp_gz, tooltip="Yeşil destek bandının sol kenarı, pivot dibinden bu kadar bar geriye uzar.")
gz_padR = input.int(8, "Sağa genişletme (bar)", minval=0, maxval=100, group=grp_gz, tooltip="Yeşil destek bandının sağ kenarı, son barın bu kadar bar ilerisine uzar. Eski sürümde sabit 3 barda.")
gz_lblCol = input.color(#22C55E, "Anvil etiket rengi", group=grp_gz)
gz_alertOn = input.bool(true, "Anvil alert (bölgeye giriş / dönüş)", group=grp_gz)
grp_kale_renk = "Kale Renk Ayarları / Kale Color Settings"
kale_direnc_dolgu = input.color(color.rgb(255, 0, 0, 85), title='Direnç Kalesi / Resistance Fort', group=grp_kale_renk, inline='1')
kale_destek_dolgu = input.color(color.rgb(41, 255, 62, 85), title='Anvil (Destek Kalesi) / Support Fort', group=grp_kale_renk, inline='2')
kale_stil_sec = input.string("Kesik Çizgi / Dashed", title="Sur Çizgi Stili / Wall Line Style", options=["Kesik Çizgi / Dashed", "Noktalı Çizgi / Dotted", "Düz Çizgi / Solid"], group=grp_kale_renk)
kale_cerceve_kalin = input.int(2, title="Sur Çizgi Kalınlığı / Wall Line Width", minval=1, maxval=10, group=grp_kale_renk)
kale_cizgi_stili = kale_stil_sec == "Kesik Çizgi / Dashed" ? line.style_dashed : kale_stil_sec == "Noktalı Çizgi / Dotted" ? line.style_dotted : line.style_solid
// =================================================================================================
// ========================== 2. TİPLER VE FONKSİYONLAR (TYPES & FUNCTIONS) ========================
// =================================================================================================
type KaleBolge
box bx
float tavan
float taban
int yon // 1 = Direnç/Resistance, -1 = Destek/Support
label lb // Anvil etiketi (sadece destek bölgelerinde dolu)
// Kale mesafe sıralaması için özel tip / Custom type for Kale distance sorting
type KaleMesafe
KaleBolge bolge
float uzaklik
kale_ust_uste_mi(float yeni_orta, int yeni_yon, KaleBolge[] liste, float esik) =>
bool ust_uste = false
if array.size(liste) > 0
for i = 0 to array.size(liste) - 1
kb = array.get(liste, i)
if kb.yon == yeni_yon
mevcut_orta = (kb.tavan + kb.taban) / 2
if math.abs(mevcut_orta - yeni_orta) < esik
ust_uste := true
break
ust_uste
// =================================================================================================
// ========================== 3. GÜNCELLEME BARI / UPDATE BAR ======================================
// =================================================================================================
bool kale_guncelleme_bari = barstate.islastconfirmedhistory or (barstate.islast and barstate.isconfirmed)
// =================================================================================================
// ============================== 4. KALE SİSTEMİ (DESTEK & DİRENÇ BÖLGELERİ) ======================
// =================================================================================================
var KaleBolge[] kaleListe = array.new<KaleBolge>()
var KaleBolge[] kaleGecici = array.new<KaleBolge>()
var KaleMesafe[] kaleMesafeListe = array.new<KaleMesafe>()
kale_atr = ta.atr(50)
kale_tepe = ta.pivothigh(kale_pivot_uzunluk, kale_pivot_uzunluk)
kale_dip = ta.pivotlow(kale_pivot_uzunluk, kale_pivot_uzunluk)
// 1. Bölgeleri uzatma ve yıkılma (kırılma) kontrolü / Zone extension and break control
if array.size(kaleListe) > 0
for i = array.size(kaleListe) - 1 to 0
kb = array.get(kaleListe, i)
kale_yikildi = false
box.set_right(kb.bx, bar_index + (kb.yon == -1 ? gz_padR : kale_uzatma))
if barstate.islast and not na(kb.lb)
label.set_x(kb.lb, math.round((box.get_left(kb.bx) + box.get_right(kb.bx)) / 2.0))
if kb.yon == 1 and close > kb.tavan
kale_yikildi := true
else if kb.yon == -1 and close < kb.taban
kale_yikildi := true
if kale_yikildi
if not na(kb.lb)
label.delete(kb.lb)
box.delete(kb.bx)
array.remove(kaleListe, i)
// 2. Yeni pivot tespit edildiğinde bölgelerin inşası / Zone creation on new pivot detection
bool kale_yeni_eklendi = false
if kale_goster and barstate.isconfirmed
kale_esik = kale_atr * 1.5
label bosEtiket = na
kale_tampon = kale_atr[kale_pivot_uzunluk] * (kale_bolge_gen / 10)
if not na(kale_tepe)
kale_pivot_bar = bar_index - kale_pivot_uzunluk
yeni_tavan = kale_tepe
yeni_taban = kale_tepe - kale_tampon
yeni_orta = (yeni_tavan + yeni_taban) / 2
if not na(kale_tampon) and close <= yeni_tavan and not kale_ust_uste_mi(yeni_orta, 1, kaleListe, kale_esik)
yeniBolge = box.new(left=kale_pivot_bar, top=yeni_tavan, right=bar_index + kale_uzatma, bottom=yeni_taban, border_color=na, border_style=kale_cizgi_stili, border_width=kale_cerceve_kalin, bgcolor=na)
label yeniEtiketR = label.new(math.round((kale_pivot_bar + bar_index + kale_uzatma) / 2.0), yeni_tavan, "", style=label.style_label_down, color=color.new(color.black, 100), textcolor=color.new(#EF4444, 0), size=size.small, textalign=text.align_center)
array.unshift(kaleListe, KaleBolge.new(yeniBolge, yeni_tavan, yeni_taban, 1, yeniEtiketR))
kale_yeni_eklendi := true
if not na(kale_dip)
kale_pivot_bar = bar_index - kale_pivot_uzunluk
yeni_taban = kale_dip
yeni_tavan = kale_dip + kale_tampon
yeni_orta = (yeni_tavan + yeni_taban) / 2
if not na(kale_tampon) and close >= yeni_taban and not kale_ust_uste_mi(yeni_orta, -1, kaleListe, kale_esik)
int gz_solX = math.max(kale_pivot_bar - gz_padL, 0)
int gz_sagX = bar_index + gz_padR
yeniBolge = box.new(left=gz_solX, top=yeni_tavan, right=gz_sagX, bottom=yeni_taban, border_color=na, border_style=kale_cizgi_stili, border_width=kale_cerceve_kalin, bgcolor=na)
label yeniEtiket = label.new(math.round((gz_solX + gz_sagX) / 2.0), yeni_taban, "", style=label.style_label_up, color=color.new(color.black, 100), textcolor=gz_lblCol, size=size.small, textalign=text.align_center)
array.unshift(kaleListe, KaleBolge.new(yeniBolge, yeni_tavan, yeni_taban, -1, yeniEtiket))
kale_yeni_eklendi := true
// 3. Hafıza yönetimi (Çok fazla bölgeyi bellekte tutmamak için) / Memory management
if kale_yeni_eklendi and array.size(kaleListe) > 0
array.clear(kaleGecici)
int direnc_adet = 0
int destek_adet = 0
for i = 0 to array.size(kaleListe) - 1
kb = array.get(kaleListe, i)
bool saklanacak_mi = false
if kb.yon == 1
if direnc_adet < kale_maks_kutu
saklanacak_mi := true
direnc_adet += 1
else if kb.yon == -1
if destek_adet < kale_maks_kutu
saklanacak_mi := true
destek_adet += 1
if saklanacak_mi
array.push(kaleGecici, kb)
else
if not na(kb.lb)
label.delete(kb.lb)
box.delete(kb.bx)
array.clear(kaleListe)
if array.size(kaleGecici) > 0
for i = 0 to array.size(kaleGecici) - 1
array.push(kaleListe, array.get(kaleGecici, i))
// 4. Görünürlük kontrolü (Sadece fiyata en yakın olanları boya) / Visibility control (Closest to price)
if kale_guncelleme_bari
array.clear(kaleMesafeListe)
if kale_guncelleme_bari and array.size(kaleListe) > 0 and kale_goster
for i = 0 to array.size(kaleListe) - 1
kb = array.get(kaleListe, i)
float kale_merkez = (kb.tavan + kb.taban) / 2.0
float kale_uzak = math.abs(close - kale_merkez)
array.push(kaleMesafeListe, KaleMesafe.new(kb, kale_uzak))
// Mesafeye göre sıralama (Bubble Sort) / Distance Sorting
int boyut = array.size(kaleMesafeListe)
if boyut > 1
for i = 0 to boyut - 2
for j = 0 to boyut - 2 - i
KaleMesafe sol = array.get(kaleMesafeListe, j)
KaleMesafe sag = array.get(kaleMesafeListe, j + 1)
if sol.uzaklik > sag.uzaklik
array.set(kaleMesafeListe, j, sag)
array.set(kaleMesafeListe, j + 1, sol)
// Gösterilecekleri seç / Select zones to show
KaleBolge[] kale_secilen = array.new<KaleBolge>()
if boyut > 0
array.push(kale_secilen, array.get(kaleMesafeListe, 0).bolge)
if boyut > 1
array.push(kale_secilen, array.get(kaleMesafeListe, 1).bolge)
int yon1 = array.get(kaleMesafeListe, 0).bolge.yon
int yon2 = array.get(kaleMesafeListe, 1).bolge.yon
// İlk iki bölgenin yönü AYNIYSA ve hafızada 2'den fazla bölge varsa 3.yü ara / If first two are same side, find 3rd
if yon1 == yon2 and boyut > 2
for i = 2 to boyut - 1
if array.get(kaleMesafeListe, i).bolge.yon != yon1
array.push(kale_secilen, array.get(kaleMesafeListe, i).bolge)
break
// Renkleri uygula veya gizle / Apply Colors or Hide
for i = 0 to array.size(kaleListe) - 1
kb = array.get(kaleListe, i)
bool boyanacak_mi = false
if array.size(kale_secilen) > 0
for j = 0 to array.size(kale_secilen) - 1
hedef = array.get(kale_secilen, j)
// Kutu objesini değil, koordinatlarını karşılaştırıyoruz / Compare coordinates, not object reference
if kb.yon == hedef.yon and kb.tavan == hedef.tavan and kb.taban == hedef.taban
boyanacak_mi := true
break
if boyanacak_mi
if kb.yon == 1
box.set_top(kb.bx, kb.tavan)
box.set_bottom(kb.bx, kb.taban)
box.set_bgcolor(kb.bx, kale_direnc_dolgu)
if not na(kb.lb)
label.set_y(kb.lb, kb.tavan)
label.set_text(kb.lb, gz_goster ? nmZoneX : "")
else
box.set_top(kb.bx, kb.tavan)
box.set_bottom(kb.bx, kb.taban)
box.set_bgcolor(kb.bx, kale_destek_dolgu)
if not na(kb.lb)
label.set_y(kb.lb, kb.taban)
label.set_text(kb.lb, gz_goster ? nmZone : "")
else
// Boyanmayan (uzak) bölgeler fiyat ölçeğini germesin: görünmez kutuyu güncel fiyata daralt
// (gerçek sınırlar kb.tavan / kb.taban içinde durur, boyanınca geri yüklenir)
box.set_top(kb.bx, close)
box.set_bottom(kb.bx, close)
box.set_bgcolor(kb.bx, na)
box.set_border_color(kb.bx, na)
if not na(kb.lb)
label.set_y(kb.lb, close)
label.set_text(kb.lb, "")
// =================================================================================================
// ===================== ANVIL: SİNYAL MOTORU (SCREENER + ALERT) =============================
// =================================================================================================
// Anvil = yeşil Kale Destek bölgesi. Fiyat bölgeye girerse / dokunup dönerse sinyal üretilir.
float cfxTop = na
float cfxBot = na
bool cfxNow = false // Iron Floor alanı aktif + kırmızı direnç (Hammer) bölgesiyle fiyatta kesişiyor (FORGE)
bool cfNow = false // dip climax alanı aktif + yeşil destek bölgesiyle fiyatta kesişiyor
float cfTop = na
float cfBot = na
bool gzTouch = false // low bölgeye girdi ve kapanış bölge tabanının üstünde (bölge yıkılmadı)
bool gzRev = false // bölgeye dokundu + bölge tavanının üstünde yeşil kapanış = DÖNÜŞ
float gzTop = na
float gzBot = na
if kale_goster and array.size(kaleListe) > 0
for i = 0 to array.size(kaleListe) - 1
KaleBolge kg = array.get(kaleListe, i)
if kg.yon == 1 and xZone and xBandBot <= kg.tavan and xBandTop >= kg.taban and not cfxNow
cfxNow := true
cfxTop := math.min(xBandTop, kg.tavan)
cfxBot := math.max(xBandBot, kg.taban)
if kg.yon == -1 and cZone and bandBot <= kg.tavan and bandTop >= kg.taban and not cfNow
cfNow := true
cfTop := math.min(bandTop, kg.tavan)
cfBot := math.max(bandBot, kg.taban)
if kg.yon == -1 and low <= kg.tavan and high >= kg.taban and close >= kg.taban
gzTouch := true
gzTop := kg.tavan
gzBot := kg.taban
if close > kg.tavan and close > open
gzRev := true
bool gzEnter = gzTouch and not gzTouch[1]
int gzSince = ta.barssince(gzTouch)
int gzRevSince = ta.barssince(gzRev)
// Pine Screener çıktıları (1 / 0). N değeri, 7. bölümdeki "N" girdisiyle ortaktır (scrN).
plot(gzTouch ? 1 : 0, "19) Anvil - fiyat bölgede", display=display.data_window)
plot(gzEnter ? 1 : 0, "20) Anvil - bölgeye YENİ giriş", display=display.data_window)
plot(gzRev ? 1 : 0, "21) Anvil - DÖNÜŞ (dokundu + yeşil mum)", display=display.data_window)
plot(not na(gzSince) and gzSince <= scrN ? 1 : 0, "22) Anvil - SON N BAR İÇİNDE bölgeye girdi", display=display.data_window)
plot(not na(gzRevSince) and gzRevSince <= scrN ? 1 : 0, "23) Anvil - SON N BAR İÇİNDE dönüş", display=display.data_window)
bool cfEnter = cfNow and not cfNow[1]
bool cfxEnter = cfxNow and not cfxNow[1]
// ───── KESİŞİM ALARMLARI (grafiğin kendi zaman dilimi) ─────
// Alarm listesinden seçilebilen LONG / SHORT alarmları. Mesajdaki Stop/TP rakamları plot'lardan gelir.
bool ksL = cfEnter or (not cfxEnter and cfNow)
plot(cfNow or cfxNow ? (ksL ? bandBot : xBandTop) : na, "KS Stop", display=display.data_window, format=format.price)
plot(cfNow or cfxNow ? (ksL ? cTP1 : xTP1) : na, "KS TP1", display=display.data_window, format=format.price)
plot(cfNow or cfxNow ? (ksL ? cTP2 : xTP2) : na, "KS TP2", display=display.data_window, format=format.price)
plot(cfNow or cfxNow ? (ksL ? cTP3 : xTP3) : na, "KS TP3", display=display.data_window, format=format.price)
plot(cfNow and cfxNow ? 2 : cfNow ? 1 : cfxNow ? -1 : 0, "52) KESİŞİMDE: 1=LONG (CRUCIBLE), -1=SHORT (FORGE), 2=ikisi", display=display.data_window)
// [STRATEGY] alertcondition(cfEnter, "KESİŞİM LONG: CRUCIBLE (Furnace + Anvil)", '📈 LONG · {{ticker}} · {{interval}}\nCRUCIBLE (ANVIL + FURNACE) kesişimi\nGiriş: {{close}}\nStop: {{plot("KS Stop")}}\nTP1: {{plot("KS TP1")}}\nTP2: {{plot("KS TP2")}}\nTP3: {{plot("KS TP3")}}')
// [STRATEGY] alertcondition(cfxEnter, "KESİŞİM SHORT: FORGE (Iron Floor + Hammer)", '📉 SHORT · {{ticker}} · {{interval}}\nFORGE (HAMMER + IRON FLOOR) kesişimi\nGiriş: {{close}}\nStop: {{plot("KS Stop")}}\nTP1: {{plot("KS TP1")}}\nTP2: {{plot("KS TP2")}}\nTP3: {{plot("KS TP3")}}')
// ───── TEK ALARM (alert()): LONG ve SHORT kesişim, sade mesaj: yön + giriş + stop + TP ─────
bool ksOn = input.bool(true, "Sade kesişim alarmı (alert): yön + giriş + stop + TP", group=grpAlert)
bool paShort = true // ALARM 1/2: SHORT sinyalleri her zaman dahil
bool pa1Str = true // ALARM 1: sadece GÜÇLÜ alanlar (0 çizgisi / PDA)
int paMinSc = input.int(0, "Mod 3/4 Min Onay Skoru (0 = Filtre Kapalı)", minval=0, maxval=5, group=grpAlert, tooltip="0: Filtre kapalı (önerilen, tüm CRUCIBLE/FORGE sinyalleri yakalanır). 1-5: Sadece bu skoru geçen sinyaller.")
plot(paN, "Alarm modu (0=Kapalı, 1-4=ALARM 1-4)", display=display.data_window)
ksBlock(bool isTop, string nm, string zn, float sl, float p1, float p2, float p3, int sc, bool st) =>
string r = (isTop ? "📉 SHORT" : "📈 LONG") + " · " + syminfo.ticker + " · " + tfName(timeframe.period) + (st ? " · ★ GÜÇLÜ" : "")
r += "\n" + nm + " (" + zn + ")" + (confOn ? " · Onay " + str.tostring(sc) + "/5" : "")
r += "\nGiriş: " + fmtP(close)
r += "\n" + slLine(sl)
r += "\n" + tpTrade("TP1", p1, sl, isTop)
r += "\n" + tpTrade("TP2", p2, sl, isTop)
r += "\n" + tpTrade("TP3", p3, sl, isTop)
r
string ksMsg = ""
if alertOn and ksOn and cruOn and cfEnter
ksMsg := ksBlock(false, nmCross, nmZone + " + " + nmClimax, bandBot, cTP1, cTP2, cTP3, math.min(dBest + cfBonus, 5), isStrong)
if alertOn and ksOn and cruXOn and cfxEnter
ksMsg := ksMsg + (ksMsg != "" ? "\n\n" : "") + ksBlock(true, nmCrossX, nmZoneX + " + IRON FLOOR", xBandTop, xTP1, xTP2, xTP3, math.min(tBest + cfBonus, 5), isStrongX)
if sendInfoAlerts and ksMsg != "" and paN == 0
alert(ksMsg, alert.freq_once_per_bar)
plot(cfNow ? 1 : 0, "36) ORTAK ALAN: destek bölgesi + climax alanı kesişiyor", display=display.data_window)
plot(cfEnter ? 1 : 0, "37) ORTAK ALAN: YENİ oluştu", display=display.data_window)
// Alert (alertcondition: Alert penceresinden seçilir)
// [STRATEGY] alertcondition(gzEnter, "Anvil: bölgeye giriş", "Anvil (yeşil destek bandı) bölgesine girildi")
// [STRATEGY] alertcondition(gzRev, "Anvil: DÖNÜŞ", "Anvil dönüşü: bölgeye dokundu, yeşil mum kapandı")
// Alert (alert(): "Herhangi bir alert() fonksiyon çağrısı" seçeneğiyle gelir, zengin metin içerir)
if sendInfoAlerts and gz_alertOn and not cruOnly and paN == 0 and (gzEnter or gzRev)
string gzMsg = alertHead("🟢", nmZone, timeframe.period, "Durum", gzRev ? "DÖNÜŞ (bölgeye dokundu, yeşil mum kapandı)" : "Bölgeye giriş (onay bekleniyor)") + "\nBölge: " + fmtP(gzBot) + " – " + fmtP(gzTop) + "\nGiriş: " + fmtP(close) + " | " + slLine(gzBot)
alert(gzMsg, alert.freq_once_per_bar_close)
// ───── ORTAK ALAN KUTULARI (grafikte ayrı renk + ortak ad) ─────
// CRUCIBLE : dip climax alanı (FURNACE) ∩ yeşil destek bölgesi (ANVIL)
// FORGE : Iron Floor (tepe climax) alanı ∩ kırmızı direnç bölgesi (HAMMER)
// İki ortak alanda da onay puanına +cfBonus eklenir (en fazla 5/5).
var box cfBox = na
var label cfLbl = na
var box cfxBox = na
var label cfxLbl = na
float cfScoreV = na // CRUCIBLE puanı (bonuslu)
float cfAge = na // CRUCIBLE: ortak alana İLK giren mumun yaşı (0 = bu bar)
float cfMove = na // CRUCIBLE: giriş mumu kapanışından bu yana % değişim
float cfxScoreV = na // FORGE puanı (bonuslu)
float cfxAge = na // FORGE: ortak alana İLK giren mumun yaşı
if barstate.islast
if not na(cfBox)
box.delete(cfBox)
cfBox := na
if not na(cfLbl)
label.delete(cfLbl)
cfLbl := na
if not na(cfxBox)
box.delete(cfxBox)
cfxBox := na
if not na(cfxLbl)
label.delete(cfxLbl)
cfxLbl := na
// ── CRUCIBLE (LONG): FURNACE ∩ ANVIL ──
if cfShow and showClimax and kale_goster and not na(cBox) and array.size(kaleListe) > 0
float cTp = box.get_top(cBox)
float cBt = box.get_bottom(cBox)
float oTop = na
float oBot = na
for i = 0 to array.size(kaleListe) - 1
KaleBolge kz = array.get(kaleListe, i)
if kz.yon == -1 and na(oTop) and cBt <= kz.tavan and cTp >= kz.taban
oTop := math.min(cTp, kz.tavan)
oBot := math.max(cBt, kz.taban)
if not na(kz.lb)
label.set_text(kz.lb, "")
if not na(oTop)
int cfL = box.get_left(cBox)
int cfR = box.get_right(cBox)
cfBox := box.new(cfL, oTop, cfR, oBot, border_color=cfCol, border_width=1, bgcolor=color.new(cfCol, 82))
// Ortak alana İLK giren mum: climax başlangıcından itibaren aralığı ortak alanla kesişen ilk bar
int scanFrom = math.min(cfL + bandPad, bar_index)
int nScan = math.min(bar_index - scanFrom, 200)
for k = nScan to 0
if low[k] <= oTop and high[k] >= oBot
cfAge := k
break
if not na(cfAge)
int kA = int(cfAge)
cfMove := (close / close[kA] - 1) * 100
label.set_text(cLbl, "")
cfScoreV := math.min(dBest + cfBonus, 5)
cfLbl := label.new(math.round((cfL + cfR) / 2.0), oBot, labelStrong ? nmCross + f_sc(int(cfScoreV)) : "", xloc=xloc.bar_index, style=label.style_label_up, color=cfCol, textcolor=color.black, size=size.small, textalign=text.align_center)
// ── FORGE (SHORT): IRON FLOOR ∩ HAMMER ──
if cfShow and showClimaxT and kale_goster and not na(xBox) and array.size(kaleListe) > 0
float xTp2 = box.get_top(xBox)
float xBt2 = box.get_bottom(xBox)
float pTop = na
float pBot = na
for i = 0 to array.size(kaleListe) - 1
KaleBolge kr = array.get(kaleListe, i)
if kr.yon == 1 and na(pTop) and xBt2 <= kr.tavan and xTp2 >= kr.taban
pTop := math.min(xTp2, kr.tavan)
pBot := math.max(xBt2, kr.taban)
if not na(kr.lb)
label.set_text(kr.lb, "")
if not na(pTop)
int cxL = box.get_left(xBox)
int cxR = box.get_right(xBox)
cfxBox := box.new(cxL, pTop, cxR, pBot, border_color=cfColX, border_width=1, bgcolor=color.new(cfColX, 82))
int scanFromX = math.min(cxL + bandPad, bar_index)
int nScanX = math.min(bar_index - scanFromX, 200)
for k = nScanX to 0
if low[k] <= pTop and high[k] >= pBot
cfxAge := k
break
label.set_text(xLbl, "")
cfxScoreV := math.min(tBest + cfBonus, 5)
cfxLbl := label.new(math.round((cxL + cxR) / 2.0), pTop, labelStrong ? nmCrossX + f_sc(int(cfxScoreV)) : "", xloc=xloc.bar_index, style=label.style_label_down, color=cfColX, textcolor=color.black, size=size.small, textalign=text.align_center)
int scrNC = input.int(3, "Ortak alan giriş mumu: son kaç bar içinde", minval=0, maxval=30, group=grpScr, tooltip="Destek bölgesi (pivot) 3 bar sonra onaylandığı için yeni oluşan ortak alanlarda giriş mumu en erken ~3 bar önce görünür. Taze olanları yakalamak için 3 civarı tut.")
plot(cfAge, "38) ORTAK ALAN: giriş mumu kaç bar önce (0 = bugün)", display=display.data_window)
plot(cfAge == 0 ? 1 : 0, "39) ORTAK ALAN: giriş mumu BUGÜN", display=display.data_window)
plot(not na(cfAge) and cfAge <= scrNC ? 1 : 0, "40) ORTAK ALAN: giriş mumu son N bar içinde", display=display.data_window)
plot(cfScoreV, "42) ORTAK ALAN: onay puanı (bonuslu, 0-5)", display=display.data_window)
plot(crM ? 1 : 0, "43) POTA şu an: AYLIK", display=display.data_window)
plot(crW ? 1 : 0, "44) POTA şu an: HAFTALIK", display=display.data_window)
plot(crD ? 1 : 0, "45) POTA şu an: GÜNLÜK", display=display.data_window)
plot(crH4 ? 1 : 0, "46) POTA şu an: 4 SAATLİK", display=display.data_window)
plot(cr_1h ? 1 : 0, "47) POTA şu an: 1 SAATLİK", display=display.data_window)
plot(cfMove, "41) ORTAK ALAN: giriş mumu kapanışından bu yana % değişim", display=display.data_window)
// ─── Sabitler (Constants) ────────────────────────────────────────────────────
const int KULE_SAYI = 7
const float KULE_ORAN_0 = 0.0
const float KULE_ORAN_1 = 0.236
const float KULE_ORAN_2 = 0.382
const float KULE_ORAN_3 = 0.5
const float KULE_ORAN_4 = 0.618
const float KULE_ORAN_5 = 0.786
const float KULE_ORAN_6 = 1.0
const float ALTIN_CEP_ALT = 0.618
const float ALTIN_CEP_UST = 0.66
const string KULE_ISIM_0 = "0"
const string KULE_ISIM_1 = "0.236"
const string KULE_ISIM_2 = "0.382"
const string KULE_ISIM_3 = "0.5"
const string KULE_ISIM_4 = "0.618"
const string KULE_ISIM_5 = "0.786"
const string KULE_ISIM_6 = "1"
// ─── Girdiler (Inputs) ───────────────────────────────────────────────────────
string GRP_KALE_PIVOT = "Kale Pivot / Salınım"
int pivotSol = 15
int pivotSag = 15
bool gelisenSalinimUzat = true
string GRP_KALE_PROFIL = "Kale Hacim Profili"
int dilimSayisi = 32
int maksAraligiBar = 500
bool hlc3DagitimKullan = false
bool sentetikHacimIzin = false
bool altTfHacimKullan = false
string altTfPeriyot = "5"
string GRP_KALE_GORUNUM = "Kale Görünüm"
bool altinCepGoster = input.bool(true, "Kale Altın Cep ", group = GRP_KALE_GORUNUM, tooltip = "Mor kutu: 0.618 ile 0.66 Fib arasındaki Altın Cep / OTE geri çekilme bölgesi.")
color renkAltinCep = input.color(color.new(#da0909, 21), "Altın Cep Rengi", group = GRP_KALE_GORUNUM)
int hayaletPocAdet = input.int(3, "Hayalet POC Sayısı", minval = 1, maxval = 5, group = GRP_KALE_GORUNUM)
// ─── Tipler (Types) ──────────────────────────────────────────────────────────
type KaleSalinim
float tepe
float dip
int tepeBar
int dipBar
bool yukselis
bool gecerli
bool gelisenTepe
bool gelisenDip
type KaleProfil
array<float> hacimDilim
float toplamHacim
float aralikUst
float aralikAlt
float dilimBoy
int baslaBar
int bitisBar
int pocDilim
float pocFiyat
float vaUst
float vaAlt
bool gecerli
bool aralikKirpildi
// ─── Yardımcılar (Helpers) ───────────────────────────────────────────────────
k_yakinFiyat(float x, float y, float aralik) =>
math.abs(x - y) < aralik
// ─── Hacim durumu (Volume state) ─────────────────────────────────────────────
bool gercekHacimVar = ta.cum(volume) > 0
bool hacimAktif = gercekHacimVar or sentetikHacimIzin
bool yalnizSentetik = not gercekHacimVar and sentetikHacimIzin
int grafikTfSn = timeframe.in_seconds()
int altTfSn = timeframe.in_seconds(altTfPeriyot)
bool altTfHacimTamam = altTfHacimKullan and altTfSn > 0 and altTfSn < grafikTfSn
[altTfUstArr, altTfAltArr, altTfKapArr, altTfHacArr] = request.security_lower_tf(syminfo.tickerid, altTfPeriyot, [high, low, close, volume])
// ─── Fib yardımcıları (Fib helpers) ──────────────────────────────────────────
k_oranGorunur(int sira) => true
k_oran(int sira) =>
switch sira
0 => KULE_ORAN_0
1 => KULE_ORAN_1
2 => KULE_ORAN_2
3 => KULE_ORAN_3
4 => KULE_ORAN_4
5 => KULE_ORAN_5
=> KULE_ORAN_6
k_isim(int sira) =>
switch sira
0 => KULE_ISIM_0
1 => KULE_ISIM_1
2 => KULE_ISIM_2
3 => KULE_ISIM_3
4 => KULE_ISIM_4
5 => KULE_ISIM_5
=> KULE_ISIM_6
k_salinimUst(KaleSalinim sal) =>
math.max(sal.tepe, sal.dip)
k_salinimAlt(KaleSalinim sal) =>
math.min(sal.tepe, sal.dip)
k_dilimOrta(KaleProfil prf, int dilimNo) =>
prf.aralikAlt + (dilimNo + 0.5) * prf.dilimBoy
k_dilimAlt(KaleProfil prf, int dilimNo) =>
prf.aralikAlt + dilimNo * prf.dilimBoy
k_dilimUst(KaleProfil prf, int dilimNo) =>
prf.aralikAlt + (dilimNo + 1) * prf.dilimBoy
k_fiyatDilim(KaleProfil prf, float fiyat) =>
int sira = int(math.floor((fiyat - prf.aralikAlt) / prf.dilimBoy))
math.max(0, math.min(dilimSayisi - 1, sira))
k_oranFiyatSalinim(KaleSalinim sal, float oran) =>
float uUst = k_salinimUst(sal)
float uAlt = k_salinimAlt(sal)
float aciklik = uUst - uAlt
sal.yukselis ? uUst - oran * aciklik : uAlt + oran * aciklik
k_oranFiyat(KaleSalinim sal, KaleProfil prf, float oran) =>
prf.gecerli ? (sal.yukselis ? prf.aralikUst - oran * (prf.aralikUst - prf.aralikAlt) : prf.aralikAlt + oran * (prf.aralikUst - prf.aralikAlt)) : k_oranFiyatSalinim(sal, oran)
k_altinCepSinir(KaleSalinim sal, KaleProfil prf) =>
float f618 = k_oranFiyat(sal, prf, ALTIN_CEP_ALT)
float f660 = k_oranFiyat(sal, prf, ALTIN_CEP_UST)
[math.max(f618, f660), math.min(f618, f660)]
// ─── Hacim dağıtımı (Volume distribution) ────────────────────────────────────
k_barHacimDagit(array<float> hacimDilim, KaleProfil prf, float barUst, float barAlt, float barKap, float barHac, bool hlc3Mod) =>
if barHac > 0 and prf.dilimBoy > 0
if hlc3Mod
float ortaFiyat = (barUst + barAlt + barKap) / 3.0
int d = k_fiyatDilim(prf, ortaFiyat)
array.set(hacimDilim, d, array.get(hacimDilim, d) + barHac)
else
float etkinAlt = math.max(barAlt, prf.aralikAlt)
float etkinUst = math.min(barUst, prf.aralikUst)
if etkinUst >= etkinAlt
int dBasla = k_fiyatDilim(prf, etkinAlt)
int dBitis = k_fiyatDilim(prf, etkinUst)
int dokunulan = dBitis - dBasla + 1
float pay = barHac / dokunulan
for d = dBasla to dBitis
array.set(hacimDilim, d, array.get(hacimDilim, d) + pay)
k_altTfDagit(array<float> hacimDilim, KaleProfil prf, array<float> ustArr, array<float> altArr, array<float> kapArr, array<float> hacArr, bool sentetik) =>
int adet = array.size(hacArr)
if adet > 0
for i = 0 to adet - 1
float hv = array.get(hacArr, i)
if sentetik
hv := hv > 0 ? hv : 1.0
if hv > 0
k_barHacimDagit(hacimDilim, prf, array.get(ustArr, i), array.get(altArr, i), array.get(kapArr, i), hv, hlc3DagitimKullan)
k_barHacim(float hamHacim, bool sentetik) =>
sentetik ? 1.0 : hamHacim
// ─── Profil kurucu (Profile builder) ─────────────────────────────────────────
k_profilKur(KaleSalinim sal, bool hacAktif, bool sentetik, bool altTfTamam) =>
array<float> hacimDilim = array.new<float>(dilimSayisi, 0.0)
KaleProfil sonuc = KaleProfil.new(hacimDilim, 0.0, 0.0, 0.0, 0.0, 0, 0, -1, na, na, na, false, false)
if sal.gecerli and hacAktif
int hamBasla = math.min(sal.tepeBar, sal.dipBar)
int hamBitis = math.max(sal.tepeBar, sal.dipBar)
bool kirpildi = hamBitis - hamBasla > maksAraligiBar
int baslaBar = kirpildi ? hamBitis - maksAraligiBar : hamBasla
int bitisBar = hamBitis
int araliktakiBar = bitisBar - baslaBar
float uUst = k_salinimUst(sal)
float uAlt = k_salinimAlt(sal)
float dBoy = (uUst - uAlt) / dilimSayisi
if araliktakiBar >= 0 and dBoy > 0
sonuc.aralikUst := uUst
sonuc.aralikAlt := uAlt
sonuc.dilimBoy := dBoy
sonuc.baslaBar := baslaBar
sonuc.bitisBar := bitisBar
sonuc.aralikKirpildi := kirpildi
for i = 0 to araliktakiBar
int hedefBar = baslaBar + i
int onceBar = bar_index - hedefBar
if onceBar >= 0
if altTfTamam and onceBar == 0
k_altTfDagit(hacimDilim, sonuc, altTfUstArr, altTfAltArr, altTfKapArr, altTfHacArr, sentetik)
else
float barHac = k_barHacim(volume[onceBar], sentetik)
if barHac > 0
k_barHacimDagit(hacimDilim, sonuc, high[onceBar], low[onceBar], close[onceBar], barHac, hlc3DagitimKullan)
float toplam = 0.0
int pocSira = 0
float maksDilimHac = 0.0
for d = 0 to dilimSayisi - 1
float hv = array.get(hacimDilim, d)
toplam += hv
if hv > maksDilimHac
maksDilimHac := hv
pocSira := d
sonuc.hacimDilim := hacimDilim
sonuc.toplamHacim := toplam
sonuc.pocDilim := pocSira
sonuc.pocFiyat := k_dilimOrta(sonuc, pocSira)
sonuc.gecerli := toplam > 0
sonuc
// ─── Salınım tespiti (Swing detection) ───────────────────────────────────────
var float sonTepe = na
var float sonDip = na
var int sonTepeBar = na
var int sonDipBar = na
float pTepe1 = ta.pivothigh(high, pivotSol, pivotSag)
float pDip1 = ta.pivotlow(low, pivotSol, pivotSag)
if not na(pTepe1)
sonTepe := pTepe1
sonTepeBar := bar_index - pivotSag
if not na(pDip1)
sonDip := pDip1
sonDipBar := bar_index - pivotSag
bool salinimVar = not na(sonTepe) and not na(sonDip) and not na(sonTepeBar) and not na(sonDipBar)
bool yukselisBacak = salinimVar and sonDipBar < sonTepeBar
int uzunlukDipten = math.max(salinimVar ? bar_index - sonDipBar + 1 : 1, 1)
int uzunlukTepeden = math.max(salinimVar ? bar_index - sonTepeBar + 1 : 1, 1)
float kosanTepe = ta.highest(high, uzunlukDipten)
int tepeOnce = ta.highestbars(high, uzunlukDipten)
float kosanDip = ta.lowest(low, uzunlukTepeden)
int dipOnce = ta.lowestbars(low, uzunlukTepeden)
float etkinTepe = sonTepe
float etkinDip = sonDip
int etkinTepeBar = sonTepeBar
int etkinDipBar = sonDipBar
bool gelTepe = false
bool gelDip = false
if salinimVar and gelisenSalinimUzat
if yukselisBacak
if kosanTepe > sonTepe
etkinTepe := kosanTepe
etkinTepeBar := bar_index - tepeOnce
gelTepe := true
else
if kosanDip < sonDip
etkinDip := kosanDip
etkinDipBar := bar_index - dipOnce
gelDip := true
KaleSalinim salinim = KaleSalinim.new(na, na, 0, 0, false, false, false, false)
if salinimVar
salinim.tepe := etkinTepe
salinim.dip := etkinDip
salinim.tepeBar := etkinTepeBar
salinim.dipBar := etkinDipBar
salinim.yukselis := yukselisBacak
salinim.gecerli := etkinTepe != etkinDip
salinim.gelisenTepe := gelTepe
salinim.gelisenDip := gelDip
// ─── Profil önbelleği + hayalet POC (Profile cache + ghost POC) ──────────────
var int onbellekTepeBar = na
var int onbellekDipBar = na
var float onbellekTepe = na
var float onbellekDip = na
var array<float> hayaletPocListe = array.new_float()
var KaleProfil aktifProfil = KaleProfil.new(array.new<float>(dilimSayisi, 0.0), 0.0, 0.0, 0.0, 0.0, 0, 0, -1, na, na, na, false, false)
bool salinimDegisti = salinim.gecerli and (
na(onbellekTepeBar) or na(onbellekDipBar) or na(onbellekTepe) or na(onbellekDip) or
onbellekTepeBar != salinim.tepeBar or onbellekDipBar != salinim.dipBar or
onbellekTepe != salinim.tepe or onbellekDip != salinim.dip)
if salinimDegisti
if aktifProfil.gecerli and hacimAktif and not na(aktifProfil.pocFiyat)
array.unshift(hayaletPocListe, aktifProfil.pocFiyat)
while array.size(hayaletPocListe) > hayaletPocAdet
array.pop(hayaletPocListe)
onbellekTepeBar := salinim.tepeBar
onbellekDipBar := salinim.dipBar
onbellekTepe := salinim.tepe
onbellekDip := salinim.dip
aktifProfil := k_profilKur(salinim, hacimAktif, yalnizSentetik, altTfHacimTamam)
KaleProfil prf = aktifProfil
bool hacimKatmaniGoster = hacimAktif and prf.gecerli
// ─── Altın Cep hesapları (Golden Pocket calculations) ────────────────────────
float apF618 = salinim.gecerli ? k_oranFiyat(salinim, prf, ALTIN_CEP_ALT) : na
float apF660 = salinim.gecerli ? k_oranFiyat(salinim, prf, ALTIN_CEP_UST) : na
float apUst = salinim.gecerli ? math.max(apF618, apF660) : na
float apAlt = salinim.gecerli ? math.min(apF618, apF660) : na
// ─── Çizim nesneleri (Drawing objects) ───────────────────────────────────────
var array<line> hayaletCizgiler = array.new_line()
var line pocCizgi = na
var box altinCepKutu = na
bool yenidenCizGerek = barstate.islast and salinim.gecerli and na(pocCizgi)
bool cizimYap = salinimDegisti or yenidenCizGerek
if cizimYap
// Önceki tüm nesneleri temizle
if not na(pocCizgi)
line.delete(pocCizgi)
pocCizgi := na
if not na(altinCepKutu)
box.delete(altinCepKutu)
altinCepKutu := na
for hc in hayaletCizgiler
line.delete(hc)
array.clear(hayaletCizgiler)
if salinim.gecerli
int xSol = hacimKatmaniGoster ? prf.baslaBar : math.min(salinim.tepeBar, salinim.dipBar)
int xSag = bar_index + 45 // Sağa sadece 45 bar
// ─── Altın Cep Kutusu ───────────────────────────────────────────────────
if altinCepGoster and not na(apUst) and not na(apAlt)
altinCepKutu := box.new(xSol, apUst, xSag, apAlt, bgcolor = renkAltinCep, border_color = color.new(renkAltinCep, 40), border_width = 1)
// ─── Aktif POC Çizgisi ─────────────────────────────────────────────────
if hacimKatmaniGoster and prf.gecerli and not na(prf.pocFiyat)
pocCizgi := line.new(xSol, prf.pocFiyat, xSag, prf.pocFiyat, color = color.new(#ecf00b, 0), width = 2, style = line.style_dashed)
// ─── Hayalet POC Çizgileri ─────────────────────────────────────────────
int hayaletBoyut = array.size(hayaletPocListe)
if hacimKatmaniGoster and hayaletBoyut > 0 and prf.gecerli
for hn = 0 to hayaletBoyut - 1
float hP = array.get(hayaletPocListe, hn)
// Aktif POC'a çok yakınsa hayaleti çizme
if not k_yakinFiyat(hP, prf.pocFiyat, prf.dilimBoy * 0.5)
line yeniHc = line.new(xSol, hP, xSag, hP, color = color.new(#2bc405, 0), width = 1, style = line.style_dotted)
array.push(hayaletCizgiler, yeniHc)
// 9. PROFESYONEL ALARMLAR: ALARM 1 (15dk+30dk+1S) / ALARM 2 (1S+4S+G+H, güçlü)
// Alarm kurarken ayarlardan "Bu alarm hangi mod?" seç → ALARM 1 veya ALARM 2
// ═══════════════════════════════════════════════════════════════════
// Güçlü alanın adını döndürür: "0 ÇİZGİSİ", "PDA-214", "PDA-1", "PDA-2" (boş = güçlü değil)
f_kindP(float bTop, float bBot, int sState, float sHi, float sLo, float sBounce, float sAtr, bool isTop) =>
string k = ""
string sfx = isTop ? " (ters)" : ""
if strongOn and not na(sLo) and not na(bTop) and not na(bBot) and sState >= 2
float tol = strongTolAtr * nz(sAtr, 0.0)
float r = not na(sHi) and sHi > sLo ? sHi - sLo : 0.0
if math.abs(bBot - sLo) <= tol or math.abs(bTop - sLo) <= tol or (bBot <= sLo and bTop >= sLo)
k := "0 ÇİZGİSİ" + sfx
if r > 0 and sState == 3
float p214t = sLo - r * 0.214
float p214b = sLo - r * (0.214 + pdaWidth)
if (bBot <= p214t and bTop >= p214b) or math.abs(bBot - p214t) <= tol
k += (k == "" ? "" : " + ") + "PDA-214" + sfx
if not na(sBounce) and sBounce > sLo
float L = (sBounce - sLo) / r
float p1t = sLo - r * L
float p1b = sLo - r * (L + pdaWidth)
float p2t = sLo - r * (1.0 - L)
float p2b = sLo - r * (1.0 - L + pdaWidth)
if bBot <= p1t and bTop >= p1b
k += (k == "" ? "" : " + ") + "PDA-1" + sfx
if bBot <= p2t and bTop >= p2b
k += (k == "" ? "" : " + ") + "PDA-2" + sfx
k
// Tek sinyal bloğu: yön, alan adı, giriş, stop, TP'ler
paBlock(string title, bool isShort, string kind, string extra, float p1, float p2, float p3, float sl) =>
string r = (isShort ? "📉 SHORT" : "📈 LONG") + " · " + title + (kind != "" ? " ★ GÜÇLÜ" : "")
if kind != ""
r += "\n 🎯 Güçlü alan: " + kind
if extra != ""
r += "\n " + extra
r += "\n Giriş: " + fmtP(close) + " | " + slLine(sl)
r += "\n " + tpTrade("TP1", p1, sl, isShort)
r += "\n " + tpTrade("TP2", p2, sl, isShort)
r += "\n " + tpTrade("TP3", p3, sl, isShort)
r
// Her zaman diliminde: Climax (dip), Iron Floor, CRUCIBLE, FORGE
// Kod: 0 = yok, 1 = yeni alan, 2 = GÜÇLÜ alan
alPack() =>
float at = ta.atr(14)
[dsc, tsc] = confPack()
// ── DİP climax (FURNACE)
[cf, st, t1, t2, t3] = calcClimax(close, high, low)
[sS, sHi, sHiB, sLo, sBn] = aynaCore(high, low, close)
int nB = na(st) ? 1 : math.max(bar_index - int(st) + 1, 1)
float lm = ta.lowest(low, nB)
float lc = ta.lowest(close, nB)
float bt = math.max(lc, lm + bandMinAtr * at)
float bb = lm - bandDownAtr * at
string kD = f_kindP(bt, bb, sS, sHi, sLo, sBn, at, false)
bool zD = earlyMode ? (cf or not na(st)) : cf
var int lastD = na
bool eD = zD and not zD[1] and (na(lastD) or bar_index - lastD > earlyGap)
if eD
lastD := bar_index
bool sD = zD and kD != ""
int cD = sD and not sD[1] ? 2 : eD ? 1 : 0
// ── TEPE (Iron Floor, ters seri)
[cfx, stx, u1, u2, u3] = calcClimax(-close, -low, -high)
[sSx, sHix, sHiBx, sLox, sBnx] = aynaCore(-low, -high, -close)
int nBx = na(stx) ? 1 : math.max(bar_index - int(stx) + 1, 1)
float hm = ta.highest(high, nBx)
float hc = ta.highest(close, nBx)
float bbx = math.min(hc, hm - bandMinAtr * at)
float btx = hm + bandDownAtr * at
string kX = f_kindP(-bbx, -btx, sSx, sHix, sLox, sBnx, at, true)
bool zX = earlyMode ? (cfx or not na(stx)) : cfx
var int lastX = na
bool eX = zX and not zX[1] and (na(lastX) or bar_index - lastX > earlyGap)
if eX
lastX := bar_index
bool sX = zX and kX != ""
int cX = sX and not sX[1] ? 2 : eX ? 1 : 0
// ── CRUCIBLE: destek bölgesi (ANVIL) ∩ dip climax (FURNACE)
float katr = ta.atr(50)
float kpl = ta.pivotlow(cruPiv, cruPiv)
var array<float> kzTop = array.new_float()
var array<float> kzBot = array.new_float()
if array.size(kzBot) > 0
for j = array.size(kzBot) - 1 to 0
if close < array.get(kzBot, j)
array.remove(kzBot, j)
array.remove(kzTop, j)
if not na(kpl)
float ktamp = katr[cruPiv] * cruGen
if not na(ktamp) and close >= kpl
array.unshift(kzBot, kpl)
array.unshift(kzTop, kpl + ktamp)
if array.size(kzBot) > cruMax
array.pop(kzBot)
array.pop(kzTop)
bool cruNow = false
float cruTop = na
float cruBot = na
if zD and array.size(kzBot) > 0
for j = 0 to array.size(kzBot) - 1
if bb <= array.get(kzTop, j) and bt >= array.get(kzBot, j)
cruNow := true
cruTop := math.min(bt, array.get(kzTop, j))
cruBot := math.max(bb, array.get(kzBot, j))
break
bool sC = cruNow and kD != ""
int cC = sC and not sC[1] ? 2 : cruNow and not cruNow[1] ? 1 : 0
// ── FORGE: direnç bölgesi (HAMMER) ∩ Iron Floor
float kph = ta.pivothigh(cruPiv, cruPiv)
var array<float> rzTop = array.new_float()
var array<float> rzBot = array.new_float()
if array.size(rzTop) > 0
for j = array.size(rzTop) - 1 to 0
if close > array.get(rzTop, j)
array.remove(rzTop, j)
array.remove(rzBot, j)
if not na(kph)
float rtamp = katr[cruPiv] * cruGen
if not na(rtamp) and close <= kph
array.unshift(rzTop, kph)
array.unshift(rzBot, kph - rtamp)
if array.size(rzTop) > cruMax
array.pop(rzTop)
array.pop(rzBot)
bool frNow = false
float frTop = na
float frBot = na
if zX and array.size(rzTop) > 0
for j = 0 to array.size(rzTop) - 1
if bbx <= array.get(rzTop, j) and btx >= array.get(rzBot, j)
frNow := true
frTop := math.min(btx, array.get(rzTop, j))
frBot := math.max(bbx, array.get(rzBot, j))
break
bool sF = frNow and kX != ""
int cF = sF and not sF[1] ? 2 : frNow and not frNow[1] ? 1 : 0
// ── 0 ÇİZGİSİNDE CRUCIBLE (LONG) / FORGE (SHORT) + min onay skoru
int scC = math.min(dsc + cfBonus, 5)
int scF = math.min(tsc + cfBonus, 5)
bool zC = cruNow and (str.contains(kD, "0 ÇİZGİSİ") or kD != "") and (paMinSc == 0 or scC >= paMinSc)
bool zF = frNow and (str.contains(kX, "0 ÇİZGİSİ") or kX != "") and (paMinSc == 0 or scF >= paMinSc)
int cZC = zC and not zC[1] ? 1 : 0
int cZF = zF and not zF[1] ? 1 : 0
// ── Mesaj blokları (sadece sinyal varsa üretilir)
string tD = ""
string tX = ""
string tC = ""
string tF = ""
if cD > 0
tD := paBlock("DİP CLIMAX · " + nmClimax, false, kD, confOn ? "Onay: " + str.tostring(dsc) + "/5" : "", t1, t2, t3, bb)
if cX > 0
tX := paBlock("IRON FLOOR (tepe climax)", true, kX, confOn ? "Onay: " + str.tostring(tsc) + "/5" : "", -u1, -u2, -u3, btx)
if cC > 0
tC := paBlock(nmCross + " · " + nmZone + " ∩ " + nmClimax, false, kD, "Kesişim: " + fmtP(cruBot) + " – " + fmtP(cruTop) + (confOn ? " · Onay: " + str.tostring(math.min(dsc + cfBonus, 5)) + "/5 (ortak alan bonuslu)" : ""), t1, t2, t3, bb)
if cF > 0
tF := paBlock(nmCrossX + " · " + nmZoneX + " ∩ IRON FLOOR", true, kX, "Kesişim: " + fmtP(frBot) + " – " + fmtP(frTop) + (confOn ? " · Onay: " + str.tostring(math.min(tsc + cfBonus, 5)) + "/5 (ortak alan bonuslu)" : ""), -u1, -u2, -u3, btx)
string tZC = ""
string tZF = ""
if cZC > 0
tZC := paBlock("CRUCIBLE · 0 ÇİZGİSİ · " + nmZone + " ∩ " + nmClimax, false, kD, "Kesişim: " + fmtP(cruBot) + " – " + fmtP(cruTop) + (confOn ? " · Onay: " + str.tostring(scC) + "/5 (ortak alan bonuslu)" : ""), t1, t2, t3, bb)
if cZF > 0
tZF := paBlock("FORGE · 0 ÇİZGİSİ · " + nmZoneX + " ∩ IRON FLOOR", true, kX, "Kesişim: " + fmtP(frBot) + " – " + fmtP(frTop) + (confOn ? " · Onay: " + str.tostring(scF) + "/5 (ortak alan bonuslu)" : ""), -u1, -u2, -u3, btx)
[time, cD, cX, cC, cF, tD, tX, tC, tF, cZC, cZF, tZC, tZF, bb, t1, btx, -u1, at]
[alTm1, alD1, alX1, alC1, alF1, alTD1, alTX1, alTC1, alTF1, alZC1, alZF1, alZTC1, alZTF1, lvLSL1, lvLTP1, lvSSL1, lvSTP1, lvAT1] = request.security(syminfo.tickerid, "15", alPack(), gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off, calc_bars_count=600)
[alTm2, alD2, alX2, alC2, alF2, alTD2, alTX2, alTC2, alTF2, alZC2, alZF2, alZTC2, alZTF2, lvLSL2, lvLTP2, lvSSL2, lvSTP2, lvAT2] = request.security(syminfo.tickerid, "30", alPack(), gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off, calc_bars_count=600)
[alTm3, alD3, alX3, alC3, alF3, alTD3, alTX3, alTC3, alTF3, alZC3, alZF3, alZTC3, alZTF3, lvLSL3, lvLTP3, lvSSL3, lvSTP3, lvAT3] = request.security(syminfo.tickerid, "60", alPack(), gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off, calc_bars_count=600)
[alTm4, alD4, alX4, alC4, alF4, alTD4, alTX4, alTC4, alTF4, alZC4, alZF4, alZTC4, alZTF4, lvLSL4, lvLTP4, lvSSL4, lvSTP4, lvAT4] = request.security(syminfo.tickerid, "240", alPack(), gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off, calc_bars_count=400)
[alTm5, alD5, alX5, alC5, alF5, alTD5, alTX5, alTC5, alTF5, alZC5, alZF5, alZTC5, alZTF5, lvLSL5, lvLTP5, lvSSL5, lvSTP5, lvAT5] = request.security(syminfo.tickerid, "D", alPack(), gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off, calc_bars_count=300)
[alTm6, alD6, alX6, alC6, alF6, alTD6, alTX6, alTC6, alTF6, alZC6, alZF6, alZTC6, alZTF6, lvLSL6, lvLTP6, lvSSL6, lvSTP6, lvAT6] = request.security(syminfo.tickerid, "W", alPack(), gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off, calc_bars_count=300)
var array<int> paLast = array.new_int(35, 0)
paJoin(string a, string b) => b == "" ? a : (a == "" ? b : a + " + " + b)
// Bir zaman dilimi için: tekrar eden alarmı engeller (HTF bar zamanı ile), gövde + etiket + yön bayrakları döndürür
paTf(array<int> arr, int base, string nm, bool tfOk, bool strongOnly, int tmv, int cD, int cX, int cC, int cF, string tD, string tX, string tC, string tF) =>
string body = ""
string tags = ""
bool lg = false
bool sh = false
if tfOk and (not confirmMode or barstate.isconfirmed)
int need = strongOnly ? 2 : 1
if cD >= need
if tmv != array.get(arr, base)
array.set(arr, base, tmv)
body += "\n\n▸ " + nm + " — " + tD
tags := paJoin(tags, nm + " CLIMAX" + (cD == 2 ? " ★" : ""))
lg := true
if paShort and cX >= need
if tmv != array.get(arr, base + 1)
array.set(arr, base + 1, tmv)
body += "\n\n▸ " + nm + " — " + tX
tags := paJoin(tags, nm + " IRON FLOOR" + (cX == 2 ? " ★" : ""))
sh := true
if cC >= need
if tmv != array.get(arr, base + 2)
array.set(arr, base + 2, tmv)
body += "\n\n▸ " + nm + " — " + tC
tags := paJoin(tags, nm + " " + nmCross + (cC == 2 ? " ★" : ""))
lg := true
if paShort and cF >= need
if tmv != array.get(arr, base + 3)
array.set(arr, base + 3, tmv)
body += "\n\n▸ " + nm + " — " + tF
tags := paJoin(tags, nm + " " + nmCrossX + (cF == 2 ? " ★" : ""))
sh := true
[body, tags, lg, sh]
// ALARM 3 / 4 (sadece 1S): CRUCIBLE / CRUCIBLE 0 (LONG) + FORGE / FORGE 0 (SHORT)
paTf34(array<int> arr, bool m3, bool m4, bool tfOk, int tmv, int cD, int cC, int cF, int cZC, int cZF, string tD, string tC, string tF, string tZC, string tZF, bool inclDip) =>
string body = ""
string tags = ""
bool lg = false
bool sh = false
if tfOk and (not confirmMode or barstate.isconfirmed)
bool cAny = cC >= 1 and tmv != array.get(arr, 27)
bool cZro = cZC == 1 and tmv != array.get(arr, 24)
bool cDip = inclDip and cD >= 1 and tmv != array.get(arr, 28)
if (m4 and (cAny or cDip)) or ((m3 or m4) and cZro)
if cAny
array.set(arr, 27, tmv)
if cZro
array.set(arr, 24, tmv)
if cDip and not cAny and not cZro
array.set(arr, 28, tmv)
string lgTxt = cZro ? tZC : cAny ? tC : tD
string lgTag = cZro ? "1 SAAT CRUCIBLE 0 ÇİZGİSİ ★" : cAny ? "1 SAAT CRUCIBLE" : "1 SAAT CLIMAX DİP"
body += "\n\n▸ 1 SAAT — " + lgTxt
tags := paJoin(tags, lgTag)
lg := true
if m4
bool fAny = cF >= 1 and tmv != array.get(arr, 25)
bool fZro = cZF == 1 and tmv != array.get(arr, 26)
if fAny or fZro
if fAny
array.set(arr, 25, tmv)
if fZro
array.set(arr, 26, tmv)
body += "\n\n▸ 1 SAAT — " + (fAny ? tF : tZF)
tags := paJoin(tags, "1 SAAT FORGE" + (fZro ? " 0 ÇİZGİSİ ★" : ""))
sh := true
[body, tags, lg, sh]
bool paM1 = paN == 1
bool paM2 = paN == 2
bool paM3 = paN == 3
bool paM4 = paN == 4
bool useStrOnly = alertStrongOnly
[pbA, pgA, lgA, shA] = paTf(paLast, 0, "15 DK", paM1 and chartSec <= 900, useStrOnly, alTm1, alD1, alX1, alC1, alF1, alTD1, alTX1, alTC1, alTF1)
[pbB, pgB, lgB, shB] = paTf(paLast, 4, "30 DK", paM1 and chartSec <= 1800, useStrOnly, alTm2, alD2, alX2, alC2, alF2, alTD2, alTX2, alTC2, alTF2)
[pbC, pgC, lgC, shC] = paTf(paLast, 8, "1 SAAT", (paM1 or paM2) and chartSec <= 3600, useStrOnly, alTm3, alD3, alX3, alC3, alF3, alTD3, alTX3, alTC3, alTF3)
[pbD, pgD, lgD, shD] = paTf(paLast, 12, "4 SAAT", paM2 and chartSec <= 14400, useStrOnly, alTm4, alD4, alX4, alC4, alF4, alTD4, alTX4, alTC4, alTF4)
[pbE, pgE, lgE, shE] = paTf(paLast, 16, "GÜNLÜK", paM2 and chartSec <= 86400, useStrOnly, alTm5, alD5, alX5, alC5, alF5, alTD5, alTX5, alTC5, alTF5)
[pbF, pgF, lgF, shF] = paTf(paLast, 20, "HAFTALIK", paM2 and chartSec <= 604800, useStrOnly, alTm6, alD6, alX6, alC6, alF6, alTD6, alTX6, alTC6, alTF6)
[pbG, pgG, lgG, shG] = paTf34(paLast, paM3, paM4, chartSec <= 3600, alTm3, alD3, alC3, alF3, alZC3, alZF3, alTD3, alTC3, alTF3, alZTC3, alZTF3, mod4IncludeDip)
string paBody = pbA + pbB + pbC + pbD + pbE + pbF + pbG
string paTags = ""
paTags := paJoin(paTags, pgA)
paTags := paJoin(paTags, pgB)
paTags := paJoin(paTags, pgC)
paTags := paJoin(paTags, pgD)
paTags := paJoin(paTags, pgE)
paTags := paJoin(paTags, pgF)
paTags := paJoin(paTags, pgG)
if sendInfoAlerts and paBody != ""
string paTitle = paM1 ? "ALARM 1 · 15dk / 30dk / 1S" : paM2 ? "ALARM 2 · 1S / 4S / G / H · GÜÇLÜ ALANLAR (0 / PDA)" : paM3 ? "ALARM 3 · 1S · CRUCIBLE 0 ÇİZGİSİ · LONG" : "ALARM 4 · 1S · FORGE (SHORT) + CRUCIBLE 0 ÇİZGİSİ (LONG)"
string paHdr = "🚨 " + paTitle + " | " + syminfo.ticker + "\nFiyat: " + fmtP(close) + " · " + str.format_time(time, "dd.MM.yyyy HH:mm", syminfo.timezone) + "\nTetikleyen: " + paTags + "\n──────────────"
alert(paHdr + paBody + "\n\n──────────────\nStop bölge dışına ATR payı ile konur. Yatırım tavsiyesi değildir.", alert.freq_once_per_bar)
// =============================================================================
// 🛠️ YARDIMCI FONKSİYONLAR
// =============================================================================
f_getPos(posStr) =>
switch posStr
"Sağ Üst" => position.top_right
"Sağ Alt" => position.bottom_right
"Sol Üst" => position.top_left
"Sol Alt" => position.bottom_left
=> position.bottom_right
// Emir miktarı: BIST'te tam lot (aşağı yuvarla), kriptoda 6 basamak. Strateji testi ile webhook AYNI miktarı kullanır.
f_qty() =>
float q = 1.0
if close > 0
q := isCryptoDetected ? math.round(webhookBaseCash / close, 6) : math.max(math.floor(webhookBaseCash / close), 1.0)
q
// Osmanlı Menkul webhook JSON mesajı (alan adları değiştirilmedi)
f_buildAlertMsg(string actionType, float orderQty, float orderPrice) =>
string sym = overrideSymbol and customSymbol != "" ? customSymbol : syminfo.ticker
string act = "SATIS"
string com = "Çıkış Emri"
if actionType == "BUY"
act := "ALIS"
com := "Climax Alis Emri"
else if actionType == "SELL"
act := "SATIS"
com := "Iron Floor Satis Emri"
else if actionType == "EXIT_LONG"
act := "SATIS"
com := "Long Pozisyon Kapatma"
else if actionType == "EXIT_SHORT"
act := "ALIS"
com := "Short Pozisyon Kapatma"
else if actionType == "TP1"
act := "SATIS"
com := "Climax TP1 Kâr Al"
else if actionType == "TP1_SHORT"
act := "ALIS"
com := "Short TP1 Kâr Al"
else if actionType == "STOP_LOSS"
act := "SATIS"
com := "Climax Bandı Stop Loss"
else if actionType == "STOP_LOSS_SHORT"
act := "ALIS"
com := "Iron Floor Bandı Stop Loss"
else if actionType == "IRON_FLOOR_EXIT"
act := "SATIS"
com := "Iron Floor Teyidiyle Long Kapat ve Kâr Al"
else if actionType == "CLIMAX_DIP_EXIT"
act := "ALIS"
com := "Climax Dip Teyidiyle Short Kapat ve Kâr Al"
string pStr = (not na(orderPrice) and orderPrice > 0) ? str.tostring(orderPrice, format.mintick) : "PİYASA"
string qStr = str.tostring(orderQty, "#.######")
"{\"Sembol\":\"" + sym + "\",\"Islem\":\"" + act + "\",\"Miktar\":\"" + qStr + "\",\"Fiyat\":\"" + pStr + "\",\"Tip\":\"PIYASA\",\"Aciklama\":\"" + com + "\"}"
// Bayrak dizisinde seçilecek zaman dilimi (preferHigh: en yüksek TF, aksi halde en düşük TF)
f_pick(array<bool> fl, bool preferHigh) =>
int ix = -1
for i = 0 to array.size(fl) - 1
if array.get(fl, i)
if preferHigh or ix == -1
ix := i
ix
// Çıkış için "yeni zıt alan olayı": aynı HTF barında tekrar tekrar tetiklenmesin
f_newEv(array<int> arr, int ix, bool on, bool ev, int tmv) =>
bool r = false
if on and ev and (not confirmMode or barstate.isconfirmed) and tmv != array.get(arr, ix)
array.set(arr, ix, tmv)
r := true
r
// =============================================================================
// 🎯 SİNYAL ÜRETİMİ (alarmlarla birebir aynı koşullar)
// =============================================================================
// Giriş bayrakları paTf / paTf34 içinden gelir (alarm mesajını üreten kod ile AYNI koşul + AYNI tekrar kilidi).
bool entL_C = lgC or lgG
bool entS_C = shC or shG
array<bool> lgArr = array.from(lgA, lgB, entL_C, lgD, lgE, lgF)
array<bool> shArr = array.from(shA, shB, entS_C, shD, shE, shF)
array<float> lSLArr = array.from(lvLSL1, lvLSL2, lvLSL3, lvLSL4, lvLSL5, lvLSL6)
array<float> lTPArr = array.from(lvLTP1, lvLTP2, lvLTP3, lvLTP4, lvLTP5, lvLTP6)
array<float> sSLArr = array.from(lvSSL1, lvSSL2, lvSSL3, lvSSL4, lvSSL5, lvSSL6)
array<float> sTPArr = array.from(lvSTP1, lvSTP2, lvSTP3, lvSTP4, lvSTP5, lvSTP6)
array<float> atArr = array.from(lvAT1, lvAT2, lvAT3, lvAT4, lvAT5, lvAT6)
array<string> tfNameArr = array.from("15dk", "30dk", "1S", "4S", "Günlük", "Haftalık")
bool preferHigh = levelTfPref == "En yüksek TF"
int ixL = f_pick(lgArr, preferHigh)
int ixS = f_pick(shArr, preferHigh)
// Grafik zaman dilimindeki kutu başlangıçları (Kutular modu girişi + isteğe bağlı çıkış)
bool chartBullEv = cZone and not cZone[1]
bool chartBearEv = xZone and not xZone[1]
bool boxMode = paN == 0
bool sigLong = ixL >= 0 or (boxMode and chartBullEv)
bool sigShort = ixS >= 0 or (boxMode and chartBearEv)
// Çıkış için zıt alan olayları: seçili modun zaman dilimlerinde YENİ Iron Floor/FORGE (zayıf dahil) ve YENİ Climax/CRUCIBLE
bool onA = paN == 1 and chartSec <= 900
bool onB = paN == 1 and chartSec <= 1800
bool onC = paN >= 1 and chartSec <= 3600
bool onD = paN == 2 and chartSec <= 14400
bool onE = paN == 2 and chartSec <= 86400
bool onF = paN == 2 and chartSec <= 604800
var array<int> exLast = array.new_int(12, 0)
bool evBearA = f_newEv(exLast, 0, onA, alX1 >= 1 or alF1 >= 1, alTm1)
bool evBearB = f_newEv(exLast, 1, onB, alX2 >= 1 or alF2 >= 1, alTm2)
bool evBearC = f_newEv(exLast, 2, onC, alX3 >= 1 or alF3 >= 1, alTm3)
bool evBearD = f_newEv(exLast, 3, onD, alX4 >= 1 or alF4 >= 1, alTm4)
bool evBearE = f_newEv(exLast, 4, onE, alX5 >= 1 or alF5 >= 1, alTm5)
bool evBearF = f_newEv(exLast, 5, onF, alX6 >= 1 or alF6 >= 1, alTm6)
bool evBullA = f_newEv(exLast, 6, onA, alD1 >= 1 or alC1 >= 1, alTm1)
bool evBullB = f_newEv(exLast, 7, onB, alD2 >= 1 or alC2 >= 1, alTm2)
bool evBullC = f_newEv(exLast, 8, onC, alD3 >= 1 or alC3 >= 1, alTm3)
bool evBullD = f_newEv(exLast, 9, onD, alD4 >= 1 or alC4 >= 1, alTm4)
bool evBullE = f_newEv(exLast, 10, onE, alD5 >= 1 or alC5 >= 1, alTm5)
bool evBullF = f_newEv(exLast, 11, onF, alD6 >= 1 or alC6 >= 1, alTm6)
bool bearEv = evBearA or evBearB or evBearC or evBearD or evBearE or evBearF or (exitUseChartBoxes and chartBearEv)
bool bullEv = evBullA or evBullB or evBullC or evBullD or evBullE or evBullF or (exitUseChartBoxes and chartBullEv)
// Giriş seviyeleri: sinyali üreten zaman diliminin bandından (Kutular modunda grafik bandından)
float rawLSL = ixL >= 0 ? array.get(lSLArr, math.max(ixL, 0)) : bandBot
float rawLTP = ixL >= 0 ? array.get(lTPArr, math.max(ixL, 0)) : cTP1
float rawLAT = ixL >= 0 ? array.get(atArr, math.max(ixL, 0)) : atrV
float rawSSL = ixS >= 0 ? array.get(sSLArr, math.max(ixS, 0)) : xBandTop
float rawSTP = ixS >= 0 ? array.get(sTPArr, math.max(ixS, 0)) : xTP1
float rawSAT = ixS >= 0 ? array.get(atArr, math.max(ixS, 0)) : atrV
float entPx = close
float lSLv = (not na(rawLSL) and rawLSL > 0 and rawLSL < entPx) ? rawLSL : entPx * (1.0 - fbSlPct / 100.0)
float lTPv = (not na(rawLTP) and rawLTP > entPx) ? rawLTP : (fbTpPct > 0 ? entPx * (1.0 + fbTpPct / 100.0) : na)
float sSLv = (not na(rawSSL) and rawSSL > entPx) ? rawSSL : entPx * (1.0 + fbSlPct / 100.0)
float sTPv = (not na(rawSTP) and rawSTP > 0 and rawSTP < entPx) ? rawSTP : (fbTpPct > 0 ? entPx * (1.0 - fbTpPct / 100.0) : na)
float lATv = nz(rawLAT, nz(atrV, 0.0))
float sATv = nz(rawSAT, nz(atrV, 0.0))
string lTfTxt = ixL >= 0 ? array.get(tfNameArr, math.max(ixL, 0)) : "Grafik"
string sTfTxt = ixS >= 0 ? array.get(tfNameArr, math.max(ixS, 0)) : "Grafik"
// =============================================================================
// 🛑 POZİSYON DURUMU
// =============================================================================
bool inLong = strategy.position_size > 0
bool inShort = strategy.position_size < 0
bool isFlat = strategy.position_size == 0
var float posSL = na
var float posTP = na
var float posAT = na
var float posQty = na
var string posTf = "-"
if isFlat
posSL := na
posTP := na
posAT := na
posQty := na
posTf := "-"
bool slClose = str.startswith(slSourceChoice, "Bölge Tabanı")
bool slAtr = str.startswith(slSourceChoice, "ATR Paylı")
bool tpOn = not str.startswith(tpSourceChoice, "Kapalı")
float orderQty = f_qty()
// =============================================================================
// 🚪 ÇIKIŞLAR (TP1 emri aşağıda strategy.exit ile; burada zıt alan ve kapanış stopu)
// =============================================================================
bool closedLong = false
bool closedShort = false
if inLong
if exitOnIronFloor and (bearEv or sigShort)
strategy.close("LONG_GIRIS", comment="Iron Floor / FORGE Kâr Al Çıkış", alert_message=f_buildAlertMsg("IRON_FLOOR_EXIT", nz(posQty, orderQty), close))
closedLong := true
else if slClose and not na(posSL) and close < posSL
strategy.close("LONG_GIRIS", comment="Stop Loss (Kapanış)", alert_message=f_buildAlertMsg("STOP_LOSS", nz(posQty, orderQty), close))
closedLong := true
if inShort
if exitOnClimaxDip and (bullEv or sigLong)
strategy.close("SHORT_GIRIS", comment="Climax Dip / CRUCIBLE Kâr Al Çıkış", alert_message=f_buildAlertMsg("CLIMAX_DIP_EXIT", nz(posQty, orderQty), close))
closedShort := true
else if slClose and not na(posSL) and close > posSL
strategy.close("SHORT_GIRIS", comment="Stop Loss (Kapanış)", alert_message=f_buildAlertMsg("STOP_LOSS_SHORT", nz(posQty, orderQty), close))
closedShort := true
// =============================================================================
// ⚡ GİRİŞLER
// =============================================================================
bool doLong = sigLong and not sigShort and strategyType != "SHORT"
bool doShort = sigShort and not sigLong and strategyType != "LONG"
bool enterLong = false
bool enterShort = false
if doLong and not inLong
if inShort and not closedShort
strategy.close("SHORT_GIRIS", comment="Long Sinyaliyle Short Kapat", alert_message=f_buildAlertMsg("EXIT_SHORT", nz(posQty, orderQty), close))
closedShort := true
strategy.entry("LONG_GIRIS", strategy.long, qty=orderQty, comment="Climax Long Giriş [" + lTfTxt + "]", alert_message=f_buildAlertMsg("BUY", orderQty, close))
posSL := lSLv
posTP := lTPv
posAT := lATv
posQty := orderQty
posTf := lTfTxt
enterLong := true
if doShort and not inShort
if inLong and not closedLong
strategy.close("LONG_GIRIS", comment="Short Sinyaliyle Long Kapat", alert_message=f_buildAlertMsg("EXIT_LONG", nz(posQty, orderQty), close))
closedLong := true
strategy.entry("SHORT_GIRIS", strategy.short, qty=orderQty, comment="Iron Floor Short Giriş [" + sTfTxt + "]", alert_message=f_buildAlertMsg("SELL", orderQty, close))
posSL := sSLv
posTP := sTPv
posAT := sATv
posQty := orderQty
posTf := sTfTxt
enterShort := true
// TP1 (limit) ve ATR paylı stop (stop emri): pozisyon boyunca her barda yenilenir
bool longActive = (inLong and not closedLong) or enterLong
bool shortActive = (inShort and not closedShort) or enterShort
if longActive
float tpL = tpOn ? posTP : na
float slL = (slAtr and not na(posSL) and (posSL - nz(posAT, 0.0)) > 0) ? posSL - nz(posAT, 0.0) : na
if not na(tpL) or not na(slL)
strategy.exit("LONG_CIKIS", from_entry="LONG_GIRIS", limit=tpL, stop=slL, comment_profit="TP1 Kâr Al", comment_loss="Stop (ATR)", alert_profit=f_buildAlertMsg("TP1", nz(posQty, orderQty), tpL), alert_loss=f_buildAlertMsg("STOP_LOSS", nz(posQty, orderQty), slL))
if shortActive
float tpS = tpOn ? posTP : na
float slS = (slAtr and not na(posSL)) ? posSL + nz(posAT, 0.0) : na
if not na(tpS) or not na(slS)
strategy.exit("SHORT_CIKIS", from_entry="SHORT_GIRIS", limit=tpS, stop=slS, comment_profit="Short TP1 Kâr Al", comment_loss="Stop (ATR)", alert_profit=f_buildAlertMsg("TP1_SHORT", nz(posQty, orderQty), tpS), alert_loss=f_buildAlertMsg("STOP_LOSS_SHORT", nz(posQty, orderQty), slS))
// Veri penceresi (kontrol için)
plot(sigLong ? 1 : 0, "SİNYAL: LONG", display=display.data_window)
plot(sigShort ? 1 : 0, "SİNYAL: SHORT", display=display.data_window)
plotshape(enterLong, "LONG giriş", shape.triangleup, location.belowbar, color.new(#089981, 0), size=size.small, text="L")
plotshape(enterShort, "SHORT giriş", shape.triangledown, location.abovebar, color.new(#f23645, 0), size=size.small, text="S")
// =============================================================================
// 🕯️ DİNAMİK AKILLI MUM RENKLENDİRME (plotcandle)
// =============================================================================
bool candleIsLong = (inLong and not closedLong) or enterLong
bool candleIsShort = (inShort and not closedShort) or enterShort
color candleBodyCol = not enableCandleColoring ? (close >= open ? color.new(#089981, 0) : color.new(#f23645, 0)) : candleIsLong ? color.new(#089981, 0) : candleIsShort ? color.new(#f23645, 0) : (close >= open ? color.new(#26a69a, 30) : color.new(#ef5350, 30))
color candleWickCol = not enableCandleColoring ? (close >= open ? #089981 : #f23645) : candleIsLong ? #089981 : candleIsShort ? #f23645 : (close >= open ? #26a69a : #ef5350)
plotcandle(open, high, low, close, title="Akıllı Sinyal Mumu",
color=candleBodyCol, wickcolor=candleWickCol, bordercolor=candleBodyCol,
editable=true)
// =============================================================================
// 📊 BİLGİ KARTI
// =============================================================================
var table infoTable = table.new(position.bottom_right, 2, 7, bgcolor=color.new(#131722, 10), border_width=1, border_color=color.new(#2a2e39, 0))
if showInfoCard and barstate.islast
table.set_position(infoTable, f_getPos(infoCardPos))
string modeLabel = (isAutoMode ? "Oto → " : "") + (paN == 2 ? "Mod 2 (Coin)" : paN == 4 ? "Mod 4 (BIST)" : paN == 1 ? "Mod 1" : paN == 3 ? "Mod 3" : "Kutular")
bool tfWarn = (paN == 1 or paN == 3 or paN == 4) and chartSec > 3600
table.cell(infoTable, 0, 0, "Aktif Alarm", bgcolor=color.new(#1e222d, 0), text_color=color.white, text_size=size.small)
table.cell(infoTable, 1, 0, modeLabel, bgcolor=color.new(#1e222d, 20), text_color=color.yellow, text_size=size.small)
table.cell(infoTable, 0, 1, "Grafik TF", bgcolor=color.new(#1e222d, 0), text_color=color.white, text_size=size.small)
table.cell(infoTable, 1, 1, tfWarn ? "⚠ 1S veya altı olmalı!" : "Uygun", bgcolor=color.new(#1e222d, 20), text_color=tfWarn ? color.red : color.green, text_size=size.small)
table.cell(infoTable, 0, 2, "Pozisyon", bgcolor=color.new(#1e222d, 0), text_color=color.white, text_size=size.small)
table.cell(infoTable, 1, 2, inLong ? "LONG [" + posTf + "]" : inShort ? "SHORT [" + posTf + "]" : "NÖTR", bgcolor=inLong ? color.new(#089981, 20) : inShort ? color.new(#f23645, 20) : color.new(#1e222d, 20), text_color=inLong ? color.green : inShort ? color.red : color.gray, text_size=size.small)
table.cell(infoTable, 0, 3, "Giriş Fiyatı", bgcolor=color.new(#1e222d, 0), text_color=color.white, text_size=size.small)
table.cell(infoTable, 1, 3, (inLong or inShort) ? str.tostring(strategy.position_avg_price, format.mintick) : "-", bgcolor=color.new(#1e222d, 20), text_color=color.white, text_size=size.small)
table.cell(infoTable, 0, 4, "Stop Seviyesi", bgcolor=color.new(#1e222d, 0), text_color=color.white, text_size=size.small)
string slTxt = (not (inLong or inShort) or na(posSL) or str.startswith(slSourceChoice, "Kapalı")) ? "-" : str.tostring(slAtr ? (inLong ? posSL - nz(posAT, 0.0) : posSL + nz(posAT, 0.0)) : posSL, format.mintick)
table.cell(infoTable, 1, 4, slTxt, bgcolor=color.new(#1e222d, 20), text_color=color.red, text_size=size.small)
table.cell(infoTable, 0, 5, "Kar Al (TP1)", bgcolor=color.new(#1e222d, 0), text_color=color.white, text_size=size.small)
table.cell(infoTable, 1, 5, ((inLong or inShort) and not na(posTP) and tpOn) ? str.tostring(posTP, format.mintick) : "-", bgcolor=color.new(#1e222d, 20), text_color=color.green, text_size=size.small)
table.cell(infoTable, 0, 6, "Emir Tutarı", bgcolor=color.new(#1e222d, 0), text_color=color.white, text_size=size.small)
table.cell(infoTable, 1, 6, str.tostring(orderQty, "#.######") + " adet", bgcolor=color.new(#1e222d, 20), text_color=color.white, text_size=size.small)
Editor is loading...
Leave a Comment