Moving Average Bollinger Bands RSI Combo Strategy
This strategy combines moving averages, Bollinger Bands and RSI to assess price trends and overbought/oversold levels for trade signals. It harnesses strengths of multiple indicators to improve accuracy. Strategy…
This strategy combines moving averages, Bollinger Bands and RSI to assess price trends and overbought/oversold levels for trade signals. It harnesses strengths of multiple indicators to improve accuracy.
Strategy Logic:
Calculate moving average and Bollinger Bands to determine price trend.
Calculate RSI to identify overbought/oversold levels.
Enter long when price breaks above BB lower band and RSI bullish crossover. Vice versa for short.
Use stop loss to control loss per trade.
Advantages:
Multi-indicator verification reduces bad trades.
RSI complements limitations of MAs.
BB identifies breakout levels.
Risks:
Time-consuming to optimize multiple parameters.
Some redundancy between RSI and BBs.
Breakouts prone to failures and reversals.
In summary, this strategy combines MAs, BBs and RSI to identify both trend and reversal trade opportunities. Using multiple indicators can improve results but requires parameter optimization and risk control.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1_close | 0 | Price source: close | high | low | open | hl2 | hlc3 | hlcc4 | ohlc4 |
| v_input_2 | 6 | (?RSI)RSI Length |
| v_input_3 | 50 | RSI Overbough |
| v_input_4 | 50 | RSI Oversold |
| v_input_5 | 50 | RSI Neutral |
| v_input_6 | 200 | (?MABB)MA Length |
| v_input_7 | 200 | BB Length |
| v_input_8 | 2 | BB multiplier |
| v_input_9 | 0 | MA type: SMA | EMA | HMA |
Source Pine Script
/*backtest
start: 2023-08-13 00:00:00
end: 2023-09-12 00:00:00
period: 30m
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/
// © LucasVivien
//@version=4
strategy("MA Bolinger Bands + RSI ", shorttitle="MABB + RSI", overlay=true)
// User input
source = input(title="Price source" , type=input.source , defval=close)
RSIlen = input(title="RSI Length" , type=input.integer , defval=6 , group="RSI")
RSIlvlOB = input(title="RSI Overbough" , type=input.integer , defval=50 , group="RSI")
RSIlvlOS = input(title="RSI Oversold" , type=input.integer , defval=50 , group="RSI")
RSIN = input(title="RSI Neutral" , type=input.integer , defval=50 , group="RSI")
MAlen = input(title="MA Length" , type=input.integer , defval=200 , group="MABB")
BBlen = input(title="BB Length" , type=input.integer , defval=200 , group="MABB")
BBmult = input(title="BB multiplier" , type=input.float , defval=2.0 , group="MABB" , tooltip="Set BB closer / appart", minval=0.001, maxval=50)
MAtype = input(title="MA type" , type=input.string , defval="SMA", group="MABB" , tooltip="MA type used in BB", options=["SMA", "EMA", "HMA"])
//SLmult = input(title="SL value" ,type=input.float , defval=0.06)
// Used indicators
RSI = rsi(source, RSIlen)
MA = sma(source, MAlen)
if MAtype == "EMA"
MA := ema(source, MAlen)
if MAtype == "HMA"
MA := hma(source, MAlen)
// Perform Calculations
BBdev = BBmult * stdev(source, BBlen)
BBupper = MA + BBdev
BBlower = MA - BBdev
longSL = close - close * 0.06
shortSL = close + close * 0.06
// Signals validation ([0] is trade displayed from strategy() on chart => long/short entry)
BBbull = (open < BBlower) and (close > BBlower)
BBbear = (open > BBupper) and (close < BBupper)
RSIbull = crossover(RSI , RSIN)
RSIbear = crossunder(RSI, RSIN)
Longsignal = (BBbull) and (RSIbull or RSIbull[1] or
RSIbull[2] or RSIbull[3] or RSIbull[4] or
RSIbull[5] or RSIbull[6] or RSIbull[7] or
RSIbull[8] or RSIbull[9] or RSIbull[10])
Shortsignal = (BBbear) and (RSIbear or RSIbear[1] or
RSIbear[2] or RSIbear[3] or RSIbear[4] or
RSIbear[5] or RSIbear[6] or RSIbear[7] or
RSIbear[8] or RSIbear[9] or RSIbear[10])
// Save SL values
var SLlongsaved = 0.0
var SLshortsaved = 0.0
if Longsignal and (strategy.position_size == -1) ///////////////////////////////
SLlongsaved := longSL
if Shortsignal and (strategy.position_size == 1) ////////////////////////////////
SLshortsaved := shortSL
// Plots
//plotshape(Longsignal , size=size.small, color=color.teal)
//plotshape(Shortsignal, size=size.small, color=color.fuchsia)
plot(Longsignal ? longSL : na, color=color.red, style=plot.style_linebr, linewidth=6)
plot(Shortsignal ? shortSL : na, color=color.red, style=plot.style_linebr, linewidth=6)
p1 = plot(BBupper,title="Bollinger Bands Upper Line", color=color.gray, transp=60)
p2 = plot(BBlower,title="Bollinger Bands Lower Line", color=color.gray, transp=60)
plot(MA, title="Bollinger Bands MA Basis Line" , color=color.white, transp=50)
fill(p1, p2, color=color.white, transp=92)
// Strategy Entry & Exit
//if Longsignal
strategy.entry(id="Long entry", long=true, when=Longsignal) //, oca_name="x", oca_type=strategy.oca.cancel)
//if Shortsignal
strategy.entry(id="Short entry", long=false, when=Shortsignal) //, oca_name="x", oca_type=strategy.oca.cancel)
strategy.close(id="Long exit", when=strategy.position_size > 0)//, from_entry="Long entry" //, when=strategy.position_size > 0 // , stop=SLlongsaved)
strategy.close(id="Short Exit", when=strategy.position_size < 0)//, from_entry="Short entry" //, when=strategy.position_size < 0 //, stop=SLshortsaved)
plot(strategy.position_size) //////////////////////////////////////////////
Published by ChaoZhang on the FMZ strategy square · last modified 2023-09-13. 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/Moving-Average-Bollinger-Bands-RSI-Combo-Strategy.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
- EMA and Bollinger Bands Breakout StrategyPine Script · Breakout · 1h
- Momentum Breakout Moving Average StrategyPine Script · Breakout · 1d
- Momentum Breakout Trading Strategy 440964Pine Script · Breakout · 5m
- Momentum Breakthrough TTM StrategyPine Script · Breakout · 1d
- Moving Average Crossover and Upper Rail Breakthrough Impulse StrategyPine Script · Breakout · 1m
- Quadruple Crossing StrategyPine Script · Breakout · 1h