Skip to content

Latest commit

 

History

History
216 lines (119 loc) · 11.9 KB

基于布林带和RSI的交易策略A-Bollinger-Band-and-Trend-Tracking-Strategy-Based-on-RSI.md

File metadata and controls

216 lines (119 loc) · 11.9 KB

Name

基于布林带和RSI的交易策略A-Bollinger-Band-and-Trend-Tracking-Strategy-Based-on-RSI

Author

ChaoZhang

Strategy Description

IMG [trans]

本策略综合利用布林带和RSI指标识别趋势方向变化的关键点,在趋势发生转折时建立头寸,随后利用趋势力量获利退出。

概述

本策略首先通过布林带上下轨来判断价格震荡的范围和方向,结合RSI指标判定多空关键点,在震荡区间震荡加剧时建立反向头寸。例如当RSI从超买/超卖区域返回并在下轨附近出现金叉时建立看涨头寸,或者当RSI从超卖区域返回并在上轨附近出现死叉时建立看跌头寸。之后利用布林带上下轨这两个动态止损位来跟踪止损和止盈。

策略原理

本策略主要利用布林带指标和RSI指标的组合来识别价格趋势的关键转折点。

布林带是根据股价的波动范围来计算上下轨的技术指标。布林带通过计算股价的标准差,得到股价波动的幅度,并据此画出股价的上下限。上轨就是股价波动的上限,下轨就是波动的下限。当股价接近上轨时,说明股价正在牛市中波动上涨,这时要警惕股价可能下跌;当股价接近下轨时,说明股价下跌加速,这时要警惕反弹机会。

RSI指标是通过计算一段时间内股价涨跌力度的强弱来判断股价趋势和超买超卖的技术指标。RSI通过比较一段时间内的平均收盘涨幅和平均收盘跌幅,测量股价正在上涨或下跌的动量。当RSI大于70时为超买,小于30时为超卖。股票价格可能反转。

本策略的交易决策是结合布林带上下轨和RSI指标的信号。当RSI从超买区下跌进入中性区,并且股价下破布林带下轨时,就表明股价的上涨趋势被打破,这时看跌的机会出现。我们可以建立看跌头寸。反之,当RSI从超卖区上升进入中性区,并且股价上破布林带上轨时,就表明股价的下跌趋势被打破,这时看涨的机会出现。我们可以建立看涨头寸。

在建立头寸后,我们会利用布林带上轨和下轨作为止损位和止盈位。当股价反转重新突破这两个关键位时,我们就及时止损或止盈。

策略优势

本策略最大的优势在于利用布林带和RSI这两个指标互为验证,识别股价关键的转折点。单独利用布林带指标,很容易产生错误信号。但结合RSI指标的超买超卖区域判断,可以有效避免错误操作。另一个优势是利用布林带上下轨作为动态的止盈止损位,这比预先设定固定止盈止损位更加灵活和合理。

策略风险

本策略风险主要体现在两个方面:

  1. 布林带参数设置不当。如果布林带参数设置得过大或过小,那么识别震荡加剧的效果就会大打折扣。

  2. 指标发出假信号。本策略主要依赖布林带指标结合RSI指标识别关键点,但在个别情况下还是可能出现指标发出的信号是错误的。这时如果盲目跟单就可能造成损失。

针对以上风险,我们可以从以下几个方面进行优化:

  1. 测试不同市场不同周期参数下布林带参数的最优值,设定合理的参数。

  2. 增加其他指标作为验证信号,避免单一指标判断错误。例如可以加入KD指标等。

  3. 增加人工经验规则,根据具体行情选择是否入场。

策略优化方向

本策略还可从以下几个方面进行优化:

  1. 测试优化布林带参数,寻找更加适合该品种的最优参数。

  2. 增加止损止盈策略,可以设置追踪止损或移动止盈来锁定更大利润。

  3. 结合更多指标和形态作为入场信号验证,例如量价指标、基本面因素等,提高操作的准确性。

  4. 根据不同品种和市场的特点,设定参数集优化组合,形成多种参数组合的策略仓库。

总结

本策略综合运用布林带指标和RSI指标,在两个指标互相验证的基础上识别价格可能反转的关键点。它在判断行情关键点时比较可靠,通过动态跟踪布林带上下轨进行止盈止损也较为合理。但本策略也存在一定风险,需要增加其他辅助工具来优化和验证操作策略,在实盘中还需结合人工经验进行调整。总体来说,本策略为一种典型的量化交易策略。

||

This strategy combines Bollinger Band and RSI indicators to identify key turning points in price trends. It establishes positions when trends reverse and then exits profitably by following the trend momentum.

Overview

This strategy first uses the upper and lower bands of Bollinger Bands to determine the price oscillation range and direction. It then uses the RSI indicator to identify long and short opportunities. For example, when the RSI exits the overbought/oversold area and a golden cross appears near the lower band, it will establish a long position. Or when the RSI exits the overbought area and a death cross appears near the upper band, it will establish a short position. It then uses the dynamic stops of the Bollinger Bands for tracking stops and profit targets.

Strategy Logic

This strategy mainly utilizes the combination of Bollinger Band and RSI indicators to identify key reversals in price trends.

The Bollinger Band is a technical indicator that calculates the upper and lower bands based on the volatility range of prices. By calculating the standard deviation of prices, it determines the amplitude of price fluctuations and plots the upper and lower limits accordingly. The upper band represents the upper limit of price swings while the lower band represents the lower limit. When prices approach the upper band, it indicates that prices are oscillating upwards in a bull market, so a potential drop should be cautious about. When prices approach the lower band, it indicates accelerated drops, so potential bounces should be cautious about.

