本策略是一个基于RSI和Supertrend指标的趋势跟踪系统,结合了ATR波动率进行风险管理。策略通过对趋势信号和超买超卖区域的判断来确定入场时机,并使用基于市场波动性的动态止盈止损来管理风险。该策略采用15分钟时间周期,默认使用15%的资金管理规则。
策略主要依据以下几个核心要素进行交易: 1. 使用Supertrend指标(参数为2.76)作为主要趋势判断工具,当方向发生变化时产生交易信号 2. 引入RSI指标(周期为12)作为过滤器,防止在超买超卖区域逆势交易 3. 采用ATR指标(周期为12)动态计算止损和止盈位置,提供风险管理框架 4. 多头入场条件:Supertrend指示买入且RSI低于70 5. 空头入场条件:Supertrend指示卖出且RSI高于30 6. 止损设置为当前价格±4倍ATR 7. 止盈设置为当前价格±2或2.237倍ATR
这是一个结构完整、逻辑清晰的趋势跟踪策略。通过将Supertrend、RSI和ATR三个指标有机结合,在捕捉趋势的同时也注重风险控制。策略的核心优势在于其自适应性和风险管理框架,但在实际应用中仍需要根据市场环境进行适当的参数调整和优化。
/*backtest
start: 2023-12-02 00:00:00
end: 2024-11-28 08:00:00
period: 3d
basePeriod: 3d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("ETH Signal 15m", overlay=true)
// Backtest period
start_time = input(timestamp("2024-08-01 00:00"), title="Backtest Start Time")
end_time = input(timestamp("2054-01-01 00:00"), title="Backtest End Time")
atrPeriod = input(12, "ATR Length")
factor = input.float(2.76, "Factor", step=0.01)
rsiLength = input(12, title="RSI Length")
rsiOverbought = input(70, title="RSI Overbought Level")
rsiOversold = input(30, title="RSI Oversold Level")
[_, direction] = ta.supertrend(factor, atrPeriod)
rsi = ta.rsi(close, rsiLength)
// Ensure current time is within the backtest period
in_date_range = true
// Long condition: Supertrend buy signal and RSI not overbought
if in_date_range and ta.change(direction) < 0 and rsi < rsiOverbought
strategy.entry("Long", strategy.long)
// Short condition: Supertrend sell signal and RSI not oversold
if in_date_range and ta.change(direction) > 0 and rsi > rsiOversold
strategy.entry("Short", strategy.short)
// Optional: Add stop loss and take profit using ATR
atr = ta.atr(atrPeriod)
strategy.exit("Exit Long", "Long", stop=close - 4 * atr, limit=close + 2 * atr)
strategy.exit("Exit Short", "Short", stop=close + 4 * atr, limit=close - 2.237 * atr)