//@version=5 strategy("Yüzdelik Hareket Stratejisi + ADX (BTC)", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100) // Kullanıcı Girdileri - Ana Strateji movement_ratio = input.float(0.5, "Hareket Oranı (0.1 = %10, 0.5 = %50)", minval=0.1, maxval=1.0, step=0.1) min_consecutive = input.int(2, "Minimum Üst Üste Gerçekleşme", minval=1, maxval=10) // ADX Filtre Ayarları use_adx_filter = input.bool(true, "ADX Filtresi Kullan", group="ADX FİLTRESİ") adx_threshold = input.float(25.0, "ADX Eşik Değeri", minval=10.0, maxval=50.0, step=1.0, group="ADX FİLTRESİ") adx_length = input.int(14, "ADX Periyodu", minval=5, maxval=50, step=1, group="ADX FİLTRESİ") // Stop Loss Ayarları sl_percent = input.float(1.0, "Stop Loss %", minval=0.1, step=0.1, group="STOP LOSS") tp_multiplier = input.float(2.0, "Take Profit Çarpanı", minval=0.1, step=0.1, group="STOP LOSS") // Görsel Ayarlar show_signals = input.bool(true, "Sinyalleri Göster", group="GÖRSEL") show_info = input.bool(true, "Bilgi Panelini Göster", group="GÖRSEL") // ═══════════════════════════════════════════════════════════════════════ // FİLTRE HESAPLAMALARI // ═══════════════════════════════════════════════════════════════════════ // ADX Hesaplama tr1 = math.max(high - low, math.abs(high - close[1])) tr2 = math.max(tr1, math.abs(low - close[1])) tr = tr2 plus_dm = high - high[1] > low[1] - low ? math.max(high - high[1], 0) : 0 minus_dm = low[1] - low > high - high[1] ? math.max(low[1] - low, 0) : 0 plus_di = 100 * ta.rma(plus_dm, adx_length) / ta.rma(tr, adx_length) minus_di = 100 * ta.rma(minus_dm, adx_length) / ta.rma(tr, adx_length) sum_di = plus_di + minus_di adx = 100 * ta.rma(math.abs(plus_di - minus_di) / (sum_di == 0 ? 1 : sum_di), adx_length) // ═══════════════════════════════════════════════════════════════════════ // ANA STRATEJİ LOGİĞİ // ═══════════════════════════════════════════════════════════════════════ // Bir önceki barın high ve low değerleri prev_high = high[1] prev_low = low[1] prev_close = close[1] // Önceki barın kendi içindeki dip-tepe arasındaki yüzdelik fark prev_range_percent = ((prev_high - prev_low) / prev_low) * 100 // Hedef hareket yüzdesi (ayarlanabilir oran) target_move_percent = prev_range_percent * movement_ratio // Mevcut fiyatın önceki kapanışa göre yüzdelik değişimi current_change_percent = ((close - prev_close) / prev_close) * 100 // Mevcut koşullar (henüz sinyal değil, sadece hareket kontrolü) current_long_move = current_change_percent >= target_move_percent and target_move_percent > 0 current_short_move = current_change_percent <= -target_move_percent and target_move_percent > 0 // Üst üste kaç kez gerçekleştiğini kontrol et check_consecutive_moves(is_long) => consecutive = 0 if is_long if current_long_move consecutive := 1 else if current_short_move consecutive := 1 if consecutive == 1 for i = 1 to 20 bar_range = ((high[i] - low[i]) / low[i]) * 100 bar_target = bar_range * movement_ratio bar_change = i == 1 ? ((close[1] - close[2]) / close[2]) * 100 : ((close[i] - close[i+1]) / close[i+1]) * 100 if is_long and bar_change >= bar_target and bar_target > 0 consecutive := consecutive + 1 else if not is_long and bar_change <= -bar_target and bar_target > 0 consecutive := consecutive + 1 else break consecutive // Long ve short için üst üste gerçekleşme sayısı long_consecutive = check_consecutive_moves(true) short_consecutive = check_consecutive_moves(false) // ═══════════════════════════════════════════════════════════════════════ // FİLTRELİ SİNYAL LOGİĞİ // ═══════════════════════════════════════════════════════════════════════ // Temel koşullar basic_long_condition = long_consecutive >= min_consecutive basic_short_condition = short_consecutive >= min_consecutive // Filtre kontrolü adx_filter = not use_adx_filter or adx >= adx_threshold // Nihai sinyal koşulları long_condition = basic_long_condition and adx_filter short_condition = basic_short_condition and adx_filter // ═══════════════════════════════════════════════════════════════════════ // POZİSYON YÖNETİMİ VE ALARM SİSTEMİ // ═══════════════════════════════════════════════════════════════════════ // Pozisyon açma if (long_condition and strategy.position_size == 0) strategy.entry("Long", strategy.long) alert("x,buy,BTCUSD,risk=0.2", alert.freq_once_per_bar) if (short_condition and strategy.position_size == 0) strategy.entry("Short", strategy.short) alert("x,sell,BTCUSD,risk=0.2", alert.freq_once_per_bar) // TradingView strategy exit'leri (ORİJİNAL HALİ GİBİ) if (strategy.position_size > 0) sl_price = strategy.position_avg_price * (1 - sl_percent / 100) tp_price = strategy.position_avg_price * (1 + (target_move_percent * tp_multiplier) / 100) strategy.exit("Long Exit", "Long", stop=sl_price, limit=tp_price) if (strategy.position_size < 0) sl_price = strategy.position_avg_price * (1 + sl_percent / 100) tp_price = strategy.position_avg_price * (1 - (target_move_percent * tp_multiplier) / 100) strategy.exit("Short Exit", "Short", stop=sl_price, limit=tp_price) // ═══════════════════════════════════════════════════════════════════════ // PINE CONNECTOR İÇİN EXIT ALARM SİSTEMİ // ═══════════════════════════════════════════════════════════════════════ // Son pozisyon durumu takibi var float last_position_size = 0 // Pozisyon değişimini algıla position_closed_long = last_position_size > 0 and strategy.position_size == 0 position_closed_short = last_position_size < 0 and strategy.position_size == 0 // Pine Connector alarmları if position_closed_long alert("x,closelong,BTCUSD", alert.freq_once_per_bar) if position_closed_short alert("x,closeshort,BTCUSD", alert.freq_once_per_bar) // Son pozisyon durumunu güncelle last_position_size := strategy.position_size // ═══════════════════════════════════════════════════════════════════════ // GÖRSEL ELEMENTLER // ═══════════════════════════════════════════════════════════════════════ // Sinyal şekilleri plotshape(long_condition and show_signals, title="Long Sinyal", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small) plotshape(short_condition and show_signals, title="Short Sinyal", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small) // SL/TP seviyelerini çiz plot(strategy.position_size > 0 ? strategy.position_avg_price * (1 - sl_percent / 100) : na, title="Long SL", color=color.red, style=plot.style_linebr, linewidth=2) plot(strategy.position_size > 0 ? strategy.position_avg_price * (1 + (target_move_percent * tp_multiplier) / 100) : na, title="Long TP", color=color.green, style=plot.style_linebr, linewidth=2) plot(strategy.position_size < 0 ? strategy.position_avg_price * (1 + sl_percent / 100) : na, title="Short SL", color=color.red, style=plot.style_linebr, linewidth=2) plot(strategy.position_size < 0 ? strategy.position_avg_price * (1 - (target_move_percent * tp_multiplier) / 100) : na, title="Short TP", color=color.green, style=plot.style_linebr, linewidth=2) // Entry price çizgisi plot(strategy.position_size != 0 ? strategy.position_avg_price : na, title="Entry Price", color=color.blue, style=plot.style_linebr, linewidth=2) // Filtre durumu şekilleri plotshape(use_adx_filter and not adx_filter and show_signals, title="ADX Zayıf", location=location.bottom, color=color.yellow, style=shape.xcross, size=size.tiny) // Bilgi etiketi var label info_label = na if show_info and barstate.islast // Eski etiketi sil label.delete(info_label) adx_status = use_adx_filter ? "ADX: " + str.tostring(math.round(adx, 1)) + " (>" + str.tostring(adx_threshold) + ") " + (adx_filter ? "✓" : "✗") : "ADX: KAPALI" filter_status = "\n═══ FİLTRE DURUMLARI ═══\n" + adx_status sl_info = "\nSabit SL: %" + str.tostring(sl_percent) position_info = "\nLong Pos: " + (strategy.position_size > 0 ? "AÇIK" : "KAPALI") + "\nShort Pos: " + (strategy.position_size < 0 ? "AÇIK" : "KAPALI") info_text = "Önceki Bar Range: %" + str.tostring(math.round(prev_range_percent, 2)) + "\nHareket Oranı: " + str.tostring(movement_ratio) + "\nHedef Hareket: %" + str.tostring(math.round(target_move_percent, 2)) + "\nMevcut Değişim: %" + str.tostring(math.round(current_change_percent, 2)) + "\n───────────" + "\nLong Üst Üste: " + str.tostring(long_consecutive) + "\nShort Üst Üste: " + str.tostring(short_consecutive) + "\nMin. Gerekli: " + str.tostring(min_consecutive) + filter_status + sl_info + position_info info_label := label.new(bar_index + 5, high, info_text, style=label.style_label_left, color=color.new(color.blue, 80), textcolor=color.white, size=size.small) // Arka plan renklendirme bgcolor(strategy.position_size > 0 ? color.new(color.green, 90) : strategy.position_size < 0 ? color.new(color.red, 90) : na)