该策略是一个结合了多重技术指标的短线交易系统,主要基于抛物线转向指标(PSAR)作为核心信号,同时结合了均线、动量指标进行交易过滤,并采用动态止损和固定止盈相结合的风险管理方法。策略设计充分考虑了市场趋势和波动性,适合在波动较大的市场环境中进行短线交易。
策略采用PSAR指标作为主要的趋势判断工具,当价格突破PSAR时产生交易信号。为了提高信号的可靠性,加入了以下过滤条件: 1. 50周期指数移动平均线(EMA50)作为趋势过滤器,确保交易方向与中期趋势一致 2. 相对强弱指数(RSI)用于过滤震荡市场,多头持仓要求RSI>40,空头持仓要求RSI<60 3. 使用ATR(平均真实波幅)动态计算止损位置,提供更灵活的风险控制 4. 采用0.7%的固定止盈目标,确保盈利及时落袋为安 5. 设置持仓检查机制,避免重复开仓
该策略通过结合多个技术指标构建了一个完整的交易系统,在趋势判断、风险控制和交易执行等方面都有较好的考虑。策略的核心优势在于其灵活的风险控制机制和完备的信号系统,但同时也需要注意参数优化和市场适应性的问题。通过持续优化和改进,该策略有望在不同市场环境下都能保持稳定的表现。
/*backtest
start: 2024-02-20 00:00:00
end: 2025-02-17 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=6
strategy("妮可百分百", overlay=true)
// 📌 設定 Parabolic SAR 參數
start = input.float(0.02, "起始 AF")
increment = input.float(0.02, "加速因子")
maximum = input.float(0.2, "最大 AF")
// 📌 計算 Parabolic SAR
SAR = ta.sar(start, increment, maximum)
// 📌 ATR 計算(用於動態止損)
atrLength = input.int(14, "ATR 計算週期")
atrMultiplier = input.float(1.3, "ATR 係數") // 2倍 ATR 作為止損範圍
ATR = ta.atr(atrLength)
// 📌 固定 0.5% 止盈計算
takeProfitPercent = 0.007 // 0.7% 固定止盈
takeProfitLong = close * (1 + takeProfitPercent) // 多單止盈
takeProfitShort = close * (1 - takeProfitPercent) // 空單止盈
// 📌 **50 EMA 過濾**
ema50 = ta.ema(close, 50)
// 📌 **RSI 過濾(防止震盪進場)**
rsiLength = input.int(14, "RSI 週期")
rsi = ta.rsi(close, rsiLength)
longFilter = rsi > 40 // 只在 RSI > 31 時做多
shortFilter = rsi < 60 // 只在 RSI < 69 時做空
// 📌 **檢查是否已經有持倉**
isFlat = strategy.position_size == 0 // **無持倉時,才能開新單**
// 🔼 **多頭進場條件**
longCondition = ta.crossover(close, SAR) and close > ema50 and longFilter and isFlat
// 🔽 **空頭進場條件**
shortCondition = ta.crossunder(close, SAR) and close < ema50 and shortFilter and isFlat
// 📌 **進場策略**
if (longCondition)
strategy.entry("B", strategy.long, comment="B")
if (shortCondition)
strategy.entry("S", strategy.short, comment="S")
// 📌 **止盈 & 止損**
stopLossLong = close - (ATR * atrMultiplier) // 多單 ATR 止損
stopLossShort = close + (ATR * atrMultiplier) // 空單 ATR 止損
strategy.exit("Exit Long", from_entry="B", stop=stopLossLong, limit=takeProfitLong, comment="TP Long")
strategy.exit("Exit Short", from_entry="S", stop=stopLossShort, limit=takeProfitShort, comment="TP Short")
// 📌 **標記進出場點**
plotshape(series=longCondition, location=location.belowbar, style=shape.triangleup, size=size.small, title="B")
plotshape(series=shortCondition, location=location.abovebar, style=shape.triangledown, size=size.small, title="S")
// 📌 **繪製 50 EMA**
plot(ema50, color=color.blue, title="50 EMA")