该策略是基于Stoch RSI指标设计的趋势追踪策略。它结合了RSI和Stoch指标的优点,通过Stoch RSI的交叉来产生交易信号,采用趋势追踪机制,dynamically调整止损和止盈线,实现优化资金管理。
策略通过计算RSI的Stoch K和D线,当Stoch RSI的K线从低位向上突破20时产生买入信号。随后设置一个以前几根K线最低价为基准的止损位,并随价格上涨dynamically调整止损线。同时设定一个基于最高价的止盈线,在价格达到止盈线时平仓套利。
该策略结合Stoch RSI指标判断市场趋势和交叉产生信号,避免了单一RSI指标的局限性。同时,趋势追踪机制使止损线可以随价格运行不断上调,避免了过早止损退出的风险,可以持续捕捉趋势行情。此外,RSI指标本身就具有较好的胜率。
该策略主要依赖Stoch RSI指标判断趋势和交叉产生信号,如果指标本身发出错误信号,将面临一定的风险。此外,在震荡行情中,止损线和止盈线可能被频繁触发,从而影响策略盈利能力。可以通过参数优化降低风险。
本策略整合了Stoch RSI指标的优势,设计了趋势追踪机制,可以有效识别趋势行情, dynamically调整止损止盈增加获利概率。通过参数优化可以进一步增强策略稳定性和跟踪能力。总体来说,该策略可以获利的同时控制风险,值得实盘验证。
/*backtest
start: 2023-01-26 00:00:00
end: 2024-02-01 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
strategy("sdf",calc_on_every_tick=true,precision=8,
default_qty_type=strategy.fixed,currency="USD")
//entradas y variables de indicadores
smoothK = input(3, minval=1)
smoothD = input(3, minval=1)
lengthRSI = input(14, minval=1)
lengthStoch = input(14, minval=1)
src = input(close, title="RSI Source")
rsi1 = rsi(src, lengthRSI)
k = sma(stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = sma(k, smoothD)
overbought=input(80)
oversold=input(20)
//entradas de stop , trail, profit
stop=input(1500)
stop_dentro_de_los_ultimos_lows=input(20)
trail_points=input(500)
trail_offset=input(100)
profit=input(1000)
riesgo_en_dolares=input(15)
marsi=sma(rsi(close,14),14)
//condicion de compra: k>80
buycondition=crossover(k,20) and security(syminfo.ticker,"240",rsi(close,14)>marsi)
bgcolor( security(syminfo.ticker,"240",rsi(close,14)>marsi) ? yellow : na , transp=0)
if year>2014
strategy.entry("l",strategy.long,qty=1,when=buycondition)
velasiguente=barssince(buycondition)+1 //cierre en cada vela nueva independientemente si subeObaja.FUNCIONANDO
strategy.close("l",when=velasiguente>2) //cierre en cada vela nueva independientemente si subeObaja.FUNCIONANDO
//paradaMasBajo=lowest(low,stop_dentro_de_los_ultimos_lows)//stop_dentro_de_los_ultimos_lows, NO PROBADA
//strategy.exit("l",loss=paradaMasBajo,profit=profit)
plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)