All English language content
This strategy identifies trading signals by using the RSI indicator to determine overbought/oversold conditions and combining with the Bollinger Bands indicator to depict price oscillation range. It generates buy and sell signals when the RSI shows overbought or oversold levels, while price is approaching or touching the Bollinger Bands upper or lower bands. The strategy synthesizes trend analysis and oscillation judgment to dynamically seek opportunities.
The strategy is based primarily on two indicators:
It calculates the RSI for a certain period and determines whether it enters overbought or oversold zones according to preset parameters, like overbought threshold at 40 and oversold threshold at 45.
It calculates the Bollinger Bands for a period and uses the upper and lower bands to form a price channel, describing the range of price oscillations.
Based on the above, the trading rules are:
When RSI crosses above 45 into oversold zone, and price crosses above Bollinger lower band, generate buy signal. When RSI crosses below 40 into overbought zone, and price crosses below Bollinger upper band, generate sell signal.
The advantages of combining RSI and Bollinger Bands include:
RSI identifies overbought/oversold levels, Bollinger Bands determine price trend direction, complementing each other.
Bollinger Bands can serve as stop loss levels for risk control.
Simple parameters make it easy to implement and backtest.
RSI parameters can be optimized to determine the best overbought/oversold range.
Different price inputs can be used to adapt to various market environments.
There are also some risks with this strategy:
Excessive Bollinger Bands width leading to bad stop loss expectancy.
Improper RSI parameter setting causing incorrect overbought/oversold level judgment.
Unable to accurately determine trend reversal points, risk of missing signals.
Unable to effectively control losses, risk of stop loss being hit by significant price swings.
Some ways to optimize the strategy:
Optimize RSI parameters to determine the ideal overbought/oversold range.
Optimize Bollinger Bands width parameter to control stop loss range.
Add other indicators to identify trend reversals and avoid missing signals.
Apply machine learning models to determine trading timing.
Use different parameter sets based on varying market environments.
Add dynamic stop loss mechanisms.
Develop programs for automatic parameter optimization.
In summary, by combining RSI and Bollinger Bands, this strategy forms relatively solid trading decisions. The logic is simple and clear, good for risk control, but has room for optimization. Further enhancing the strategy through parameter optimization, stop loss optimization, algorithm incorporation etc. can make it more adaptable to complex market environments. The strategy provides ideas for building trading systems and is worth further research and application.
/*backtest start: 2023-08-18 00:00:00 end: 2023-09-17 00:00:00 period: 2h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Mdemoio //@version=4 strategy("Madri", shorttitle="Madri", overlay=true) // Version 1.1 ///////////// RSI RSIlength = input(2,title="A") RSIoverSold = 45 RSIoverBought = 40 price = close vrsi = rsi(price, RSIlength) ///////////// Bollinger Bands BBlength = input(150, minval=1,title="B") BBmult = 2// input(2.0, minval=0.001, maxval=50,title="Bollinger Bands Standard Deviation") BBbasis = sma(price, BBlength) BBdev = BBmult * stdev(price, BBlength) BBupper = BBbasis + BBdev BBlower = BBbasis - BBdev source = close buyEntry = crossover(source, BBlower) sellEntry = crossunder(source, BBupper) ///////////// Colors //switch1=input(true, title="Enable Bar Color?") //switch2=input(true, title="Enable Background Color?") //TrendColor = RSIoverBought and (price[1] > BBupper and price < BBupper) and BBbasis < BBbasis[1] ? red : RSIoverSold and (price[1] < BBlower and price > BBlower) and BBbasis > BBbasis[1] ? green : na //barcolor(switch1?TrendColor:na) //bgcolor(switch2?TrendColor:na,transp=50) ///////////// RSI + Bollinger Bands Strategy if (not na(vrsi)) if (crossover(vrsi, RSIoverSold) and crossover(source, BBlower)) strategy.entry("RSI_BB_L", strategy.long, stop=BBlower, comment="Buy") else strategy.cancel(id="RSI_BB_L") if (crossunder(vrsi, RSIoverBought) and crossunder(source, BBupper)) strategy.entry("RSI_BB_S", strategy.short, stop=BBupper, comment="Sell") else strategy.cancel(id="RSI_BB_S") //plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)