Untitled
unknown
plain_text
2 months ago
2.5 kB
34
Indexable
// Uzun Yönlü Kaplumbağa Ticaret Stratejisi // TradingView Pine Script //@version=5 strategy("Turtle Trading Strategy - Long Only", overlay=true) // Kullanıcı tarafından ayarlanabilir parametreler donchian_period = input.int(20, title="Donchian Kanal Periyodu", minval=1) atr_period = input.int(14, title="ATR Periyodu", minval=1) risk_percent = input.float(2.0, title="Risk Yüzdesi (%)", minval=0.1, step=0.1) stop_atr_multiplier = input.float(2.0, title="ATR Stop Çarpanı", minval=0.1, step=0.1) // Donchian Kanalları hesaplama upper_band = ta.highest(high, donchian_period) lower_band = ta.lowest(low, donchian_period) // ATR hesaplama atr_value = ta.atr(atr_period) // Giriş sinyali (sadece uzun pozisyonlar için) long_entry = ta.crossover(close, upper_band[1]) // Stop loss hesaplama stop_loss = close - (atr_value * stop_atr_multiplier) // Risk hesaplama risk_amount = (close - stop_loss) * strategy.position_size contract_size = (strategy.equity * (risk_percent / 100)) / risk_amount // Pozisyon boyutu yuvarlama (daha gerçekçi pozisyon boyutları için) contract_size_rounded = math.floor(contract_size) // Strateji giriş/çıkış noktaları if (long_entry) strategy.entry("Long", strategy.long, qty=contract_size_rounded) strategy.exit("Exit Long", "Long", stop=stop_loss) // Donchian kanallarını göster upper_plot = plot(upper_band, title="Üst Bant", color=color.green, linewidth=2) lower_plot = plot(lower_band, title="Alt Bant", color=color.red, linewidth=2) fill(upper_plot, lower_plot, title="Kanal İç Dolgu", color=color.new(color.purple, 90)) // Stop loss'u göster plot(strategy.position_size > 0 ? stop_loss : na, title="Stop Loss", color=color.red, style=plot.style_cross, linewidth=2) // Bilgi paneli var table info_table = table.new(position.top_right, 5, 3, border_width=1) if (barstate.islastconfirmedhistory) table.cell(info_table, 0, 0, "Kaplumbağa Stratejisi", bgcolor=color.blue, text_color=color.white) table.cell(info_table, 0, 1, "Periyot: " + str.tostring(donchian_period), text_color=color.black) table.cell(info_table, 0, 2, "Risk: %" + str.tostring(risk_percent), text_color=color.black) table.cell(info_table, 1, 0, "ATR Stop", bgcolor=color.red, text_color=color.white) table.cell(info_table, 1, 1, "ATR Periyot: " + str.tostring(atr_period), text_color=color.black) table.cell(info_table, 1, 2, "ATR Çarpan: " + str.tostring(stop_atr_multiplier), text_color=color.black)
Editor is loading...
Leave a Comment