NinjaScript and Pine developer
Bootstraps: a forecast fan for TradingView (Pine v6)
Bootstraps draws a fan of where price could go over the next few bars, built by resampling the chart's own recent returns thousands of ways. It is a statistical what-if, not a prediction. Open source, free on TradingView.
What you see
- A 90% band, a 25-75% band and a median line, starting at the last closed bar.
- A small table: median move, 90% range, chance of ending higher, chance of touching a level you set (default 2%).
- The fan holds still while a bar forms and updates once when it closes. Optional: start it from the live price.
How it works
- Stationary block bootstrap (Politis and Romano, 1994): past returns are resampled in blocks of random length, so short-range clustering is kept.
- Fixed random seed: the same data gives the same fan.
- No
request.*()calls, no lookahead, no future data.
Tested, with the settings it ships with
I tested the method on 5-minute regular-hours bars for seven futures markets (equity indices, gold, Treasury notes, euro FX), 2015 to 2026, using walk-forward checks: at each point, forecast using only earlier data, then see where price actually went. Averages across the seven markets:
| Horizon | History used (Preset) | 90% band contained the outcome | 50% band contained the outcome |
|---|---|---|---|
| 10 bars | 500 bars | 88% | 52% |
| 20 bars | 1000 bars | 88% | 52% |
| 40 bars | 1000 bars | 87% | 51% |
- The 50% band is well calibrated. The 90% band runs about 2 points narrow, so treat the outer edge as a little optimistic.
- Short history hurts at long horizons (40 bars with 250 bars of history: 83%), which is why Preset uses more history for longer horizons.
- A plain normal-distribution forecast scored about the same on accuracy, but its 50% band was far too wide (65% instead of 50%). A volatility-scaled version did not help and was dropped.
- The seven markets behaved alike, so there is one default, not one per market. Not tested: crypto, stocks, other timeframes.
- Settings: Preset (default) or Manual (history length, block length, horizon, paths, confidence, seed, table position, anchor).
Important
Not trading advice. Past behaviour does not predict future results.
Get it
Stationary Bootstrap Fan on TradingView
Need something custom?
I write Pine v6 and NinjaScript indicators and strategies, and audit existing scripts.