
この戦略は,複数の指数移動平均 ((EMA) に基づくトレンド追跡取引システムである.これは,EMA25,EMA50,EMA100の3つの均線が形成された黄金のクロスを使用して,強い上昇傾向を確認し,価格がEMA25を破るときに入場を区分する.この戦略は,ダイナミックなストップ・ロスと区分されたストップ・ストップの方法でリスクと利益を管理する.
戦略の中核となるロジックには、次の主要な部分が含まれます。
この戦略は,複数の均線組合せと分期操作方法によって,より完全なトレンド追跡取引システムを構築している.戦略の優点は,トレンド追跡とリスク管理の複数の重要な要素を組み合わせていることにあるが,実際の市場状況に応じてパラメータ最適化とルール改進が必要である.提案された最適化方向によって,戦略は,異なる市場環境で安定したパフォーマンスを維持することが期待されている.
/*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")