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

BB-RSI-ADX指标入场点策略

Author: 雨幕(youquant), Date: 2022-05-30 10:06:30
Tags: RSIADXBB

这是一组用于寻找可能逆转的超卖和超买切入点的指标。

  • 当满足进入多头头寸的所有条件时,将出现绿色箭头。
  • 当满足进入空头头寸的所有条件时,将出现红色箭头。

您可以从指示器的设置中修改所有这些条件参数。

指标信号如何工作,这些信号使用布林带、BB %B、RSI和ADX指标来试图找到反转点

  • 进入多头条件 当前BAR最低价低于BB下限。 BB %B大于0。 RSI>30 ADX>25

  • 进入空头条件 当前BAR最高价高于BB上限。 BB %B小于1。 RSI<70 ADX>25

这些是默认设置,似乎对我有用,但您可以从指示器设置自定义所有这些设置。我发现这个策略在3分钟内最有效 注:BB %B是为stDev-1计算的。这将帮助您更快地看到变化。

回测测试

img

img

img


/*backtest
start: 2021-12-01 00:00:00
end: 2022-05-09 23:59:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_CTP","currency":"FUTURES"}]
args: [["ContractType","rb2210",360008]]
*/

//@version=5
indicator(shorttitle="BB-RSI-ADX", title="BB-RSI-ADX Entry Points", overlay=true, timeframe="", timeframe_gaps=true)

// Bollinger Bands Setup
bbLength = input.int(9, minval=1, title="BB 周期", group="BB Settings")
src = input(close, title="数据源", group="BB Settings")
stDev = input.float(2.0, minval=0.001, maxval=50, title="标准差", group="BB Settings")
basis = ta.sma(src, bbLength)
dev = stDev * ta.stdev(src, bbLength)
devMinOne = (stDev > 1 ? stDev - 1 : 1) * ta.stdev(src, bbLength)
upper = basis + dev
lower = basis - dev
upperMinOne = basis + devMinOne
lowerMinOne = basis - devMinOne

plot(basis, "Basis", color=#FF6D00)
p1 = plot(upper, "BB  Upper", color=#2962FF)
p2 = plot(lower, "BB Lower", color=#2962FF)
fill(p1, p2, title = "BB Background", color=color.rgb(33, 150, 243, 95))

// BB width %B
bbr = (src - lowerMinOne)/(upperMinOne - lowerMinOne)

// RSI
rsiLengthInput = input.int(14, minval=1, title="RSI 周期", group="RSI Settings")
rsiSourceInput = input.source(close, "数据源", group="RSI Settings")
rsiUp = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
rsiDown = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
rsi = rsiDown == 0 ? 100 : rsiUp == 0 ? 0 : 100 - (100 / (1 + rsiUp / rsiDown))

// ADX
adxlen = input(14, title="ADX 平滑周期", group="ADX Settings")
dilen = input(14, title="ADX DI 周期", group="ADX Settings")
dirmov(len) =>
	up = ta.change(high)
	down = -ta.change(low)
	plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
	minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
	truerange = ta.rma(ta.tr, len)
	plus = fixnan(100 * ta.rma(plusDM, len) / truerange)
	minus = fixnan(100 * ta.rma(minusDM, len) / truerange)
	[plus, minus]
adx(dilen, adxlen) =>
	[plus, minus] = dirmov(dilen)
	sum = plus + minus
	adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
adxStr = adx(dilen, adxlen)

// Entry condition inputs
c_enter_long_bbr = input(0, title="最小值 BB %B", group="Enter LONG Conditions", tooltip="The Minimum required BB %B required to enter a LONG position. RECOMMENDED: 0")
c_enter_long_rsi_min = input(30, title="最小 RSI", group="Enter LONG Conditions", tooltip="The Minimum RSI value to enter a LONG position. RECOMMENDED: 30", inline="rsi_long")
c_enter_long_rsi_max = input(50, title="最大 RSI", group="Enter LONG Conditions", tooltip="The Maximum RSI value to enter a LONG position. RECOMMENDED: 50", inline="rsi_long")
c_adx_min_str = input(25, title="ADX 最小力度", group="ADX Settings")

c_enter_short_bbr = input(1, title="最大值 BB %B", group="Enter SHORT Conditions", tooltip="The Highest required BB %B required to enter a SHORT position. RECOMMENDED: 1")
c_enter_short_rsi_min = input(50, title="最小 RSI", group="Enter SHORT Conditions", tooltip="The Minimum RSI value to enter a SHORT position. RECOMMENDED: 50", inline="rsi_short")
c_enter_short_rsi_max = input(70, title="最大 RSI", group="Enter SHORT Conditions", tooltip="The Maximum RSI value to enter a SHORT position. RECOMMENDED: 70", inline="rsi_short")

// Enter Long Conditions
enter_long = (low < lower) and (bbr > c_enter_long_bbr) and (rsi > c_enter_long_rsi_min) and (rsi < c_enter_long_rsi_max) and (adxStr > c_adx_min_str)  ? 1 : 0
// Enter Short Conditions
enter_short = (high > upper) and (bbr < c_enter_short_bbr) and (rsi > c_enter_short_rsi_min) and (rsi < c_enter_short_rsi_max) and (adxStr > c_adx_min_str)  ? -1 : 0


//plotarrow(enter_long, maxheight=10)    

//plotarrow(enter_short, maxheight=10)    




if enter_long
    strategy.entry("Enter Long", strategy.long)
else if enter_short
    strategy.entry("Enter Short", strategy.short)
template: strategy.tpl:40:21: executing "strategy.tpl" at <.api.GetStrategyListByName>: wrong number of args for GetStrategyListByName: want 7 got 6