这是一个基于均值回归原理设计的量化交易策略,结合了布林带、相对强弱指数(RSI)和平均真实波幅(ATR)等技术指标,通过识别市场超买超卖状态进行交易。策略采用低风险回报比设置以提高胜率,并通过资金管理来控制风险。
策略主要通过以下几个方面来实现交易: 1. 使用布林带(20日)作为价格波动区间的判断依据 2. 通过RSI(14日)判断市场超买超卖状态 3. 利用ATR(14日)动态设置止损和获利目标 4. 当价格突破布林带下轨且RSI低于30时入场做多 5. 当价格突破布林带上轨且RSI高于70时入场做空 6. 设置0.75的风险回报比,以提高策略胜率 7. 采用基于账户权益的2%风险控制
该策略通过均值回归原理和多重技术指标的结合,构建了一个稳健的交易系统。低风险回报比的设置有助于提高胜率,而严格的风险管理则确保了资金安全。虽然存在一些固有风险,但通过持续优化和完善,策略有望获得更好的表现。这是一个适合稳健型交易者的策略,特别适合波动性较大的市场。
/*backtest start: 2024-01-01 00:00:00 end: 2024-11-11 00:00:00 period: 2d basePeriod: 2d exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("High Win Rate Mean Reversion Strategy for Gold", overlay=true) // Input Parameters bbLength = input.int(20, title="Bollinger Bands Length") bbMult = input.float(2, title="Bollinger Bands Multiplier") rsiLength = input.int(14, title="RSI Length") rsiOverbought = input.int(70, title="RSI Overbought Level") rsiOversold = input.int(30, title="RSI Oversold Level") atrLength = input.int(14, title="ATR Length") rrRatio = input.float(0.75, title="Risk/Reward Ratio", step=0.05) // Lower RRR to achieve a high win rate riskPerTrade = input.float(2.0, title="Risk per Trade (%)", step=0.1) / 100 // 2% risk per trade // Bollinger Bands Calculation basis = ta.sma(close, bbLength) dev = bbMult * ta.stdev(close, bbLength) upperBand = basis + dev lowerBand = basis - dev // RSI Calculation rsi = ta.rsi(close, rsiLength) // ATR Calculation for Stop Loss atr = ta.atr(atrLength) // Entry Conditions: Mean Reversion longCondition = close < lowerBand and rsi < rsiOversold shortCondition = close > upperBand and rsi > rsiOverbought // Stop Loss and Take Profit based on ATR longStopLoss = close - atr * 1.0 // 1x ATR stop loss for long trades shortStopLoss = close + atr * 1.0 // 1x ATR stop loss for short trades longTakeProfit = close + (close - longStopLoss) * rrRatio // 0.75x ATR take profit shortTakeProfit = close - (shortStopLoss - close) * rrRatio // 0.75x ATR take profit // Calculate position size based on risk equity = strategy.equity riskAmount = equity * riskPerTrade qtyLong = riskAmount / (close - longStopLoss) qtyShort = riskAmount / (shortStopLoss - close) // Long Trade if (longCondition) strategy.entry("Long", strategy.long, qty=qtyLong) strategy.exit("Take Profit/Stop Loss", from_entry="Long", limit=longTakeProfit, stop=longStopLoss) // Short Trade if (shortCondition) strategy.entry("Short", strategy.short, qty=qtyShort) strategy.exit("Take Profit/Stop Loss", from_entry="Short", limit=shortTakeProfit, stop=shortStopLoss) // Plot Bollinger Bands plot(upperBand, color=color.red, linewidth=2, title="Upper Bollinger Band") plot(lowerBand, color=color.green, linewidth=2, title="Lower Bollinger Band") plot(basis, color=color.gray, linewidth=2, title="Bollinger Basis") // Plot RSI for visual confirmation hline(rsiOverbought, "Overbought", color=color.red) hline(rsiOversold, "Oversold", color=color.green) plot(rsi, color=color.purple, title="RSI")