Indicator · Pine Script v6 · Own pane

GOM BB Prediction (300 bars)

by Sidoine1991

This indicator calculates and plots predicted future Bollinger Bands mid, upper, and lower lines for 300 bars ahead using linear extrapolation.

View on GitHub

Repaints

GitHub stars4on the repository
Pine versionv6current
Lines of code110
Settings4inputs
LicenceMIT
Last update2 weeks ago13 Oct 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

110 lines of Pine Script v6 from mt5/GOM_BB_PREDICTION.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

GOM_BB_PREDICTION.pine
//@version=6
// GOM_BB_PREDICTION.pine — Calcule les Bollinger Bands futures (300 bougies)
// À ajouter comme étude separate ou fusionner dans GOM_KOLA_script.pine

indicator("GOM BB Prediction (300 bars)", shorttitle="GOM BB Pred", overlay=false)

// Entrées
pred_horizon = input.int(300, "Horizon prediction (bougies)", minval=50, maxval=500)
pred_method = input.string("linear", "Méthode", options=["linear", "trend", "sma"])
bb_period = input.int(20, "Période Bollinger", minval=5, maxval=50)
bb_dev = input.float(2.0, "Déviation Bollinger", minval=0.5, maxval=4.0)

// Calculer BB actuels
[bb_mid, bb_up, bb_dn] = ta.bb(close, bb_period, bb_dev)

// ═══════════════════════════════════════════════════════════════
// PRÉDICTION LINÉAIRE — extrapolation simple
// ═══════════════════════════════════════════════════════════════
// Pente simple sur les 20 dernières bougies
lookback_slope = 20

// Mid-line trend
slope_mid = 0.0
if bb_period <= bar_index
    slope_mid := (bb_mid - bb_mid[lookback_slope]) / lookback_slope

// Upper trend
slope_up = 0.0
if bb_period <= bar_index
    slope_up := (bb_up - bb_up[lookback_slope]) / lookback_slope

// Lower trend
slope_dn = 0.0
if bb_period <= bar_index
    slope_dn := (bb_dn - bb_dn[lookback_slope]) / lookback_slope

// ─────────────────────────────────────────────────────────────
// Prédictions futures (300 bars)
// ─────────────────────────────────────────────────────────────
var array<float> pred_bb_mid = array.new<float>()
var array<float> pred_bb_up  = array.new<float>()
var array<float> pred_bb_dn  = array.new<float>()
var array<int>   pred_times  = array.new<int>()

if barstate.islast
    // Effacer anciens
    array.clear(pred_bb_mid)
    array.clear(pred_bb_up)
    array.clear(pred_bb_dn)
    array.clear(pred_times)

    // Générer 300 points prédits
    current_mid = bb_mid
    current_up  = bb_up
    current_dn  = bb_dn

    for i = 1 to pred_horizon
        // Extrapolation linéaire
        future_mid = current_mid + slope_mid * i
        future_up  = current_up + slope_up * i
        future_dn  = current_dn + slope_dn * i

        array.push(pred_bb_mid, future_mid)
        array.push(pred_bb_up,  future_up)
        array.push(pred_bb_dn,  future_dn)
        array.push(pred_times,  bar_index + i)

// ─────────────────────────────────────────────────────────────
// EXPORT JSON pour webhook
// ─────────────────────────────────────────────────────────────
// Construire une chaîne JSON compacte (JSON complet = trop lourd)

pred_json = ""
if barstate.islast and array.size(pred_bb_mid) > 0
    // Format compact: "mid:[1,2,3]|up:[1,2,3]|dn:[1,2,3]"
    mid_str = ""
    up_str  = ""
    dn_str  = ""

    // Limiter à 100 points pour rester dans les limites
    steps = math.max(1, array.size(pred_bb_mid) / 100)

    for i = 0 to array.size(pred_bb_mid) - 1 by steps
        if mid_str != ""
            mid_str += ","
            up_str  += ","
            dn_str  += ","
        mid_str += str.tostring(math.round(array.get(pred_bb_mid, i) * 100) / 100)
        up_str  += str.tostring(math.round(array.get(pred_bb_up, i) * 100) / 100)
        dn_str  += str.tostring(math.round(array.get(pred_bb_dn, i) * 100) / 100)

    pred_json = "PRED_BB|" + syminfo.ticker + "|" + timeframe.period + "|MID:[" + mid_str + "]|UP:[" + up_str + "]|DN:[" + dn_str + "]"

