This strategy is a quantitative trading system based on technical analysis, primarily focusing on identifying triple bottom patterns and momentum breakthrough signals in the market. The strategy combines multiple technical indicators including Moving Average (MA) crossovers, Average True Range (ATR), and price channels to build a complete trading system. Through programmatic implementation, it achieves automated identification of triple bottom rebound patterns and trade execution.
The core logic includes the following key elements: 1. Using fast (5-period) and slow (20-period) moving average crossovers to confirm market trend direction 2. Automatically identifying three consecutive low points (low1, low2, low3) to form a triple bottom pattern 3. Utilizing ATR indicator to calculate volatility and set dynamic stop-loss and take-profit levels 4. Confirming long entry signals when price breaks above previous rebound high after the third bottom, combined with MA crossover signals 5. Establishing parallel channels to visualize price movement ranges for additional market reference 6. Implementing ATR-based dynamic stop-loss and take-profit conditions during trade execution
This strategy implements a triple bottom rebound breakthrough trading system programmatically, combining multiple technical indicators and risk management measures with good practicality. Through continuous optimization and improvement, the strategy shows promise for better performance in actual trading. It is recommended to conduct thorough backtesting before live trading and adjust parameters according to specific market conditions.
/*backtest start: 2019-12-23 08:00:00 end: 2025-01-08 08:00:00 period: 1d basePeriod: 1d exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT","balance":49999}] */ //@version=5 strategy("反彈三次突破策略", overlay=true, initial_capital=100000, commission_value=0.001425, slippage=1) // === 參數設定 === fast_length = input.int(5, title="快速均線週期") slow_length = input.int(20, title="慢速均線週期") atr_period = input.int(14, title="ATR 週期") atr_factor = input.float(2.0, title="ATR 因子") profit_factor = input.float(2.0, title="止盈因子") // === 計算均線 === fast_ma = ta.ema(close, fast_length) slow_ma = ta.ema(close, slow_length) // === 均線交叉訊號 === long_signal = ta.crossover(fast_ma, slow_ma) short_signal = ta.crossunder(fast_ma, slow_ma) // === 計算 ATR === atr = ta.atr(atr_period) // === 反彈三次突破策略 === var float low1 = na var float low2 = na var float low3 = na var bool trend_down = false var bool long_breakout = false var line lower_line = na var line upper_line = na if (na(low1) or na(low2) or na(low3)) // 初始化低點 low1 := na low2 := na low3 := na if (close < low3 or na(low3)) // 更新低點 low1 := low2 low2 := low3 low3 := close trend_down := true if (trend_down and close > low2 and close > low1) // 確認反轉且第三次反彈比第二次高 trend_down := false long_breakout := true // 清除前一個反彈通道 if (not na(lower_line)) line.delete(lower_line) if (not na(upper_line)) line.delete(upper_line) // 繪製新的反彈通道 if (not na(low1) and not na(low3)) lower_line := line.new(x1=bar_index[2], y1=low1, x2=bar_index, y2=low3, color=color.yellow, width=2) upper_line := line.new(x1=bar_index[2], y1=low1 + (low3 - low1), x2=bar_index, y2=low3 + (low3 - low1), color=color.yellow, width=2) // === 進出場條件 === var float last_long_exit = na var float last_short_exit = na var float stop_loss_long = na var float take_profit_long = na var float stop_loss_short = na var float take_profit_short = na var label stop_loss_label_long = na var label take_profit_label_long = na var label stop_loss_label_short = na var label take_profit_label_short = na if (long_signal or long_breakout) if na(last_short_exit) or (time - last_short_exit) > 2 * 60 * 60 * 1000 // 確保多頭出場後有一段時間間隔 // 做多 strategy.entry("做多", strategy.long) // 止損設置為最近低點下方 stop_loss_long := low3 - atr_factor * atr take_profit_long := close + profit_factor * atr // 設定止盈位置 strategy.exit("止盈/止損", "做多", stop=stop_loss_long, limit=take_profit_long) last_long_exit := time // 記錄多頭出場時間 // 刪除之前的止盈止損標籤 if (not na(stop_loss_label_long)) label.delete(stop_loss_label_long) if (not na(take_profit_label_long)) label.delete(take_profit_label_long) // 繪製新的止盈止損標籤 stop_loss_label_long := label.new(x=bar_index, y=stop_loss_long, text=str.tostring(math.round(stop_loss_long * 10) / 10), color=color.red, style=label.style_label_down, textcolor=color.white, size=size.small) take_profit_label_long := label.new(x=bar_index, y=take_profit_long, text=str.tostring(math.round(take_profit_long * 10) / 10), color=color.green, style=label.style_label_up, textcolor=color.white, size=size.small) if (short_signal) if na(last_long_exit) or (time - last_long_exit) > 2 * 60 * 60 * 1000 // 確保空頭出場後有一段時間間隔 // 做空 strategy.entry("做空", strategy.short) // 止損設置為最近高點上方 stop_loss_short := high + atr_factor * atr take_profit_short := close - profit_factor * atr // 設定止盈位置 strategy.exit("止盈/止損", "做空", stop=stop_loss_short, limit=take_profit_short) last_short_exit := time // 記錄空頭出場時間 // 刪除之前的止盈止損標籤 if (not na(stop_loss_label_short)) label.delete(stop_loss_label_short) if (not na(take_profit_label_short)) label.delete(take_profit_label_short) // 繪製新的止盈止損標籤 stop_loss_label_short := label.new(x=bar_index, y=stop_loss_short, text=str.tostring(math.round(stop_loss_short * 10) / 10), color=color.red, style=label.style_label_down, textcolor=color.white, size=size.small) take_profit_label_short := label.new(x=bar_index, y=take_profit_short, text=str.tostring(math.round(take_profit_short * 10) / 10), color=color.green, style=label.style_label_up, textcolor=color.white, size=size.small)