该策略是一个基于相对强弱指标(RSI)和动能振荡器(AO)协同作用的量化交易策略。策略主要通过捕捉RSI突破50水平线与AO处于负值区域的配合信号来识别潜在的做多机会。策略采用百分比止盈止损机制来管理风险,默认使用账户10%的资金进行交易。
策略的核心逻辑基于两个技术指标的协同配合: 1. RSI指标:使用14周期的RSI指标监测价格动量,当RSI突破50中轴线时视为上涨动能确立。 2. AO指标:通过对比5周期和34周期的移动平均线计算价格动量,当AO为负值时表明市场处于超卖区域。 3. 入场条件:当RSI突破50且AO为负值时开仓做多,这意味着捕捉到价格在超卖区域出现反转信号。 4. 出场条件:采用2%的止盈和1%的止损设置,确保每笔交易的风险收益比合理。
这是一个结合RSI和AO指标的趋势追踪策略,通过捕捉超卖区域的反转信号进行做多交易。策略设计合理,风险控制到位,但仍有优化空间。建议交易者在实盘使用前进行充分的历史回测,并根据实际市场情况调整参数设置。策略适合风险承受能力较强、对技术分析有一定理解的交易者使用。
/*backtest start: 2024-10-01 00:00:00 end: 2024-10-31 23:59:59 period: 1h basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy(title="🐂 BUY Only - RSI Crossing 50 + AO Negative", shorttitle="🐂 AO<0 RSI+50 Strategy", overlay=true) // ----------------------------- // --- User Inputs --- // ----------------------------- // RSI Settings rsiPeriod = input.int(title="RSI Period", defval=14, minval=1) // AO Settings aoShortPeriod = input.int(title="AO Short Period", defval=5, minval=1) aoLongPeriod = input.int(title="AO Long Period", defval=34, minval=1) // Strategy Settings takeProfitPerc = input.float(title="Take Profit (%)", defval=2.0, minval=0.0, step=0.1) stopLossPerc = input.float(title="Stop Loss (%)", defval=1.0, minval=0.0, step=0.1) // ----------------------------- // --- Awesome Oscillator (AO) Calculation --- // ----------------------------- // Calculate the Awesome Oscillator ao = ta.sma(hl2, aoShortPeriod) - ta.sma(hl2, aoLongPeriod) // Detect AO Crossing Zero aoCrossOverZero = ta.crossover(ao, 0) aoCrossUnderZero = ta.crossunder(ao, 0) // ----------------------------- // --- Relative Strength Index (RSI) Calculation --- // ----------------------------- // Calculate RSI rsiValue = ta.rsi(close, rsiPeriod) // Detect RSI Crossing 50 rsiCrossOver50 = ta.crossover(rsiValue, 50) rsiCrossUnder50 = ta.crossunder(rsiValue, 50) // ----------------------------- // --- Plotting Arrows and Labels --- // ----------------------------- // Plot AO Cross Over Arrow (AO+) plotshape(series=aoCrossOverZero, location=location.belowbar, color=color.green, style=shape.labelup, title="AO Crosses Above Zero", text="AO+", textcolor=color.white, size=size.small) // Plot AO Cross Under Arrow (AO-) plotshape(series=aoCrossUnderZero, location=location.abovebar, color=color.red, style=shape.labeldown, title="AO Crosses Below Zero", text="AO-", textcolor=color.white, size=size.small) // Plot RSI Cross Over Arrow (RSI Up) plotshape(series=rsiCrossOver50, location=location.belowbar, color=color.blue, style=shape.labelup, title="RSI Crosses Above 50", text="RSI Up", textcolor=color.white, size=size.small) // Plot RSI Cross Under Arrow (RSI Down) plotshape(series=rsiCrossUnder50, location=location.abovebar, color=color.orange, style=shape.labeldown, title="RSI Crosses Below 50", text="RSI Down", textcolor=color.white, size=size.small) // ----------------------------- // --- Buy Signal Condition --- // ----------------------------- // Define Buy Signal: AO is negative and previous bar's RSI > 50 buySignal = (ao < 0) and (rsiValue[1] > 50) // Plot Buy Signal plotshape(series=buySignal, location=location.belowbar, color=color.lime, style=shape.triangleup, title="Buy Signal", text="BUY", textcolor=color.black, size=size.small) // ----------------------------- // --- Strategy Execution --- // ----------------------------- // Entry Condition if buySignal strategy.entry("Long", strategy.long) // Exit Conditions // Calculate Stop Loss and Take Profit Prices if strategy.position_size > 0 // Entry price entryPrice = strategy.position_avg_price // Stop Loss and Take Profit Levels stopLevel = entryPrice * (1 - stopLossPerc / 100) takeProfitLevel = entryPrice * (1 + takeProfitPerc / 100) // Submit Stop Loss and Take Profit Orders strategy.exit("Exit Long", from_entry="Long", stop=stopLevel, limit=takeProfitLevel)