Bollinger Bands strategy with RSI and MACD v1.0
Apr 15, 2021

The Bollinger Bands strategy with RSI and MACD v1.0 tool is a comprehensive automated trading system that combines mean-reversion Bollinger Bands logic with momentum and trend filters for high-probability trade execution.
Usage
The strategy identifies long opportunities when the price crosses above the lower Bollinger Band and short opportunities when it crosses below the upper Bollinger Band. To refine entries, users can toggle RSI and MACD filters:
- Mean Reversion: Basic entries trigger when price rejects the outer bands and moves back toward the mean.
- RSI Filter: If enabled, long trades only trigger when the RSI is below a specified oversold level, and short trades trigger when above an overbought level.
- MACD Filter: Users can filter trades based on MACD zero-crosses or a custom "MACD variation" logic that looks for specific histogram momentum trends over the last three candles.
- Position Management: The strategy features a multi-stage exit. Half of the position is closed when the price touches the middle band (basis), and the remainder is closed at the opposite band. Users can also enable fixed percentage take-profits and trailing stop-losses.
Details
This script implements a dynamic exit system using arrays to manage multiple simultaneous orders (pyramiding). It tracks individual trade IDs to handle partial closes at the middle band and full closes at the outer bands or fixed TP/SL levels. The "MACD variation" logic provides an alternative to standard crossovers by analyzing the slope of the MACD histogram, allowing the strategy to enter based on fading or increasing momentum rather than just trend direction.
Settings
Bollinger Bands
- BB source: Determines the price data used for Bollinger Band calculations.
- Bollinger Bands SMA length: The lookback period for the middle moving average.
- Bollinger Bands StdDev length: The multiplier for the standard deviation bands.
Risk Management
- Trail Long/Short Loss (%): The percentage distance for the trailing stop-loss.
- Maximum orders: Sets the limit for simultaneous open positions in one direction.
- Position size: The number of units or contracts traded per entry.
RSI & MACD
- Use RSI: Enables the RSI oversold/overbought filter.
- RSI period / Source: Parameters for the RSI calculation.
- RSI value for buy/sell: Thresholds for trade validation.
- Use MACD / Variation: Enables standard MACD zero-cross filters or the 3-candle momentum variation.
- MACD fast/slow/signal length: Standard MACD period settings.
Take Profit
- Use maximum TP long/short: Toggles a fixed percentage take-profit.
- Maximum take profit long/short (%): The percentage distance for the fixed exit.
FAQ
How do I use the MACD variation setting?
The MACD variation setting requires "Use MACD" to be active. It looks for a sequence where the MACD histogram has been decreasing for three candles to signal a sell, or increasing for three candles to signal a buy, rather than waiting for a zero-line cross.
Can I trade with only Bollinger Bands?
Yes, simply disable the "Use RSI" and "Use MACD" checkboxes in the settings menu to use the core mean-reversion logic.
How do I access Bollinger Bands strategy with RSI and MACD v1.0?
You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Trading & investing are risky and many will lose money in connection with trading and investing activities. All content on this site is not intended to, and should not be, construed as financial advice. Decisions to buy, sell, hold or trade in securities, commodities and other investments involve risk and are best made based on the advice of qualified financial professionals. Past performance does not guarantee future results.
Hypothetical or Simulated performance results have certain limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, including, but not limited to, lack of liquidity. Simulated trading programs in general are designed with the benefit of hindsight, and are based on historical information. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.
Testimonials appearing on this website may not be representative of other clients or customers and is not a guarantee of future performance or success.
As a provider of technical analysis tools and strategies, we do not have access to the personal trading accounts or brokerage statements of our customers. As a result, we have no reason to believe our customers perform better or worse than traders as a whole based on any content, tool, or platform feature we provide.
Charts used on this site are by TradingView in which the majority of our technical indicators are built on. TradingView® is a registered trademark of TradingView, Inc. www.TradingView.com TradingView® has no affiliation with the owner, developer, or provider of the Services described herein.
Market data is provided by CBOE, CME Group, BarChart, Massive, CoinAPI. Select U.S. equities data is provided through Massive. CBOE BZX real-time U.S. equities data is licensed from CBOE and provided through BarChart. Real-time futures data is licensed from CME Group and provided through BarChart. Select cryptocurrency data, including major coins, is provided through CoinAPI. All data is provided “as is” and should be verified independently for trading purposes.
This does not represent our full Disclaimer. Please read our full disclaimer.
© 2026 LuxAlgo Global, LLC.

