本策略是一个基于双周期RSI(相对强弱指标)的趋势跟踪交易系统,结合了金字塔式加仓管理。策略通过对比两个不同周期(14和30)的RSI指标,在趋势初期介入并在趋势延续时通过限价单进行加仓,实现对趋势的最大化把握。系统设计了完整的风险控制机制,包括仓位管理和动态平仓条件。
策略采用双周期RSI交叉信号作为交易触发条件,并结合金字塔式加仓管理。具体来说: 1. 入场信号:使用14周期RSI突破超卖(30)和超买(70)水平作为开仓信号 2. 加仓管理:在开仓后通过设定价格偏离1.5%的限价单实现二次加仓 3. 平仓信号:使用30周期RSI作为平仓指标,当RSI从超买区回落或从超卖区反弹时触发平仓 4. 仓位控制:系统允许最多持有两个头寸(pyramiding=2),每次开仓数量可独立设置
该策略通过双周期RSI和金字塔式加仓的结合,实现了对趋势的良好把握。策略设计了完整的交易系统,包括入场、加仓、止损和仓位管理等关键要素。通过参数优化和风险管理的改进,策略有望在实际交易中取得稳定表现。建议交易者在实盘使用前,充分测试并根据具体市场特征调整参数。
/*backtest
start: 2024-12-17 00:00:00
end: 2025-01-16 00:00:00
period: 3h
basePeriod: 3h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT","balance":49999}]
*/
//@version=5
strategy("RSI Top Strategy", overlay=true, pyramiding=2)
qty1 = input( 1 , "Qty first entry", group="Strategy settings")
qty2 = input( 1 , "Qty second entry", group="Strategy settings")
avg1 = input.float( 1.5 , "% averaging ", group="Strategy settings")
overSold = input( 30 , group="open RSI Settings")
overBought = input( 70 , group="open RSI Settings")
rsi1len = input.int(14, minval=1, title="open RSI Length", group="open RSI Settings")
overSold2 = input( 30 , group="close RSI Settings")
overBought2 = input( 70 , group="close RSI Settings")
rsi2len = input.int(30, minval=1, title="close RSI Length", group="close RSI Settings")
price = close
vrsi = ta.rsi(price, rsi1len)
vrsi2 = ta.rsi(price, rsi2len)
sz=strategy.position_size
co = ta.crossover(vrsi, overSold)
cu = ta.crossunder(vrsi, overBought)
if (not na(vrsi))
if (co) and not (sz>0)
strategy.entry("Long", strategy.long, qty = qty1, comment="Long")
Avgl=close-close*0.01*avg1
strategy.entry("AvgL", strategy.long, qty = qty2, limit=Avgl, comment="AvgL")
if (cu) and not (sz<0)
strategy.entry("Short", strategy.short, qty = qty1, comment="Short")
Avgs=close+close*0.01*avg1
strategy.entry("AvgS", strategy.short, qty = qty2, limit=Avgs, comment="AvgS")
//plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr)
if sz[1]<0 and sz<0 and vrsi2<overBought2 and vrsi2[1]>=overBought2
strategy.close_all("x")
if sz[1]>0 and sz>0 and vrsi2>overSold2 and vrsi2[1]<=overSold2
strategy.close_all("x")
plot(vrsi,'open rsi',color=color.green)
plot(vrsi2,'close rsi',color=color.red)
hline(overBought, "RSI Upper Band", color=#787B86)
hline(overSold, "RSI Upper Band", color=#787B86)