该策略基于相对强弱指数(RSI)指标的超卖信号,在日内低点买入,然后设置固定百分比的止盈和止损,回测策略在触及止盈和止损时的概率。主要思路是利用RSI指标超卖时的反转机会,在日内低点介入,博取反转带来的短期收益。同时,使用移动平均线过滤趋势,只在价格高于均线时入场做多。
RSI2策略尝试捕捉RSI指标超卖后的日内反转机会,通过设置固定百分比止盈止损来控制风险,同时使用长周期均线来过滤逆势信号。该策略思路简单,适合短线投机交易者。但其也存在一定局限性,如缺乏趋势判断,难以精准买在最低点,固定止盈止损也限制了策略收益空间。未来可以从动态止盈止损,结合趋势指标,优化入场点,强化仓位管理等方面来改进该策略,提升系统性和鲁棒性,更好地适应多变的市场环境。
/*backtest
start: 2024-03-01 00:00:00
end: 2024-03-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © rajk1987
//@version=5
strategy("RSI2 strategy Raj", overlay=true, margin_long=100, margin_short=100)
rsi_len = input.int( 2, title = "RSI Length", group = "Indicators")
rsi_os = input.float(10, title = "RSI Oversold", group = "Indicators")
rsi_ob = input.float(90, title = "RSI OverBrought", group = "Indicators")
max_los = input.float(3,title = "Max Loss Percent", group = "Indicators")
tar_per = input.float(6,title = "Target Percent",group = "Indicators")
//Get the rsi value of the stock
rsi = ta.rsi(close, rsi_len)
sma = ta.sma(close,200)
var ent_dat = 0
var tar = 0.0
var los = 0.0
var bp = 0.0
if ((close > sma) and (rsi < rsi_os))
strategy.entry("RSI2 Long Entry", strategy.long,1)
ent_dat := time(timeframe = timeframe.period)
if(ent_dat == time(timeframe = timeframe.period))
bp := low //high/2 + low/2
tar := bp * (1 + (tar_per/100))
los := bp * (1 - (max_los/100))
if (time(timeframe = timeframe.period) > ent_dat)
strategy.exit("RSI2 Exit", "RSI2 Long Entry",qty = 1, limit = tar, stop = los, comment_profit = "P", comment_loss = "L")
//plot(rsi,"RSI")
//plot(bp,"BP")
//plot(tar,"TAR")
//plot(los,"LOS")