The RSI is a technical indicator that judges price trends and overbought/oversold conditions by calculating the strength of price rises and falls over a period of time. By comparing the average closing gains and average closing losses over a period of time, RSI measures the momentum of the ongoing price rises or drops. Above 70 RSI indicates overbought conditions while below 30 indicates oversold conditions, which implies potential price reversals.

The trading signals of this strategy come from the combination of Bollinger Bands and RSI signals. When the RSI drops from the overbought zone to the neutral zone while prices break below the lower band of Bollinger Bands, it indicates the upside price trend is breaking down and shorting opportunities emerge. We can establish short positions. On the contrary, when the RSI rises from the oversold zone to the neutral zone while prices break above the upper band, it indicates the downside price trend is breaking up and long opportunities emerge. We can establish long positions.

After establishing positions, the upper and lower bands of Bollinger Bands will be used as dynamic stops for managing risks and profit targets. When prices reverse and break through those key levels again, we close positions in a timely manner.

Advantages

The biggest advantage of this strategy is using Bollinger Bands and RSI indicators to verify each other when identifying key turning points of prices. Using Bollinger Bands alone can easily generate false signals. But by combining the overbought/oversold zones of RSI, false operations can be effectively avoided. Another advantage is using the dynamic upper and lower bands of Bollinger Bands as profit and loss stops, which is more flexible and reasonable than presetting fixed profit and loss stops.

Risks

The main risks of this strategy are reflected in two aspects:

  1. Improper parameter settings of Bollinger Bands. If the parameters of Bollinger Bands are set too large or too small, the effect of identifying increased oscillations will be greatly reduced.

  2. False signals from indicators. This strategy mainly relies on Bollinger Bands combined with RSI indicators to identify key points. In some individual cases, the signals emitted may still be wrong. Blindly following them at that time can lead to losses.

To address the above risks, optimization can be done in the following aspects:

  1. Test the optimal values of Bollinger Band parameters under different markets and cycle periods to set reasonable parameters.

  2. Add other indicators to verify signals and avoid false judgments from single indicators. Indicators like KD can be added.

  3. Add manual empirical rules to determine whether to participate based on specific market conditions.

Optimization

The strategy can be further optimized in the following aspects:

  1. Test and optimize Bollinger Band parameters to find the optimal parameters suitable for the underlying.

  2. Add stop loss and take profit strategies. Trailing stops or moving profit targets can be used to lock in bigger profits.

  3. Combine more indicators and patterns for verifying entry signals to improve accuracy. Examples include volume price indicators, fundamental factors etc.

  4. Set up parameter optimization combinations according to the characteristics of different products and markets to build a strategy pool with multiple parameter combinations.

Conclusion

This strategy combines Bollinger Band and RSI indicators to identify key potential reversal points when the two indicators verify each other. It is relatively reliable in capturing key market points. The dynamic bands for stop loss and take profit are also reasonable. But there are still risks in this strategy, so other tools are needed to optimize and verify the operational strategy. Manual interference based on trading experience is also needed during live trading. In general, this is a typical quantitative trading strategy.

[/trans]

Strategy Arguments

Argument Default Description
v_input_1 6 RSI Period Length
v_input_int_1 200 Bollinger Period Length

Source (PineScript)

/*backtest
start: 2024-01-28 00:00:00
end: 2024-02-04 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("TradeOptix 2.0", shorttitle="TradeOptix 2.0", overlay=true)


///////////// RSI
RSIlength = input(6, title='RSI Period Length')
RSIoverSold = 50
RSIoverBought = 50
price = close
vrsi = ta.rsi(price, RSIlength)


///////////// Bollinger Bands
BBlength = input.int(200, minval=1, title='Bollinger Period Length')
BBmult = 2  // input(2.0, minval=0.001, maxval=50,title="Bollinger Bands Standard Deviation")
BBbasis = ta.sma(price, BBlength)
BBdev = BBmult * ta.stdev(price, BBlength)
BBupper = BBbasis + BBdev
BBlower = BBbasis - BBdev
source = close
buyEntry = ta.crossover(source, BBlower)
sellEntry = ta.crossunder(source, BBupper)
plot(BBbasis, color=color.new(color.aqua, 0), title='Bollinger Bands SMA Basis Line')
p1 = plot(BBupper, color=color.new(#7787b9, 0), title='Bollinger Bands Upper Line')
p2 = plot(BBlower, color=color.new(#7787b9, 0), title='Bollinger Bands Lower Line')
fill(p1, p2, color = color.rgb(40, 226, 255, 90))





///////////// RSI + Bollinger Bands Strategy
long = ta.crossover(vrsi, RSIoverSold) and ta.crossover(source, BBlower)
close_long = ta.crossunder(vrsi, RSIoverBought) and ta.crossunder(source, BBupper)

if not na(vrsi)

    if long
        strategy.entry('Long', strategy.long, stop=BBlower, alert_message = "Exit")
        alert("Enter Calls")
    else
        strategy.cancel(id='Long')
        alert("Exit Calls")

    if close_long
        strategy.close('Long',alert_message = "Exit")
        alert("Exit Calls")


plotshape(long, title='UpTrend Begins', location=location.belowbar, style=shape.flag, size=size.tiny, color=color.new(color.green, 0))
plotshape(close_long, title='DownTrend Begins', location=location.abovebar, style=shape.flag, size=size.tiny, color=color.new(color.red, 0))


Detail

https://www.fmz.com/strategy/441056

Last Modified

2024-02-05 11:02:51