Volume
Volume bars in their own pane with a rolling average line and a shaded cloud up to the average.
- Volume
- Built into Spectral
- Updates every tick
- Uses volume
- volume
- histogram
- average
- participation
MIT-0: free to use, change and share, no attribution needed. What you build from it is yours.
Already in Spectral: add it from the Indicators toolbox. The file here is the same indicator written as a custom indicator, to change or learn from. Installed, it appears next to the built-in one, marked Custom.

Overview
Volume plots the reported volume of every chart bar as a histogram, green when the bar closed at or above its open and red when it closed below it, with a rolling average of the last Average length bars and a shaded cloud from zero up to that average.
How to read it
Bars that rise well above the cloud show stronger participation than the recent baseline; moves on bars inside the cloud have less broad support. Compare each bar with the average and with nearby price structure.
Settings and limitations
The average defaults to 20 bars and appears once 20 bars are loaded. Missing volume counts as zero in the average. Volume is bar-level reported volume, so its meaning depends on the instrument, the bar size, the session and the data feed.
Notes
Computes the same bars, colors and average as the built-in Volume in Spectral (its colors follow your candle colors there; here the Up bar and Down bar colors are settings). Custom indicators cannot use the dedicated volume pane yet, so this one opens its own pane below the chart. Version 1.0.0 drew every bar in one color: a bar color saved there carries over to the Up bar color only, so set Down bar as well to keep one color.
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 |
|---|---|---|---|---|
| Average length | Whole number | 20 | 1 – 500 | Bars in the rolling volume average. |
| Show cloud | On / off | On | — | Shade the area from zero up to the average. |
| Show average line | On / off | On | — | Draw the average as a line on top of the cloud. |
What it draws
Lines
- Averagesolid · 1 px · primary
#8AA9C3
Zones
- Average cloudfilled at 18% opacity
#8AA9C3
Histograms
- Up barhistogram bars
#089981 - Down barhistogram bars
#F23645
Source
Save it as volume.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: 'volume',
name: 'Volume',
shortName: 'Volume',
version: '1.1.0',
author: 'Spectral',
description: 'Volume bars in their own pane with a rolling average line and a shaded cloud up to the average.',
pane: 'oscillator',
live: { lookback: 'averageLength' },
usesVolume: true,
inputs: {
averageLength: { type: 'integer', label: 'Average length', default: 20, min: 1, max: 500, description: 'Bars in the rolling volume average.' },
showCloud: { type: 'boolean', label: 'Show cloud', default: true, description: 'Shade the area from zero up to the average.' },
showAverage: { type: 'boolean', label: 'Show average line', default: true, description: 'Draw the average as a line on top of the cloud.' },
},
plots: {
average: { label: 'Average', color: '#8AA9C3', lineWidth: 1, primary: true },
},
zones: {
cloud: { label: 'Average cloud', color: '#8AA9C3', opacity: 0.18 },
},
columns: {
// `volume` stays the key of the up bars, so a color saved for the column in 1.0.0 still applies.
volume: { label: 'Up bar', color: '#089981' },
down: { label: 'Down bar', color: '#F23645' },
},
docs: {
overview: 'Volume plots the reported volume of every chart bar as a histogram, green when the bar closed at or above its open and red when it closed below it, with a rolling average of the last Average length bars and a shaded cloud from zero up to that average.',
howToRead: 'Bars that rise well above the cloud show stronger participation than the recent baseline; moves on bars inside the cloud have less broad support. Compare each bar with the average and with nearby price structure.',
settings: 'The average defaults to 20 bars and appears once 20 bars are loaded. Missing volume counts as zero in the average. Volume is bar-level reported volume, so its meaning depends on the instrument, the bar size, the session and the data feed.',
notes: 'Computes the same bars, colors and average as the built-in Volume in Spectral (its colors follow your candle colors there; here the Up bar and Down bar colors are settings). Custom indicators cannot use the dedicated volume pane yet, so this one opens its own pane below the chart. Version 1.0.0 drew every bar in one color: a bar color saved there carries over to the Up bar color only, so set Down bar as well to keep one color.',
},
calculate(ctx) {
const { bars, inputs, ta } = ctx;
const length = inputs.averageLength;
const volumes = bars.map((bar) => Math.max(0, bar.volume ?? 0));
// The window's running sum carries from bar to bar through ta.scan: each bar adds its volume, and from the
// Length-th bar on the volume Length bars back leaves it.
const items = volumes.map((volume, index) => ({ volume, leaving: volumes[index - length] }));
const sums = ta.scan(items, 0, (sum, item, index) => {
const added = sum + item.volume;
return index >= length ? added - item.leaving : added;
});
const average = sums.map((sum, index) => (index >= length - 1 ? sum / length : null));
const hidden = bars.map(() => null);
return {
plots: { average: inputs.showAverage ? average : hidden },
zones: { cloud: inputs.showCloud ? { upper: average, lower: average.map((value) => (value === null ? null : 0)) } : { upper: hidden, lower: hidden } },
// Colored by direction like the built-in: green when the close is at or above the open.
columns: {
volume: bars.map((bar) => (typeof bar.volume === 'number' && bar.close >= bar.open ? bar.volume : null)),
down: bars.map((bar) => (typeof bar.volume === 'number' && bar.close < bar.open ? bar.volume : null)),
},
};
},
};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/volume.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.