// Plot pour debug (affiche les prédictions)
plot(barstate.islast ? bb_mid : na, "BB Mid Current", color=color.blue, linewidth=2)
plot(barstate.islast ? bb_up : na, "BB Up Current", color=color.red, linewidth=1)
plot(barstate.islast ? bb_dn : na, "BB Down Current", color=color.green, linewidth=1)

// Export via alerte
if barstate.isconfirmed and pred_json != ""
    alert(pred_json, alert.freq_once_per_bar_close)

// Affichage debug
var label pred_lbl = na
if barstate.islast
    if not na(pred_lbl)
        label.delete(pred_lbl)
    pred_lbl := label.new(bar_index, bb_mid,
         "Pred: " + str.tostring(array.size(pred_bb_mid)) + " points",
         color=color.new(color.blue, 80), textcolor=color.white, size=size.small)

Overview

GOM BB Prediction (300 bars) draws these prediction lines in a separate pane below the price chart. Users can adjust the prediction horizon in bars, the Bollinger Bands period and deviation, and the extrapolation method. No entry or exit signals are provided, as it functions purely as a forecasting tool. The main settings control the lookback for slope calculation, the number of predicted bars, and Bollinger parameters. It has a notable limit of using future data for predictions and is intended for separate pane use only.

Details

Published by

Sidoine1991 on GitHub

Type

Indicator, Pine Script v6

Draws

Separate pane below the chart

Category

Volatility & bands, Moving averages

Markets

Forex, Indices

Timeframes

Any timeframe

Risk Notes

  • Reads higher-timeframe data with lookahead on, so the history can show signals that were not there in real time

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Horizon prediction (bougies)int300pred_horizon
Méthodestringlinearpred_method
Période Bollingerint20bb_period
Déviation Bollingerfloat2.0bb_dev
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

318 stars

Calculates and plots moving averages on selected VIX volatility terms (VIX9D, VIX, VIX3M, or VIX6M) in a separate pane. The script computes user-defined short and long moving averages using EMA or SMA. It shades the background red when the short-term moving av

Indicator v5 Volatility & bandsMoving averages
Updated 2 months ago · MIT GitHub repository of [TVT] VIX Short Term Danger

MACD-V

by harryguiacorn
219 stars

MACD-V is a volatility-normalized momentum indicator based on research by Alex Spiroglou. It calculates the standard MACD histogram and normalizes it by dividing by the Average True Range (ATR). Plotted in a separate pane as a colored histogram, it includes us

Indicator v5 Oscillators & momentumVolatility & bands
Updated 1 year ago · None stated GitHub repository of MACD-V

MultiIndicator

by capissimo
114 stars

MultiIndicator combines multiple technical indicators into a single separate pane to save chart space. It calculates and displays market regime detection based on ordinary least squares regression, a Holt exponential smoothing crossover, normalized RSI, ADX, a

Indicator v4 Oscillators & momentumTrend
Updated 1 year ago · None stated GitHub repository of MultiIndicator

The AMFM indicator decomposes price movements into amplitude and frequency components using Ehlers' digital signal processing methods. It whitens the derivative as close minus open, then computes AM as the smoothed envelope of the absolute difference over 4 pe

Indicator v6 Volatility & bandsMoving averages
Updated 4 weeks ago · Apache-2.0 GitHub repository of AMFM - Ehlers AM Detector / FM Demodulator

PPO ATR Bands

by cryptorife
75 stars

PPO ATR Bands plots a percentage price oscillator in a separate pane. It compares a Hull average of typical price with a volume-weighted exponential average of Parabolic SAR, then scales three true-range bands around the slow average into matching oscillator l

Indicator v4 Oscillators & momentumMoving averages
Updated 3 years ago · GPL-3.0 GitHub repository of PPO ATR Bands

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers