Ultimate Oscillator
Buying pressure relative to true range over three lookbacks, weighted 4:2:1, on a 0-100 scale with 70/30 bands.
- UO
- Built into Spectral
- Updates every tick
- ultimate oscillator
- uo
- larry williams
- buying pressure
- overbought
- oversold
- momentum
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
The Ultimate Oscillator (Larry Williams) measures buying pressure, the close minus the lower of the low and the previous close, as a share of the true range. It sums both over three lookbacks (7, 14 and 28 bars), divides them, and averages the three ratios with weights 4, 2 and 1, so the short lookback counts most without letting it dominate. The result runs from 0 to 100.
How to read it
Above 50 closes have been in the upper part of their true ranges, below 50 in the lower part. Williams used 70 and 30 as the overbought and oversold zones.
His original signal is a divergence: price makes a new low while the oscillator makes a higher low that held above 30, then the oscillator rises above the high between the two lows. Readings on their own describe pressure; compare them with price structure.
Settings and limitations
Defaults are 7, 14 and 28 bars, as on TradingView. Keeping the 1:2:4 ratio between the lengths keeps the character of the indicator. The first value appears on bar Slow length + 1 (bar 29 with the defaults), because the first bar has no previous close. When nothing traded in range over a lookback, there is no value.
Notes
Matches the Ultimate Oscillator on TradingView and most platforms: 100 x (4 x A7 + 2 x A14 + A28) / 7, where each A is the sum of buying pressure divided by the sum of true range over that lookback.
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 |
|---|---|---|---|---|
| Fast length | Whole number | 7 | 1 – 500 | Bars in the shortest lookback, weighted 4. |
| Middle length | Whole number | 14 | 1 – 500 | Bars in the middle lookback, weighted 2. |
| Slow length | Whole number | 28 | 1 – 500 | Bars in the longest lookback, weighted 1. |
| Upper band | Number | 70 | 0 – 100, step 1 | Level of the upper reference band. |
| Middle band | Number | 50 | 0 – 100, step 1 | Level of the middle reference band. |
| Lower band | Number | 30 | 0 – 100, step 1 | Level of the lower reference band. |
| Fill between bands | On / off | On | — | Shade the area between the upper and lower band. |
What it draws
Lines
- UOsolid · 1.5 px · primary
#7FB5A0
Levels
- Upper banddashed · 1 px
#788493 - Middle banddotted · 1 px
#788493 - Lower banddashed · 1 px
#788493
Zones
- Band fillfilled at 10% opacity
#7FB5A0
Source
Save it as ultimate-oscillator.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').IndicatorV2} */
export default {
schemaVersion: 2,
id: 'ultimate-oscillator',
name: 'Ultimate Oscillator',
shortName: 'UO',
version: '1.0.0',
author: 'Spectral',
description: 'Buying pressure relative to true range over three lookbacks, weighted 4:2:1, on a 0-100 scale with 70/30 bands.',
pane: 'oscillator',
live: { lookback: 'fastLength + middleLength + slowLength' },
inputs: {
fastLength: { type: 'integer', label: 'Fast length', default: 7, min: 1, max: 500, description: 'Bars in the shortest lookback, weighted 4.' },
middleLength: { type: 'integer', label: 'Middle length', default: 14, min: 1, max: 500, description: 'Bars in the middle lookback, weighted 2.' },
slowLength: { type: 'integer', label: 'Slow length', default: 28, min: 1, max: 500, description: 'Bars in the longest lookback, weighted 1.' },
upperBand: { type: 'number', label: 'Upper band', default: 70, min: 0, max: 100, step: 1, description: 'Level of the upper reference band.' },
middleBand: { type: 'number', label: 'Middle band', default: 50, min: 0, max: 100, step: 1, description: 'Level of the middle reference band.' },
lowerBand: { type: 'number', label: 'Lower band', default: 30, min: 0, max: 100, step: 1, description: 'Level of the lower reference band.' },
showFill: { type: 'boolean', label: 'Fill between bands', default: true, description: 'Shade the area between the upper and lower band.' },
},
plots: {
uo: { label: 'UO', color: '#7FB5A0', lineWidth: 1.5, primary: true },
},
levels: {
upper: { label: 'Upper band', color: '#788493', lineStyle: 'dashed' },
middle: { label: 'Middle band', color: '#788493', lineStyle: 'dotted' },
lower: { label: 'Lower band', color: '#788493', lineStyle: 'dashed' },
},
zones: {
fill: { label: 'Band fill', color: '#7FB5A0', opacity: 0.1 },
},
docs: {
overview: 'The Ultimate Oscillator (Larry Williams) measures buying pressure, the close minus the lower of the low and the previous close, as a share of the true range. It sums both over three lookbacks (7, 14 and 28 bars), divides them, and averages the three ratios with weights 4, 2 and 1, so the short lookback counts most without letting it dominate. The result runs from 0 to 100.',
howToRead: 'Above 50 closes have been in the upper part of their true ranges, below 50 in the lower part. Williams used 70 and 30 as the overbought and oversold zones.\n\nHis original signal is a divergence: price makes a new low while the oscillator makes a higher low that held above 30, then the oscillator rises above the high between the two lows. Readings on their own describe pressure; compare them with price structure.',
settings: 'Defaults are 7, 14 and 28 bars, as on TradingView. Keeping the 1:2:4 ratio between the lengths keeps the character of the indicator. The first value appears on bar Slow length + 1 (bar 29 with the defaults), because the first bar has no previous close. When nothing traded in range over a lookback, there is no value.',
notes: 'Matches the Ultimate Oscillator on TradingView and most platforms: 100 x (4 x A7 + 2 x A14 + A28) / 7, where each A is the sum of buying pressure divided by the sum of true range over that lookback.',
},
calculate(ctx) {
const { bars, inputs, ta } = ctx;
const pressure = [];
const range = [];
for (let index = 0; index < bars.length; index += 1) {
const bar = bars[index];
if (index === 0) {
pressure.push(null);
range.push(null);
continue;
}
const previousClose = bars[index - 1].close;
const low = Math.min(bar.low, previousClose);
pressure.push(bar.close - low);
range.push(Math.max(bar.high, previousClose) - low);
}
const ratio = (length) => {
const pressureSum = ta.sum(pressure, length);
const rangeSum = ta.sum(range, length);
return pressureSum.map((value, index) => (value === null || !rangeSum[index] ? null : value / rangeSum[index]));
};
const fast = ratio(inputs.fastLength);
const middle = ratio(inputs.middleLength);
const slow = ratio(inputs.slowLength);
const uo = fast.map((value, index) => (value === null || middle[index] === null || slow[index] === null
? null
: (100 * (4 * value + 2 * middle[index] + slow[index])) / 7));
const band = (value) => bars.map(() => (inputs.showFill ? value : null));
return {
plots: { uo },
levels: { upper: inputs.upperBand, middle: inputs.middleBand, lower: inputs.lowerBand },
zones: { fill: { upper: band(inputs.upperBand), lower: band(inputs.lowerBand) } },
};
},
};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/ultimate-oscillator.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.


