OPEN-SOURCE SCRIPT
BB Crosses Optimized - [JTCAPITAL]

BB Crosses Optimized - [JTCAPITAL] is a modified way to use Bollinger Bands combined with volatility filtering (ATR) and flexible smoothing methods for Trend-Following.
The indicator works by calculating in the following steps:
Buy and Sell Conditions:
-Buy Signal: Triggered when smoothed price closes above the upper Bollinger Band. Trend line then anchors below price (with or without ATR offset depending on settings).
-Sell Signal: Triggered when smoothed price closes below the lower Bollinger Band. Trend line then anchors above price (with or without ATR offset).
Additional filtering is possible via:
-ATR Toggle: Switch ATR on or off to adapt the strategy to either volatile or steady markets.
-Smoothing Method: Adjust smoothing to speed up or slow down responsiveness.
-Deviation Multiplier: Tight or wide bands adjust the sensitivity of signals.
Features and Parameters:
-Source: Choose between Close, Open, High, Low, HL2, etc.
-Average Type: Options include SMA, EMA, HMA, DEMA, TEMA, RMA, FRAMA.
-ATR Period: Defines how ATR volatility is measured.
-BB Period: Lookback length for Bollinger Band construction.
-Deviation: Multiplier for the standard deviation in Bollinger Bands.
-Smoothing Period: Controls how much the source data is smoothed.
-ATR Filter On/Off: Enables or disables ATR integration in signal calculation.
Specifications:
Smoothing (MA Types)
Smoothing is essential to reduce chart noise. By offering multiple MA choices, traders can balance between lag (SMA, RMA) and responsiveness (EMA, HMA, FRAMA). This flexibility allows the indicator to adapt across asset classes and trading styles.
Bollinger Bands
Bollinger Bands measure price deviation around a moving average. They help identify volatility expansion and contraction. In this script, the bands serve as breakout triggers—price crossing outside suggests momentum strong enough to sustain a trend.
Standard Deviation
Standard Deviation is a statistical measure that quantifies the dispersion of price data around the mean. With a multiplier applied, it creates bands that contain a probabilistic portion of price action. Crossing beyond these suggests a higher likelihood of trend continuation.
ATR (Average True Range)
ATR measures the degree of volatility. Instead of simply reacting to price crossing the bands, ATR ensures the trend line placement adapts to current conditions. In volatile markets, wider buffers prevent premature signals; in calmer markets, tighter placement keeps signals responsive.
Trend Line Logic
The trend line only adjusts in the direction of the trend. If new values do not exceed the prior, the line remains unchanged. This prevents false reversals and makes the line a reliable visual confirmation of trend direction.
Signal Detection
The indicator does not repaint: signals are based on confirmed closes relative to the Bollinger Bands. This makes it more reliable for both live trading and backtesting scenarios.
Visual Enhancements
The use of dual plots and fill shading creates a clearer separation of bullish vs. bearish phases. This helps traders visually align entries and exits without second-guessing.
Enjoy!
The indicator works by calculating in the following steps:
- Source Selection & Smoothing
The script begins by letting the user select a preferred price source (default is Close, but options include Open, High, Low, HL2, etc.). This raw input is then passed through a smoothing process.
Multiple smoothing techniques can be chosen: SMA, EMA, HMA, DEMA, TEMA, RMA, and FRAMA. Each method reduces short-term noise differently, ensuring flexibility for traders who prefer faster or slower reaction speeds in trend detection. - Bollinger Band Construction
Once the smoothed source is prepared, Bollinger Bands are calculated. The middle band is a moving average of the smoothed data over the defined BB Period. The upper and lower bands are then generated by adding and subtracting the Standard Deviation × Deviation multiplier. These dynamic bands capture volatility and help define breakout zones. - ATR Volatility Measurement
Parallel to the band calculation, the Average True Range (ATR) is computed over the chosen ATR Period. This measures market volatility. The ATR can optionally act as a filter, refining buy and sell levels so signals adapt to current market conditions rather than being fixed to price alone. - Bollinger Band Signals
-If the smoothed price closes above the upper band, a potential bullish event is marked.
-If the smoothed price closes below the lower band, a potential bearish event is marked. - Trend Line Construction
When a bullish event occurs, the script anchors a trend-following line beneath price. If ATR filtering is enabled, the line is set at Low – ATR, otherwise at the simple Low. Conversely, when a bearish event occurs, the line is anchored above price at High + ATR (or just High without the filter). The line is designed to only move in the direction of the trend—if price action does not exceed the prior value, the previous level is held. This prevents unnecessary whipsaws and keeps the indicator aligned with dominant momentum. - Final Trend Detection
The slope of the trend line defines the trend itself:
-Rising line → bullish trend.
-Falling line → bearish trend. - Visual Output
The indicator plots the trend line with dynamic coloring: Blue for bullish phases, Purple for bearish phases. A subtle filled background area emphasizes the active trend zone for clearer chart interpretation.
Buy and Sell Conditions:
-Buy Signal: Triggered when smoothed price closes above the upper Bollinger Band. Trend line then anchors below price (with or without ATR offset depending on settings).
-Sell Signal: Triggered when smoothed price closes below the lower Bollinger Band. Trend line then anchors above price (with or without ATR offset).
Additional filtering is possible via:
-ATR Toggle: Switch ATR on or off to adapt the strategy to either volatile or steady markets.
-Smoothing Method: Adjust smoothing to speed up or slow down responsiveness.
-Deviation Multiplier: Tight or wide bands adjust the sensitivity of signals.
Features and Parameters:
-Source: Choose between Close, Open, High, Low, HL2, etc.
-Average Type: Options include SMA, EMA, HMA, DEMA, TEMA, RMA, FRAMA.
-ATR Period: Defines how ATR volatility is measured.
-BB Period: Lookback length for Bollinger Band construction.
-Deviation: Multiplier for the standard deviation in Bollinger Bands.
-Smoothing Period: Controls how much the source data is smoothed.
-ATR Filter On/Off: Enables or disables ATR integration in signal calculation.
Specifications:
Smoothing (MA Types)
Smoothing is essential to reduce chart noise. By offering multiple MA choices, traders can balance between lag (SMA, RMA) and responsiveness (EMA, HMA, FRAMA). This flexibility allows the indicator to adapt across asset classes and trading styles.
Bollinger Bands
Bollinger Bands measure price deviation around a moving average. They help identify volatility expansion and contraction. In this script, the bands serve as breakout triggers—price crossing outside suggests momentum strong enough to sustain a trend.
Standard Deviation
Standard Deviation is a statistical measure that quantifies the dispersion of price data around the mean. With a multiplier applied, it creates bands that contain a probabilistic portion of price action. Crossing beyond these suggests a higher likelihood of trend continuation.
ATR (Average True Range)
ATR measures the degree of volatility. Instead of simply reacting to price crossing the bands, ATR ensures the trend line placement adapts to current conditions. In volatile markets, wider buffers prevent premature signals; in calmer markets, tighter placement keeps signals responsive.
Trend Line Logic
The trend line only adjusts in the direction of the trend. If new values do not exceed the prior, the line remains unchanged. This prevents false reversals and makes the line a reliable visual confirmation of trend direction.
Signal Detection
The indicator does not repaint: signals are based on confirmed closes relative to the Bollinger Bands. This makes it more reliable for both live trading and backtesting scenarios.
Visual Enhancements
The use of dual plots and fill shading creates a clearer separation of bullish vs. bearish phases. This helps traders visually align entries and exits without second-guessing.
Enjoy!
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.