RSI鳄鱼趋势策略是基于RSI指标的鳄鱼指标组合,用于判断趋势的进入和退出。它使用三条平均线 - 鳄鱼的上颚线、牙齿线和唇线,采用不同周期的RSI构建。当牙齿线上穿唇线且RSI上颚线高于牙齿线时做多;当牙齿线下穿唇线且RSI上颚线低于牙齿线时做空。该策略同时设定了止损和止盈条件。
RSI鳄鱼趋势策略使用RSI指标构建鳄鱼指标的三条移动平均线。具体设置如下:
进入信号的判断逻辑是:
多头信号:当牙齿线上穿唇线,同时上颚线高于牙齿线时,做多。
空头信号:当牙齿线下穿唇线,同时上颚线低于牙齿线时,做空。
该策略同时设定了止损和止盈条件:
RSI鳄鱼趋势策略具有以下优势:
RSI鳄鱼趋势策略也存在以下风险:
牙齿线与唇线的交叉可能出现假突破,导致不必要的亏损。可以适当调整周期参数降低假突破概率。
止损设置可能过于激进,无谓止损的概率较大。可以适当放宽止损范围,或添加其他条件作为止损激活的前提条件。
若行情剧烈,止损或无法起到应有的保证金效果。这时则需要人工干预,及时止损。
多空切换频繁时,交易费用压力较大。可以适当放宽进入条件,减少不必要的反复。
RSI鳄鱼趋势策略可以从以下几个方面进行优化:
优化鳄鱼线的参数设置,调整周期参数,找到最佳参数组合
优化进入的条件逻辑,比如新增交易量指标等过滤信号
优化止盈止损策略,使其更加顺应行情与保证金水平
增加对突发事件的处理机制,避免异常行情的暴露
增加开仓算法,控制单笔投入资金占比,规避风险
RSI鳄鱼趋势策略整体来说是一种可靠、易操作的趋势跟踪策略。它使用鳄鱼指标判断趋势方向,配合RSI指标设定参考阈值,能有效锁定趋势并设定合理的出场点。同时,策略本身也具备较强的灵活性与扩展性,值得实盘应用与后续优化。
/*backtest start: 2023-12-01 00:00:00 end: 2023-12-31 23:59:59 period: 1h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ // @version=3 // RSI Alligator // Forked from Author: Reza Akhavan // Updated by Khalid Salomão strategy("RSI Alligator Strategy", overlay=false, pyramiding=0, default_qty_type=strategy.cash, default_qty_value=25000, initial_capital=25000, commission_type=strategy.commission.percent, commission_value=0.15, slippage=3) // === TA LOGIC === overBought = input(70, minval=0, maxval=100, title="Over bought") overSold = input(30, minval=0, maxval=100, title="Over sold") jawPeriods = input(5, minval=1, title="Jaw Periods") jawOffset = input(0, minval=0, title="Jaw Offset") teethPeriods = input(13, minval=1, title="Teeth Periods") teethOffset = input(0, minval=0, title="Teeth Offset") lipsPeriods = input(34, minval=1, title="Lips Periods") lipsOffset = input(0, minval=0, title="Lips Offset") jaws = rsi(close, jawPeriods) teeth = rsi(close, teethPeriods) lips = rsi(close, lipsPeriods) plot(jaws, color=green, offset=jawOffset, title="Jaw") plot(teeth, color=red, offset=teethOffset, title="Teeth") plot(lips, color=blue, offset=lipsOffset, title="Lips") // // === Signal logic === // LONG_SIGNAL_BOOLEAN = crossover(teeth, lips) and jaws > teeth SHORT_SIGNAL_BOOLEAN = crossunder(teeth, lips) and jaws < teeth // === INPUT BACKTEST DATE RANGE === strategyType = input(defval="Long Only", options=["Long & Short", "Long Only", "Short Only"]) FromMonth = input(defval = 7, title = "From Month", minval = 1, maxval = 12) FromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31) FromYear = input(defval = 2018, title = "From Year", minval = 2017) ToMonth = input(defval = 12, title = "To Month", minval = 1, maxval = 12) ToDay = input(defval = 1, title = "To Day", minval = 1, maxval = 31) ToYear = input(defval = 2020, title = "To Year", minval = 2017) start = timestamp(FromYear, FromMonth, FromDay, 00, 00) finish = timestamp(ToYear, ToMonth, ToDay, 23, 59) window() => true // === STRATEGY BUY / SELL ENTRIES === // TODO: update the placeholder LONG_SIGNAL_BOOLEAN and SHORT_SIGNAL_BOOLEAN to signal // long and short entries buy() => window() and LONG_SIGNAL_BOOLEAN sell() => window() and SHORT_SIGNAL_BOOLEAN if buy() if (strategyType == "Short Only") strategy.close("Short") else strategy.entry("Long", strategy.long, comment="Long") if sell() if (strategyType == "Long Only") strategy.close("Long") else strategy.entry("Short", strategy.short, comment="Short") // === BACKTESTING: EXIT strategy === sl_inp = input(10, title='Stop Loss %', type=float)/100 tp_inp = input(90, title='Take Profit %', type=float)/100 stop_level = strategy.position_avg_price * (1 - sl_inp) take_level = strategy.position_avg_price * (1 + tp_inp) strategy.exit("Stop Loss/Profit", "Long", stop=stop_level, limit=take_level)