NEWCard payments are live · from $18/month, USDT also acceptedSee plans
COINPRED / STRATEGY LIBRARY

BTC Bollinger + RSI: Long if a bar opens below the lower band and closes back in, after RSI crosses up through 50; skip extreme volatility. ATR-trail exit; shorts are symmetric

LucasVivien's open-source mean-reversion script (MPL 2.0), titled MA Bollinger Bands + RSI (Strategy). A long needs a bar that opens below the lower band and closes back inside it, plus an RSI cross up through 50 in the recent lookback. Extreme band width is filtered out by default. Fixed stops and targets are off; the default exit is an ATR trail. Longs and shorts are both on. The author's chart is BINANCE:BTCUSDT, 15-minute. Rules follow the source; this page invents no backtest figures.

Illustrated guidesPine Script®Included with monthly & annual plans
← All strategies
LucasVivien · 14.0 · 2026-12-05 · Mean reversion
BTC Bollinger + RSI: Long if a bar opens below the lower band and closes back in, after RSI crosses up through 50; skip extreme volatility. ATR-trail exit; shorts are symmetric

The idea

This is LucasVivien's open-source strategy, published as MA Bollinger Bands + RSI (Strategy) (short title MABB+RSI (Strat)). Besides the MPL 2.0 header and © LucasVivien, the source credits ChartArt, Matthew J. Slabosz, and Zen & The Art of Trading. It is closer to mean reversion than to a breakout chase: it waits for price to travel outside the lower band and then close back inside it, with RSI having recently crossed up through its midline, before treating that as a long. Shorts are the mirror image, using the upper band and an RSI cross down through the midline.

Both longs and shorts are enabled by default. A volatility filter is also on: signals are dropped when Bollinger width is extremely wide or extremely narrow versus its own long baseline. Date and session filters are off by default. On the exit side, fixed take-profit and fixed stop-loss are both off; the script uses an ATR trailing stop, and the default multiplier of 9 keeps that trail relatively far from entry. The author's chart is BINANCE:BTCUSDT, 15-minute. Entries also require barstate.isconfirmed, so the signal is only valid once the bar is confirmed.

Author chart of LucasVivien MA Bollinger Bands + RSI Strategy on BINANCE:BTCUSDT 15-minute
Author chart: BINANCE:BTCUSDT, 15-minute, from the script's publication page. The image shows the average, Bollinger bands, and trade marks; it is only a visual example, not a live or backtest track record. / 作者展示:BINANCE:BTCUSDT,15 分钟图,取自作者发布页主图。

How the lines are built

  • The mid-line defaults to a 200-period simple average of close. It can be switched to EMA, WMA, VWMA, or HMA; the length is set by MA Length.
  • The bands are not a standard deviation around that mid-line. Width is BBdev = ta.stdev(close, BBlen) * BBX, with default length 200 and multiplier 2, then upper = mid-line + BBdev and lower = mid-line - BBdev. MA Length and BB Length are separate inputs; both happen to default to 200.
  • The long band condition, BBbull, is open below the lower band and close back above it. The short condition, BBbear, is the mirror: open above the upper band and close back below it.
  • RSI uses close and defaults to length 6. The midline defaults to 50. RSIbull is true if, looking back the default 10 bars, RSI has crossed up through 50; RSIbear is true if it has crossed down through 50 in that window.
  • Band width is upper minus lower. A signal line is a 50-period average of that width, and a baseline is a 2000-period average. Extreme high or low volatility is width moving beyond the baseline by Volatility Factor / 10. Both filters are on by default.

Entry rules

  • Longs and shorts are both on by default; either side can be switched off.
  • A long needs BBbull, RSIbull, no extreme-high and no extreme-low volatility, a pass on the date and session filters (off by default), and barstate.isconfirmed. It also has to be a new direction: the previous bar was not already a valid long, or the position just went flat and re-entry after a stop or target is allowed (that switch is on by default), and it must not be the same bar that just hit the stop or target.
  • Shorts are symmetric: BBbear and RSIbear, with the same volatility and re-entry rules.
  • When those conditions hold, the script calls strategy.entry('Long') or strategy.entry('Short'). calc_on_order_fills=true, so the script recalculates after a fill.

