资源加载中... loading...

RSI-买卖信号策略

Author: 雨幕(youquant), Date: 2022-06-02 15:44:55
Tags: RSIEMAsma

该指标主要基于超买和超卖。短期交易指标。这样,您可以获得较小但可接受的信号。 该指标的主要依据如下: 要买入,该指标正在等待该工具从RSI角度超卖。然后,如果图表自下而上穿过包络线指示器的底线,则发出买入信号。 对于卖出,指标等待工具从RSI角度超买。然后,如果图表自上而下穿过包络线指示器的顶行,则发出卖出信号。 一般的依据是价格和RSI指标的一致性。 我自己想出的最佳设置: 时间框架:15分钟 超买:80 超卖:25 RSI长度:8 它可以在不同的仪器上完成。但一定要设定盈亏限额。 (本指标的盈亏比可以是1:1。)

免责声明:所提供的信息、交易指标和工具既不是也不应解释为要约或要约邀约,以买卖证券。您应全权负责您做出的任何投资决策,这些决策将完全基于您对财务状况、投资目标、风险承受能力和流动性需求的评估。 我不对应用本指标中包含的信息可能导致的任何利润、财务改善、损失或损害、金钱或其他方面负责。个体交易者必须在分析特色交易指标、其他交易工具、网络研讨会和其他教育材料时进行尽职调查,以确定它们是否代表了适合个体交易者的可用特征和能力。

策略回测

img

img

img


/*backtest
start: 2022-01-01 00:00:00
end: 2022-06-01 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_CTP","currency":"FUTURES"}]
args: [["RunMode",1,360008],["ContractType","rb2210",360008]]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Saleh_Toodarvari

//@version=5
indicator(title="ENVELOPE - RSI - Buy Sell Signals", shorttitle="ENVELOPE - RSI", overlay=true)
//_________________Envelope_________________
len = input.int(8, title="Envelope周期", minval=1, group="Envelope Settings")
percent = input(0.22,title="Envelope百分比", group="Envelope Settings")
src = input(hl2, title="Envelope数据源", group="Envelope Settings")
exponential = input(false, title="使用EMA,不勾选使用SMA")
basis = exponential ? ta.ema(src, len) : ta.sma(src, len)
k = percent/100.0
upper = basis * (1 + k)
lower = basis * (1 - k)
plot(basis, "Basis", color=#ED7300)
u = plot(upper, "Upper", color=#FF2424)
l = plot(lower, "Lower", color=#24FF24)
//fill(u, l, color=color.rgb(33, 150, 243, 95), title="Background")
cross_buy=ta.crossover(close,lower)
cross_sell=ta.crossunder(close,upper) 
// _________________RSI_________________
rsiLengthInput = input.int(8, minval=1, title="RSI 周期", group="RSI Settings")
rsiSourceInput = input.source(hl2, "RSI 数据源", group="RSI Settings")
up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
Overbought_RSI = input(title="RSI 超买 限制(Recommended: 70-85)", defval=80, group="RSI Settings")
Oversold_RSI = input(title="RSI 超卖 限制(Recommended: 20-30)", defval=25, group="RSI Settings")
condition_buy= rsi<Oversold_RSI and (ta.cross(low,lower) or ta.cross(close,lower) or ta.cross(high,lower) or ta.cross(open,lower))
condition_sell= rsi>Overbought_RSI and (ta.cross(low,upper) or ta.cross(close,upper) or ta.cross(high,upper) or ta.cross(open,upper))
if cross_sell
    strategy.entry("Enter Long", strategy.long)
else if cross_buy
    strategy.entry("Enter Short", strategy.short)

// plotshape(cross_sell ? condition_sell:na, title="Sell Label", text="Sell", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white)
// sell_sig=plot(cross_sell ? high:na,color=color.new(#000000,100))
// plotshape(cross_buy ? condition_buy:na, title="Buy Label", text="Buy", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
// buy_sig=plot(cross_buy ? ohlc4:na,color=color.new(#000000,100))
// tpColor = if(cross_sell[1] or cross_sell[2] or cross_buy[1] or cross_buy[2])
//     color.new(#1DBC60, 30)
// else
//     color.new(#000000,100)
// slColor = if(cross_sell[1] or cross_sell[2] or cross_buy[1] or cross_buy[2])
//     color.new(#F74A58, 30)
// else
//     color.new(#000000,100)
// //_________________TP&SL_________________
// TP_Percent = input.float(0.15, "TP %")
// SL_Percent = input.float(0.15, "SL %")
// tp= if condition_sell
//     ohlc4-ohlc4*(TP_Percent/100)
// else if condition_buy
//     ohlc4+ohlc4*(TP_Percent/100)
// sl= if condition_sell
//     ohlc4+ohlc4*(SL_Percent/100)
// else if condition_buy
//     ohlc4-ohlc4*(SL_Percent/100)
// tp_sig=plot(tp,color=color.new(#000000,100),title="tp")
// sl_sig=plot(sl,color=color.new(#000000,100),title="tp")
// lower_plot=plot(lower,color=color.new(#000000,100))
// fill(sell_sig,tp_sig, color=tpColor)
// fill(buy_sig,tp_sig, color=tpColor)
// fill(buy_sig,sl_sig, color=slColor)
// fill(sell_sig,sl_sig, color=slColor)
template: strategy.tpl:40:21: executing "strategy.tpl" at <.api.GetStrategyListByName>: wrong number of args for GetStrategyListByName: want 7 got 6