
Die Strategie ist ein Trend-Tracking-Trading-System, das auf einem Multiple-Index-Moving-Average (EMA) basiert. Es verwendet ein Gold-Kreuz, das aus drei Ebenen EMA25, EMA50 und EMA100 gebildet wird, um einen starken Aufwärtstrend zu bestätigen und bei einem Preisbruch der EMA25 eine Eintrittsrunde zu erstellen. Die Strategie verwaltet Risiken und Gewinne mit einem dynamischen Stop-Loss- und einem getrennten Stop-Stop.
Die Kernlogik der Strategie umfasst die folgenden Schlüsselelemente:
Durch die Kombination von mehreren Mittellinien und der Batch-Betriebsmethode wurde ein relativ vollständiges Trend-Tracking-Handelssystem aufgebaut. Die Strategie hat den Vorteil, dass sie mehrere wichtige Elemente der Trend-Tracking und des Risikomanagements kombiniert, aber immer noch Parameteroptimierungen und Regelverbesserungen nach den tatsächlichen Marktbedingungen erfordert. Durch die empfohlene Optimierungsrichtung wird erwartet, dass die Strategie in verschiedenen Marktumgebungen stabil bleibt.
/*backtest
start: 2024-11-19 00:00:00
end: 2024-12-18 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=6
strategy("Golden Cross with Customizable TP/SL", overlay=true)
// Parameters for EMA
ema_short_length = 25
ema_mid_length = 50
ema_long_length = 100
// Parameters for stop-loss and take-profit
lookback_bars = input.int(20, title="Lookback bars for lowest low")
pip_buffer = input.float(0.0003, title="Stop-loss buffer (pips)") // Fixed default pip value (e.g., 3 pips for 5-digit pairs)
tp_multiplier1 = input.float(1.0, title="Take-profit multiplier 1")
tp_multiplier2 = input.float(1.5, title="Take-profit multiplier 2")
// Calculate EMAs
ema25 = ta.ema(close, ema_short_length)
ema50 = ta.ema(close, ema_mid_length)
ema100 = ta.ema(close, ema_long_length)
// Golden Cross condition (EMA25 > EMA50 > EMA100)
golden_cross = ema25 > ema50 and ema50 > ema100
// Entry condition: Candle crosses above EMA25 after a golden cross
cross_above_ema25 = ta.crossover(close, ema25)
entry_condition = golden_cross and cross_above_ema25
// Stop-loss and take-profit calculation
lowest_low = ta.lowest(low, lookback_bars)
var float entry_price = na
var float stop_loss = na
var float take_profit1 = na
var float take_profit2 = na
if (entry_condition)
entry_price := close
stop_loss := lowest_low - pip_buffer
take_profit1 := entry_price + (entry_price - stop_loss) * tp_multiplier1
take_profit2 := entry_price + (entry_price - stop_loss) * tp_multiplier2
strategy.entry("Buy1", strategy.long, qty=0.5) // First 50%
strategy.entry("Buy2", strategy.long, qty=0.5) // Second 50%
// Separate exit conditions for each entry
cross_below_ema100 = ta.crossunder(close, ema100)
exit_condition1 = close >= take_profit1
exit_condition2 = close >= take_profit2
exit_condition_sl = close <= stop_loss
if (exit_condition1 or cross_below_ema100)
strategy.close("Buy1")
if (exit_condition2 or cross_below_ema100 or exit_condition_sl)
strategy.close("Buy2")
// Plot EMAs
plot(ema25, color=color.blue, title="EMA 25")
plot(ema50, color=color.orange, title="EMA 50")
plot(ema100, color=color.red, title="EMA 100")