该策略名为”RSI50_EMA长仓策略”,主要思路是利用相对强弱指数(RSI)和指数移动平均线(EMA)两个技术指标的交叉信号来进行交易决策。当价格从下向上突破EMA上轨且RSI大于50时开仓做多,当价格从上向下突破EMA下轨或RSI跌破50时平仓。该策略只做多、不做空,是一个追涨策略。
RSI50_EMA长仓策略是一个基于RSI和EMA的简单易用的趋势追踪策略,适合在单边上涨行情中使用。该策略逻辑清晰,优势明显,但是也存在一些不足和风险。通过引入更多辅助指标、优化参数、改进风控等措施,可以进一步提升该策略的稳定性和收益性。但是在实际应用中,还需要根据市场特点、个人风险偏好等因素,灵活调整和改进。
/*backtest
start: 2023-05-05 00:00:00
end: 2024-05-10 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy("RSI50_EMA Long Only Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
len = input(11, type=input.integer, minval=1, title="Length")
mul = input(2, type=input.float, minval=0, title="Multiplier")
rsicap = input(50, type=input.integer, minval=1, title="rsicap")
rsi_1 = rsi(close,20)
price = sma(close, 2)
average = ema(close, len)
diff = atr(len) * mul
bull_level = average + diff
bear_level = average - diff
bull_cross = crossover(price, bull_level)
RENTRY = crossover(rsi_1,rsicap)
bear_cross = crossover(bear_level, price)
EXIT = crossunder(rsi_1,50)
strategy.entry("Buy", strategy.long, when=bull_cross)
strategy.close("Buy", when=bear_cross) //strategy.entry("Sell", strategy.short, when=bear_cross)
if (RENTRY)
strategy.entry("RSI", strategy.long, when=bull_cross)
if (EXIT)
strategy.close("RSICLose", when=bull_cross) //strategy.entry("Sell", strategy.short, when=bear_cross)
plot(price, title="price", color=color.black, transp=50, linewidth=2)
a0 = plot(average, title="average", color=color.red, transp=50, linewidth=1)
a1 = plot(bull_level, title="bull", color=color.green, transp=50, linewidth=1)
a2 = plot(bear_level, title="bear", color=color.red, transp=50, linewidth=1)
fill(a0, a1, color=color.green, transp=97)
fill(a0, a2, color=color.red, transp=97)