A momentum oscillator that blends three lookback periods into one 0-100 reading, aiming to reduce some of the false signals common in single-period oscillators.
The Ultimate Oscillator (UO) is a momentum indicator developed by Larry Williams in 1976. It measures buying pressure across three different lookback periods at once - by default 7, 14, and 28 bars - and combines them into a single value that moves between 0 and 100. The idea behind using three periods is to address a common complaint about single-period oscillators: that they can react sharply to short-term price swings and produce readings that flip quickly. By weighting a short, medium, and long period together, the UO aims to give a smoother momentum picture. It is an educational analysis tool, not a predictive one, and it does not tell you what price will do next. Trading carries risk of loss.
The UO is built from "buying pressure" relative to "true range" on each bar. Buying pressure (BP) for a bar is the close minus the lower of (the current low) or (the prior close). True range (TR) is the higher of (the current high) or (the prior close), minus the lower of (the current low) or (the prior close). For each of the three periods (commonly 7, 14, 28), the indicator sums buying pressure and divides it by the sum of true range over that window, producing three averages. These three averages are combined with fixed weights of 4, 2, and 1 - giving the shortest period the most influence - and scaled to a 0-100 range. The formula is: UO = 100 x (4 x Avg7 + 2 x Avg14 + 1 x Avg28) / (4 + 2 + 1). Because it uses summed buying pressure over summed true range rather than a moving average of price, the UO reflects where the close sits within each bar's range over time rather than the closing price alone.
Default periods are 7, 14, and 28 with fixed 4:2:1 weighting (this weighting is part of the formula and is not usually adjustable). Reference levels are commonly drawn at 70 and 30, with 50 as an optional midline. Some traders widen these to 80/20 to mark only more extreme readings. These are conventions, not optimized values.
//@version=6
indicator("Ultimate Oscillator", shorttitle="UO")
length1 = input.int(7, "Fast Length")
length2 = input.int(14, "Middle Length")
length3 = input.int(28, "Slow Length")
// Buying pressure and true range
bp = close - math.min(low, close[1])
tr = math.max(high, close[1]) - math.min(low, close[1])
avg(len) => math.sum(bp, len) / math.sum(tr, len)
uo = 100 * (4 * avg(length1) + 2 * avg(length2) + avg(length3)) / 7
plot(uo, "UO", color=color.blue)
hline(70, "Upper", color=color.gray)
hline(50, "Mid", color=color.new(color.gray, 60))
hline(30, "Lower", color=color.gray)Pro tip: If you study divergences, mark them against clear swing points in price rather than every minor wiggle, and read them alongside broader context like trend and structure. Divergence is a context cue about possible weakening momentum, not a trigger - and it can resolve against you, so treat the UO as one input among several and remember trading carries risk of loss.
Educational only — not financial advice, not a recommendation to trade. No indicator is predictive; trading involves substantial risk of loss.