
Chiến lược này được gọi là chiến lược RSI50_EMA dài, và ý tưởng chính là sử dụng tín hiệu chéo của hai chỉ số kỹ thuật của chỉ số tương đối yếu ((RSI) và chỉ số di chuyển trung bình ((EMA) để đưa ra quyết định giao dịch.
Chiến lược RSI50_EMA là một chiến lược theo dõi xu hướng đơn giản và dễ sử dụng dựa trên RSI và EMA, phù hợp để sử dụng trong tình huống leo thang một bên. Chiến lược có logic rõ ràng, lợi thế rõ ràng, nhưng cũng có một số thiếu sót và rủi ro. Bằng cách giới thiệu nhiều chỉ số hỗ trợ, tham số tối ưu hóa, cải thiện kiểm soát rủi ro và các biện pháp khác, có thể nâng cao hơn nữa sự ổn định và lợi nhuận của chiến lược.
/*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)