1. Bollinger Bands Forecast Strategy Description
Traditional Bollinger Bands combined with a projected "forecast cone" — linearly extrapolating the trend of the middle line and the band width, showing what the bands might look like in the future.
1.1 Indicator concept
The foundation is classic Bollinger Bands theory: plot a moving average (the basis = SMA) and 2 bands surrounding it at ±N standard deviations. Statistically, price tends to spend most of its time oscillating inside these 2 bands; when price touches or moves outside a band, that's typically a sign of a temporary "overbought/oversold" statistical extreme — prone to a pull back toward the mean (mean reversion).
BigBeluga's own extension — the "Regression Forecast": instead of only showing the bands as they are now, the indicator also extrapolates the direction of the basis line and the rate at which the band width is expanding/contracting, based on the most recent linear regression slope, then draws a "forecast cone" projecting forward into the future — assuming the current trend and volatility continue for the next forecastBars bars. This is NOT a prediction that factors in reversal/mean-reversion within the forecast itself — it is purely "if the current trend + volatility keep the same pace, this is what the bands would look like".
1.2 Indicator features
-
Display:
- Live Bollinger Bands: the Basis (SMA) line + Upper/Lower bands + a shaded fill between the 2 bands — drawn continuously on EVERY bar like standard BB. Basis changes color to teal if rising compared to 2 bars ago, red if falling.
- Forecast Cone: 3 polylines (Upper/Basis/Lower) extending forward forecastBars bars into the future, plus a shaded cone-shaped area (closed off by going out along Upper then back along Lower) representing where price is expected to stay within. Only shown on the current bar (still-forming) — no history of past cones is kept on bars that have already closed.
- End-of-cone price labels: 2 numeric labels showing the exact Upper/Lower value at the final point of the forecast cone (forecastBars bars from now).
- Rejection arrows: a ▼ label when the high just spiked above the Upper band and then fell back below it (a sign of rejection at the dynamic resistance), a ▲ label when the low just pierced below the Lower band and then bounced back above it (rejection at the dynamic support). Both arrow types SHARE one cooldown counter of a minimum 7 bars — once one arrow (regardless of direction) appears, no other arrow gets drawn for the next 7 bars.
- Alert: The indicator has NO alertcondition() at all in the code — you cannot set up an automatic alert for a band touch or an arrow appearing. It must be watched directly on the chart.
1.3 How to use it in trading
- Use the live Bollinger bands the traditional way: consider selling/taking profit when price presses against/exceeds the Upper band, consider buying/taking profit when price presses against/exceeds the Lower band — especially when combined with a ▼/▲ arrow (confirming price was actually rejected, not just touching and continuing on).
- Use the forecast cone to frame expectations: if the cone tilts upward (the forecast Basis line is teal, meaning the current basis is lower than the forecast value at the cone's end) → the "if the trend holds" scenario is further upside; tilting downward (red) → the scenario is further downside.
- Read the cone's width to gauge expected volatility: a cone widening over its length → volatility is trending wider (dSl positive); a cone narrowing → volatility is trending tighter (dSl negative), but it never narrows below a minimum floor (see the technical note below).
- Important usage note: the forecast portion is a purely linear extrapolation (assuming the current rate of rise/fall and the current rate of expansion/contraction stay constant) — it does NOT automatically account for the possibility of a reversal. The further into the future (larger i, approaching forecastBars), the larger the assumption error. Treat this as an "if-then" reference scenario, not a guaranteed forecast, and pair it with other trend-confirmation tools.
- Since the cone only exists on the current bar (no history is kept), you cannot look back on the chart to check how accurate past forecast cones turned out to be — it can only be observed live, in real time.
1.4 How the indicator works
Inputs & their role
- length (integer, default 40): number of bars used to compute the Basis (SMA) and standard deviation (stdev), and also the window used to compute the linear regression slope (linreg) for both the basis and the band width. Raising it makes the Basis/bands smoother but slower to react to recent changes, and the forecast slope also becomes more stable but slower to update; lowering it makes it more sensitive but noisier.
- mult (decimal, default 2.0): the standard-deviation multiplier used to compute band width (same as standard BB). E.g. stdev=$5, mult=2.0 → dev=$10, the Upper/Lower bands sit $10 from the Basis on each side. Raising mult widens the bands (fewer band-touch signals), and the forecast cone widens correspondingly too since dev is the base value the extrapolated dF is built from.
- src (price source, default close): the price used to compute the Basis/standard deviation.
- forecastBars (integer, default 40): how many bars the forecast cone extends into the future. Raising it makes the cone longer but the far end becomes less reliable (linear extrapolation stretched further); lowering it makes the cone shorter, closer to the present, more trustworthy but less useful for "looking far ahead".
- uCol / lCol / fCol: the Upper / Lower line color and fill color — shared by BOTH the live bands and the forecast cone.
- bColU / bColD (default teal / red): the 2 colors for the Basis line depending on trend — used for both the live Basis line (versus 2 bars ago) AND the Basis line inside the forecast cone (versus the forecast value at the cone's end) — 2 different comparisons but mapped to the same color pair.
- widthB (integer, default 3): the Basis line's thickness (both the live version and the version inside the forecast cone).
Main logic blocks
📏 Flow 1 — Live Bollinger Bands (every bar)
- Basis = SMA(src, length); dev = mult × stdev(src, length); Upper = Basis + dev; Lower = Basis − dev — the standard BB formula, recomputed every bar.
- Basis color (the live line, not the cone): compares the current basis to the basis 2 bars ago — higher → teal, lower → red.
- This part is always displayed on EVERY bar, including historical bars, not just the last one.
📐 Flow 2 — Estimating the rate of change (every bar, preparing for the forecast)
- bSl (Basis slope): = the linear regression (linreg) value of the Basis at the current bar minus the regression value at the previous bar → approximates "how much the Basis is rising/falling per bar" along the regression trend line (not the raw price).
- dSl (band-width slope): computed the same way but for dev → approximates "how much the band width is expanding/contracting per bar".
- minW (minimum width floor): = the LOWEST value of (Upper − Lower) over the last 50 bars — used as a lower bound so the forecast width never shrinks too thin or negative.
🔮 Flow 3 — Building the forecast cone (runs only on the current, still-forming bar)
- Because this section re-runs on every real-time price update while the current bar is still unclosed, the indicator must delete the polyline/label set it drew last time before drawing a new one — otherwise countless old lines would pile up (Pine's technical limit is a max of 100 polylines at once).
- A loop runs from i = 0 to forecastBars, computing 1 point on the cone at each step:
- Pure extrapolated Basis: bF = Basis + bSl × i (continuing along the current regression slope).
- Extrapolated deviation, floor-clamped: dF = max(dev + dSl × i, minW).
- Pure extrapolated Upper/Lower: uF = bF + dF; dF_ = bF − dF.
- Smooth blend from current → extrapolated: w = i / forecastBars (running from 0 → 1). The actual value drawn on the cone = (current value) × (1−w) + (pure extrapolated value) × w — ensuring that at i=0 the cone matches EXACTLY the currently displayed bands (no visual break), and the further out i goes, the more it leans fully toward the linear-extrapolation line.
- Concrete example: Basis=$2650, bSl=+$0.8/bar, dev=$8, dSl=−$0.05/bar, forecastBars=40. At i=40 (end of cone): bF = 2650+0.8×40 = $2682; dF = max(8−0.05×40, minW) = max(6, minW). If minW=$5 → dF=$6 → the forecast Upper at the cone's end ≈ $2688, Lower ≈ $2676. Since i=40=forecastBars, w=1, so the cone's final point equals exactly the pure extrapolated value (no longer blended with the current one).
- At step i = forecastBars (the cone's final point): the code saves y2 = the forecast Basis value at that final point, then runs a second loop backward (k from forecastBars down to 0) to recompute the entire Lower-point sequence using the same formula — appended to the already-built Upper-point array, forming a single closed polygon (going out along the Upper edge, coming back along the Lower edge) so the cone's interior area can be filled.
🎨 Flow 4 — Drawing the cone & price labels
- Basis color INSIDE THE CONE (a different comparison than the live-Basis color in Flow 1): compares the current Basis against y2 (the forecast Basis at the cone's end) — current lower than y2 (expected to rise) → teal; otherwise → red.
- 3 forecast polylines (Upper/Basis/Lower) are drawn connecting the points computed in Flow 3; the closed polygon area is filled with fCol, producing the "cone" visual effect.
- 2 price labels are placed at the final point of the forecast Upper/Lower lines, showing the exact, rounded numeric value.
🔺🔻 Flow 5 — Band-rejection arrows (every closed bar)
- Only runs when barstate.isconfirmed (the bar has fully closed, avoiding a false draw based on the still-forming bar's temporary high/low).
- ▼: if the high just "crossed back under" the Upper band (meaning the previous bar's high ≥ Upper, this bar's high < Upper) AND at least 7 bars have passed since the last arrow was drawn → draw ▼ at the previous bar's high.
- ▲: if the low just "crossed back over" the Lower band (previous bar's low ≤ Lower, this bar's low > Lower) AND the 7-bar cooldown condition is met → draw ▲ at the previous bar's low.
- The cooldown counter (start) is SHARED by both arrow types — a ▼ arrow that just appeared also locks out the ▲ arrow for the next 7 bars, and vice versa.
Outputs & how they're used
- Live Bollinger bands + shaded fill: the traditional overbought/oversold reference frame for mean-reversion entries, or for tracking the current volatility state.
- Forecast cone + end-of-cone price labels: an "if the current trend & volatility hold pace" scenario — used to frame short-term expectations, NOT a direct entry signal.
- ▼/▲ arrows: a tactical signal confirming price was just rejected at the live band, noise-filtered by the 7-bar cooldown.