Exits and position size

  • A trailing stop is on by default. For a long, it starts at the lowest low of the last TSLlookback bars (default 2), minus ATR times ATR Mult (ATR length 14, multiplier 9 by default), and then only ratchets up. A short starts from the recent high plus the ATR band and only ratchets down.
  • Fixed stops and fixed targets are off by default. If you turn them on, the stop distance is ATR times ATR Mult, and the target is that distance times Risk:Reward (default 1).
  • In the default strategy.exit, the long stop is the trailing price TSLsaved and the limit is empty, so no fixed target is placed. A valid opposite signal can also flip the position by entering the other side.
  • Orders default to a cash size of 10000, with initial_capital also 10000 and commission 0.1%. The source does not set slippage.

Inputs (defaults in the source)

InputDefaultWhat it does
Long trades / Short tradestrue / trueWhether longs and shorts are allowed.
Use Take ProfitfalseEnables a fixed take-profit. Off by default.
Use Stop LossfalseEnables a fixed stop. Off by default.
Use Trailing StoptrueEnables the ATR trailing stop. On by default.
Re-Entry after SL/TPtrueAllows another entry in the same direction after a stop or target.
Trailing lookback2How many bars of highs or lows seed the trailing stop.
ATR Mult / ATR Length9.0 / 14ATR multiplier and length. A default of 9 keeps the trail fairly far away.
Risk:Reward1If a fixed target is on, its distance is the stop distance times this value.
High Volatility / Low Volatilitytrue / trueFilters extreme-high and extreme-low band width. Both on by default.
Volatility Factor5.0How wide the extreme-volatility bands are; lower values filter more.
MA Type / MA LengthSMA / 200Type and length of the mid-line average.
BB Mult / BB Length2.0 / 200Standard-deviation multiplier and length for the bands.
RSI Cross Lookback10How many bars back to look for an RSI cross of the midline.
RSI Neutral / RSI Length50 / 6Midline and RSI length.
Enable Date Filter / Session Filterfalse / falseDate and session filters are off by default.
Trading Session1000-2200:1234567Session used if the session filter is turned on.

Caveats

  • This is a reversion idea, not an upper-band breakout chase. A long first has to fall outside the lower band and then close back inside it.
  • RSI does not have to have been oversold first; a cross up through 50 in the last 10 bars is enough. That is looser than requiring RSI to be above 50 now.
  • Both extreme-high and extreme-low volatility filters are on by default, so very tight ranges and sudden expansions can suppress signals.
  • The default ATR multiplier on the trail is 9, which sits well away from entry, and the fixed target is off, so a losing trade may wait for that trail.
  • The date filter's start and end default to 2022 and 2023, but the switch is off, so that window is not applied unless you turn it on.
  • The first header line reads “This close code is subject to...”, but it still declares MPL 2.0 and © LucasVivien. Coinpred ships the unmodified source.
  • The author's chart is 15-minute. The same 200-period bands and 6-period RSI will behave very differently on daily or 1-minute charts.

Install it on TradingView

  1. Download the .pine file from Coinpred (a current membership is required; see the page) or check the original publication for a newer revision.
  2. Open the symbol and timeframe you want in TradingView, open the Pine Editor, paste the source, and add it to the chart.
  3. Start with the default 200-period average and bands, 6-period RSI, and trailing-stop-only exits so you can see the lower-band recovery and the RSI cross, then change lengths, multipliers, or switches.
  4. The source sizes orders at 10000 in cash, sets initial capital to 10000, commission to 0.1%, and turns on calc_on_order_fills. Live order routing has to be set separately.
  5. Crypto trades around the clock. The tester's timezone and session settings may differ from your venue by several hours.

About backtest figures

Source, license, and version

  • Source: https://www.tradingview.com/script/2MMNHl97-MA-Bollinger-Bands-RSI/
  • Author: LucasVivien (header © LucasVivien; also credits ChartArt, Matthew J. Slabosz, and Zen & The Art of Trading)
  • License: Mozilla Public License 2.0. Redistribution must keep the original copyright and license notices; if you modify the source file, the modified file must remain under MPL 2.0. Coinpred ships the unmodified source.
  • Version: 14.0 in the publication record and pine-facade. scriptAccess is open_no_auth.

Source, license and version

Licensed under MPL 2.0 per the source header, © LucasVivien. Redistribution must keep the copyright and license notices; modified files must remain under MPL 2.0. Coinpred ships the unmodified source.

View original source ↗

Check the script license and your TradingView account features. Historical results do not guarantee future performance.

More strategies

All strategies →