RSI with Bollinger Bands
RSI with a Bollinger envelope around its moving average, 30/70 guides and crossover dots.
- RSI BB
- Updates every tick
- rsi
- bollinger bands
- oscillator
- overbought
- oversold
- crossover
- histogram
MIT-0: free to use, change and share, no attribution needed. What you build from it is yours.

Overview
Relative Strength Index with a Bollinger envelope drawn around its own moving average.
How to read it
RSI above the upper band marks unusually strong momentum; below the lower band, unusually weak. The 30/70 guides are the classic oversold/overbought levels.
Green dots mark RSI crossing above its own average; the histogram shows how far RSI is from that average.
Settings and limitations
RSI length (14) sets how quickly RSI reacts. Band length (20) and Band width (2) set how far RSI must move to leave the band. The first values appear after RSI length + Band length bars.
Notes
The band uses a population standard deviation, like the built-in Bollinger Bands.
Settings
Each setting appears in the indicator's settings panel in Spectral, next to a color setting for every output.
| Setting | Type | Default | Range or options | What it does |
|---|---|---|---|---|
| RSI length | Whole number | 14 | 2 – 200, step 1 | Number of bars in the RSI lookback. Shorter reacts faster but is noisier. |
| Source | Price source | close | open, high, low, close, hlc3 | Price the RSI is calculated from. |
| Band length | Whole number | 20 | 2 – 200 | Number of RSI values in the band average and its standard deviation. |
| Band width | Number | 2 | 0.5 – 5, step 0.1 | Distance of each band from the average, in standard deviations. |
| Fill band | On / off | On | — | Shade the area between the upper and lower band. |
Presets
Each preset is its own entry in the Indicators toolbox, with these settings changed.
| Toolbox entry | Short name | Settings |
|---|---|---|
| RSI BB (fast) | RSI BB 7 | RSI length: 7Band length: 10 |
What it draws
Lines
- RSIsolid · 1.5 px · primary
#B7A1C8 - Basissolid · 1 px
#C4A46A - Upperdashed · 1 px
#788493 - Lowerdashed · 1 px
#788493
Levels
- 70dotted · 1 px · value on the axis
#788493 - 30dotted · 1 px
#788493
Zones
- Bandfilled at 10% opacity
#8AA9C3
Markers
- RSI crosses basisdot, radius 3
#3FB950
Histograms
- RSI minus basishistogram bars
#58A6FF
Source
Save it as rsi-bands.js and add it with Indicators → Custom indicators → Add file…. The format is explained in the custom indicators guide.
// Copyright (c) 2026 Spectral
// SPDX-License-Identifier: MIT-0
// Free to use, copy, modify and share: https://spectral.trade/docs/custom-indicators/LICENSE.txt
/** @type {import('./spectral-indicator').IndicatorV1} */
export default {
schemaVersion: 1,
id: 'rsi-bands',
name: 'RSI with Bollinger Bands',
shortName: 'RSI BB',
version: '1.0.0',
author: 'Spectral examples',
description: 'RSI with a Bollinger envelope around its moving average, 30/70 guides and crossover dots.',
pane: 'oscillator',
live: { lookback: 'bbLength' },
inputs: {
length: { type: 'integer', label: 'RSI length', default: 14, min: 2, max: 200, step: 1, description: 'Number of bars in the RSI lookback. Shorter reacts faster but is noisier.' },
source: { type: 'source', label: 'Source', default: 'close', description: 'Price the RSI is calculated from.' },
bbLength: { type: 'integer', label: 'Band length', default: 20, min: 2, max: 200, description: 'Number of RSI values in the band average and its standard deviation.' },
bbMult: { type: 'number', label: 'Band width', default: 2, min: 0.5, max: 5, step: 0.1, description: 'Distance of each band from the average, in standard deviations.' },
showBand: { type: 'boolean', label: 'Fill band', default: true, description: 'Shade the area between the upper and lower band.' },
},
plots: {
rsi: { label: 'RSI', color: '#B7A1C8', lineWidth: 1.5, primary: true },
basis: { label: 'Basis', color: '#C4A46A', lineWidth: 1 },
upper: { label: 'Upper', color: '#788493', lineStyle: 'dashed' },
lower: { label: 'Lower', color: '#788493', lineStyle: 'dashed' },
},
levels: {
overbought: { label: '70', color: '#788493', lineStyle: 'dotted', showValue: true },
oversold: { label: '30', color: '#788493', lineStyle: 'dotted' },
},
zones: { band: { label: 'Band', color: '#8AA9C3', opacity: 0.1 } },
markers: { cross: { label: 'RSI crosses basis', color: '#3FB950', radius: 3 } },
columns: { spread: { label: 'RSI minus basis', color: '#58A6FF' } },
presets: [{ id: 'fast', name: 'RSI BB (fast)', shortName: 'RSI BB 7', inputs: { length: 7, bbLength: 10 } }],
docs: {
overview: 'Relative Strength Index with a Bollinger envelope drawn around its own moving average.',
howToRead: 'RSI above the upper band marks unusually strong momentum; below the lower band, unusually weak. The 30/70 guides are the classic oversold/overbought levels.\n\nGreen dots mark RSI crossing above its own average; the histogram shows how far RSI is from that average.',
settings: 'RSI length (14) sets how quickly RSI reacts. Band length (20) and Band width (2) set how far RSI must move to leave the band. The first values appear after RSI length + Band length bars.',
notes: 'The band uses a population standard deviation, like the built-in Bollinger Bands.',
},
calculate(ctx) {
const { ta, inputs, bars } = ctx;
const rsi = ta.rsi(ta.source(bars, inputs.source), inputs.length);
const basis = ta.sma(rsi, inputs.bbLength);
const deviation = ta.stdev(rsi, inputs.bbLength);
const upper = basis.map((value, index) => (value === null || deviation[index] === null ? null : value + inputs.bbMult * deviation[index]));
const lower = basis.map((value, index) => (value === null || deviation[index] === null ? null : value - inputs.bbMult * deviation[index]));
const crosses = ta.crossover(rsi, basis);
const markers = [];
for (let index = 0; index < bars.length; index += 1) {
if (crosses[index] && rsi[index] !== null) markers.push({ index, value: rsi[index] });
}
return {
plots: { rsi, basis, upper, lower },
levels: { overbought: 70, oversold: 30 },
zones: inputs.showBand ? { band: { upper, lower } } : { band: { upper: upper.map(() => null), lower: lower.map(() => null) } },
markers: { cross: markers },
columns: { spread: rsi.map((value, index) => (value === null || basis[index] === null ? null : value - basis[index])) },
};
},
};Adapt it with an LLM
Paste this into your assistant and replace the second-to-last line with the change you want.
Start from this Spectral custom indicator: https://spectral.trade/indicators/rsi-bands.js Format reference: https://spectral.trade/docs/custom-indicators.llm.md Keep the file format and every rule of the reference; give the result a new id, name, shortName and version, and update docs and input descriptions to match. Keep its live updates exact and fast (section "Fast live updates" of the reference): carry values from bar to bar only through ctx.ta, and raise live.lookback if the change reads further back; Spectral rejects a file whose live updates differ from a full recalculation or are too slow. Change I want: <describe the change> Answer with the complete file in one code block, ready to save as <id>.js.


