该策略是一个多指标协同的趋势反转交易系统,主要结合了相对强弱指标(RSI)、抛物线指标(SAR)和简单移动平均线(SMA)三个技术指标。策略的核心思想是通过RSI超买卖信号预警潜在的反转机会,再利用SAR指标的方向变化确认反转信号,最后使用移动平均线作为动态止盈止损参考。这种多指标协同验证的方法可以有效降低假信号的干扰,提高交易的可靠性。
策略运行机制主要分为三个步骤: 1. 信号预警:监控RSI指标是否出现超买(>70)或超卖(<30)信号,这类信号往往预示着可能出现价格反转。 2. 入场确认:在RSI发出信号后的1-3个K线内,如果SAR指标也出现方向反转(由上方转到下方或由下方转到上方),则确认入场信号。具体而言: - 做多条件:RSI超卖后3根K线内SAR由上方转至下方 - 做空条件:RSI超买后3根K线内SAR由下方转至上方 3. 退出机制:使用21周期简单移动平均线(SMA)作为动态止盈止损线,当价格与均线发生穿越时平仓: - 多头平仓:价格跌破21均线 - 空头平仓:价格突破21均线
该策略通过RSI和SAR的协同配合,构建了一个相对可靠的趋势反转交易系统。使用移动平均线作为动态风控工具,既保证了对趋势的有效把握,又实现了风险的动态控制。策略的主要优势在于多重信号验证和清晰的交易规则,但在实际应用中需要注意市场环境的识别和参数的动态优化。通过添加市场环境过滤、优化止损方式、完善仓位管理等方向的改进,可以进一步提升策略的稳定性和盈利能力。
/*backtest
start: 2024-07-15 00:00:00
end: 2025-02-15 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Binance","currency":"BNB_USDT"}]
*/
//@version=5
strategy("SAR + RSI Strategy", overlay=true, margin_long=100, margin_short=100)
// ———————— SAR Parameters ————————
start = input(0.02, "SAR Start")
increment = input(0.02, "SAR Increment")
maximum = input(0.2, "SAR Maximum")
// ———————— RSI Parameters ————————
rsiLength = input(14, "RSI Length")
upperLevel = input(70, "RSI Upper Level")
lowerLevel = input(30, "RSI Lower Level")
// ———————— SMA Parameter ————————
smaLength = input(21, "SMA Exit Length")
// ———————— Indicators Calculation ————————
// SAR Calculation
sarValue = ta.sar(start, increment, maximum)
sarUp = sarValue < close
sarDown = sarValue > close
// RSI Calculation
rsi = ta.rsi(close, rsiLength)
rsiOverbought = ta.cross(rsi, upperLevel)
rsiOversold = ta.cross(rsi, lowerLevel)
// SMA Calculation
sma21 = ta.sma(close, smaLength)
// ———————— Entry Conditions ————————
longCondition =
// RSI oversold signal occurred in last 3 bars
(ta.barssince(rsiOversold) <= 3) and
// SAR reversal to bullish occurs now
sarUp and not sarUp[1]
shortCondition =
// RSI overbought signal occurred in last 3 bars
(ta.barssince(rsiOverbought) <= 3) and
// SAR reversal to bearish occurs now
sarDown and not sarDown[1]
// ———————— Exit Conditions ————————
exitLong = ta.crossunder(close, sma21)
exitShort = ta.crossover(close, sma21)
// ———————— Strategy Execution ————————
strategy.entry("Long", strategy.long, when=longCondition)
strategy.close("Long", when=exitLong)
strategy.entry("Short", strategy.short, when=shortCondition)
strategy.close("Short", when=exitShort)
// ———————— Visualizations ————————
// plot(sarValue, "SAR", style=plot.style_circles, color=sarUp ? color.green : color.red)
// plot(sma21, "21 SMA", color=color.orange)