Strategy vault / Mean reversion
Short Term Trading Strategy Based on Bollinger Bands Moving Average and RSI
This strategy aims to capture short-term price movements by utilizing a combination of Bollinger Bands (BB), Moving Average (MA), and Relative Strength Index (RSI) for long trading. The strategy enters long positions…

Overview
This strategy aims to capture short-term price movements by utilizing a combination of Bollinger Bands (BB), Moving Average (MA), and Relative Strength Index (RSI) for long trading. The strategy enters long positions when the price is above the upper band and moving average, and the RSI indicates an oversold condition. It manages risk and locks in profits through percentage-based stop loss and take profit levels, and adjusts entry prices based on the trader's Bybit account level to account for commissions.
Strategy Principles
The strategy is based on the following principles:
- Bollinger Bands: When the price breaks above the upper band, it suggests a potential uptrend in the market.
- Moving Average: A price above the moving average indicates a current uptrend.
- Relative Strength Index: When the RSI is below the oversold threshold, it suggests a potential market reversal and price increase.
By combining these three indicators, the strategy identifies potential long entry opportunities when the price breaks above the upper Bollinger Band, is above the moving average, and the RSI is in the oversold region. It also sets stop loss and take profit prices to control risk and lock in profits.
Strategy Advantages
- Multiple indicators: The strategy considers Bollinger Bands, Moving Average, and RSI, providing a more comprehensive market analysis.
- Trend following: By using Bollinger Bands and Moving Average, the strategy can identify the current market trend.
- Oversold signals: The RSI indicator helps identify potential oversold conditions and catch potential reversal opportunities.
- Risk management: The strategy incorporates percentage-based stop loss and take profit levels to control risk and lock in profits.
- Commission consideration: It adjusts entry prices based on the trader's Bybit account level to account for commissions.
Strategy Risks
- False signals: Any technical indicator can generate false signals, leading to unnecessary trades.
- Market volatility: The market may experience severe short-term fluctuations, triggering stop losses or missing potential profits.
- Trend reversal: The strategy assumes the current trend will continue, but trends can suddenly reverse, resulting in losses.
- Commission impact: Although the strategy accounts for commissions, frequent trading can still increase commission costs, affecting overall profitability.
Strategy Optimization Directions
- Parameter optimization: Optimize the parameters for Bollinger Bands, Moving Average, and RSI to adapt to different market conditions.
- Long and short combination: Consider adding short trading conditions to fully utilize different market opportunities.
- Dynamic stop loss and take profit: Adjust stop loss and take profit levels dynamically based on market volatility to better control risk and lock in profits.
- Combining other indicators: Introduce other technical indicators, such as MACD, ATR, etc., to enhance the strategy's reliability.
- Money management: Optimize money management methods, such as adjusting position sizes based on risk, to improve risk-adjusted returns.
Summary
This strategy utilizes a combination of Bollinger Bands, Moving Average, and RSI to identify short-term long trading opportunities. It determines trends using Bollinger Bands and Moving Average, identifies oversold conditions with RSI, and sets stop loss and take profit levels to manage risk. The strategy considers commission impact and adjusts based on the trader's Bybit account level. While the strategy has certain advantages, it still faces risks such as false signals, market volatility, and trend reversals. Future optimizations can include parameter optimization, combining long and short positions, dynamic stop loss and take profit, incorporating other indicators, and optimizing money management to improve the strategy's performance and adaptability.
Source Pine Script
/*backtest
start: 2023-05-08 00:00:00
end: 2024-05-13 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@BryanAaron
//@version=5
strategy("Bybit . BB Short-Term Trading Strategy - Long Only", overlay=true)
// Input parameters
bbLength = input(45, title="BB Length")
bbMultiplier = input(1.0, title="BB Multiplier")
maLength = input(90, title="MA Length")
rsiLength = input(5, title="RSI Length")
rsiUpperThreshold = input(85, title="RSI Upper Threshold")
rsiLowerThreshold = input(45, title="RSI Lower Threshold")
slPerc = input(2.0, title="Stop Loss %")
tpPerc = input(4.0, title="Take Profit %")
bybitAccountLevel = input.string("VIP 0", title="Bybit Account Level", options=["VIP 0", "VIP 1", "VIP 2", "VIP 3", "VIP 4"])
// Calculate Bollinger Bands
[bbMiddle, bbUpper, bbLower] = ta.bb(close, bbLength, bbMultiplier)
// Calculate moving average
ma = ta.sma(close, maLength)
// Calculate RSI
rsi = ta.rsi(close, rsiLength)
// Trading conditions
longCondition = close > bbUpper and close > ma and rsi < rsiLowerThreshold
shortCondition = close < bbLower and close < ma and rsi > rsiUpperThreshold
// Entry and exit signals
var bool longEntry = false
var bool shortEntry = false
if (longCondition and not longEntry)
longEntry := true
shortEntry := false
else if (shortCondition and not shortEntry)
shortEntry := true
longEntry := false
else if (not longCondition and not shortCondition)
longEntry := false
shortEntry := false
// Set commission based on Bybit account level
commissionPerc = switch bybitAccountLevel
"VIP 0" => 0.075
"VIP 1" => 0.065
"VIP 2" => 0.055
"VIP 3" => 0.045
"VIP 4" => 0.035
=> 0.075
// Adjust entry prices based on commission
longEntryPrice = close * (1 + commissionPerc / 100)
shortEntryPrice = close * (1 - commissionPerc / 100)
// Calculate stop loss and take profit prices
longStopPrice = longEntryPrice * (1 - slPerc / 100)
longProfitPrice = longEntryPrice * (1 + tpPerc / 100)
shortStopPrice = shortEntryPrice * (1 + slPerc / 100)
shortProfitPrice = shortEntryPrice * (1 - tpPerc / 100)
// Plot signals
plotshape(longEntry, title="Long Entry", location=location.belowbar, style=shape.triangleup, size=size.small, color=color.green)
plotshape(shortEntry, title="Short Entry", location=location.abovebar, style=shape.triangledown, size=size.small, color=color.red)
// Entry and exit
if (longEntry)
strategy.entry("Long", strategy.long, limit=longEntryPrice, stop=longStopPrice, comment="Long Entry")
strategy.exit("Long TP/SL", from_entry="Long", limit=longProfitPrice, stop=longStopPrice, comment="Long Exit")
else if (shortEntry)
strategy.entry("Short", strategy.short, limit=shortEntryPrice, stop=shortStopPrice, comment="Short Entry")
strategy.exit("Short TP/SL", from_entry="Short", limit=shortProfitPrice, stop=shortStopPrice, comment="Short Exit")
else
strategy.close_all(comment="Close All")
// Plot Bollinger Bands
plot(bbUpper, color=color.blue, title="BB Upper")
plot(bbMiddle, color=color.orange, title="BB Middle")
plot(bbLower, color=color.blue, title="BB Lower")
// Plot moving average
plot(ma, color=color.purple, title="MA")Published by ChaoZhang on the FMZ strategy square · last modified 2024-05-14. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Short-Term-Trading-Strategy-Based-on-Bollinger-Bands-Moving-Average-and-RSI.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- Advanced 15 Minute Chart Trading Signal StrategyPine Script · Mean reversion · 3h
- Advanced Quantitative Trading Strategy Combining RSI Divergence and Moving AveragesPine Script · Mean reversion · 1h
- Bollinger Bands Stochastic RSI Extreme Strategy BBSR Extreme StrategyPine Script · Mean reversion · 1h
- Dual Moving Average RSI Synergy Options Quantitative Trading StrategyPine Script · Mean reversion · 1h
- Gods Bollinger Bands RSI Trading StrategyPine Script · Mean reversion · 1d
- Multi Indicator Reversal Point Capture Trading StrategyPine Script · Mean reversion · 1d