OPEN-SOURCE SCRIPT
Ultimate Oscillator (ULTOSC)

The Ultimate Oscillator (ULTOSC) is a technical momentum indicator developed by Larry Williams that combines three different time periods to reduce the volatility and false signals common in single-period oscillators. By using a weighted average of three Stochastic-like calculations across short, medium, and long-term periods, the Ultimate Oscillator provides a more comprehensive view of market momentum while maintaining sensitivity to price changes.
The indicator addresses the common problem of oscillators being either too sensitive (generating many false signals) or too slow (missing opportunities). By incorporating multiple timeframes with decreasing weights for longer periods, ULTOSC attempts to capture both short-term momentum shifts and longer-term trend strength, making it particularly valuable for identifying divergences and potential reversal points.
## Core Concepts
* **Multi-timeframe analysis:** Combines three different periods (typically 7, 14, 28) to capture various momentum cycles
* **Weighted averaging:** Assigns higher weights to shorter periods for responsiveness while including longer periods for stability
* **Buying pressure focus:** Measures the relationship between closing price and the true range rather than just high-low range
* **Divergence detection:** Particularly effective at identifying momentum divergences that precede price reversals
* **Normalized scale:** Oscillates between 0 and 100, with clear overbought/oversold levels
## Common Settings and Parameters
| Parameter | Default | Function | When to Adjust |
|-----------|---------|----------|---------------|
| Fast Period | 7 | Short-term momentum calculation | Lower (5-6) for more sensitivity, higher (9-12) for smoother signals |
| Medium Period | 14 | Medium-term momentum calculation | Adjust based on typical swing duration in the market |
| Slow Period | 28 | Long-term momentum calculation | Higher values (35-42) for longer-term position trading |
| Fast Weight | 4.0 | Weight applied to fast period | Higher weight increases short-term sensitivity |
| Medium Weight | 2.0 | Weight applied to medium period | Adjust to balance medium-term influence |
| Slow Weight | 1.0 | Weight applied to slow period | Usually kept at 1.0 as the baseline weight |
**Pro Tip:** The classic 7/14/28 periods with 4/2/1 weights work well for most markets, but consider using 5/10/20 with adjusted weights for faster markets or 14/28/56 for longer-term analysis.
## Calculation and Mathematical Foundation
**Simplified explanation:**
The Ultimate Oscillator calculates three separate "buying pressure" ratios using different time periods, then combines them using weighted averaging. Buying pressure is defined as the close minus the true low, divided by the true range.
**Technical formula:**
```
BP = Close - Min(Low, Previous Close)
TR = Max(High, Previous Close) - Min(Low, Previous Close)
BP_Sum_Fast = Sum(BP, Fast Period)
TR_Sum_Fast = Sum(TR, Fast Period)
Raw_Fast = 100 × (BP_Sum_Fast / TR_Sum_Fast)
BP_Sum_Medium = Sum(BP, Medium Period)
TR_Sum_Medium = Sum(TR, Medium Period)
Raw_Medium = 100 × (BP_Sum_Medium / TR_Sum_Medium)
BP_Sum_Slow = Sum(BP, Slow Period)
TR_Sum_Slow = Sum(TR, Slow Period)
Raw_Slow = 100 × (BP_Sum_Slow / TR_Sum_Slow)
ULTOSC = 100 × [(Raw_Fast × Fast_Weight) + (Raw_Medium × Medium_Weight) + (Raw_Slow × Slow_Weight)] / (Fast_Weight + Medium_Weight + Slow_Weight)
```
Where:
- BP = Buying Pressure
- TR = True Range
- Fast Period = 7, Medium Period = 14, Slow Period = 28 (defaults)
- Fast Weight = 4, Medium Weight = 2, Slow Weight = 1 (defaults)
> 🔍 **Technical Note:** The implementation uses efficient circular buffers for all three period calculations, maintaining O(1) time complexity per bar. The algorithm properly handles true range calculations including gaps and ensures accurate buying pressure measurements across all timeframes.
## Interpretation Details
ULTOSC provides several analytical perspectives:
* **Overbought/Oversold conditions:** Values above 70 suggest overbought conditions, below 30 suggest oversold conditions
* **Momentum direction:** Rising ULTOSC indicates increasing buying pressure, falling indicates increasing selling pressure
* **Divergence analysis:** Divergences between ULTOSC and price often precede significant reversals
* **Trend confirmation:** ULTOSC direction can confirm or question the prevailing price trend
* **Signal quality:** Extreme readings (>80 or <20) indicate strong momentum that may be unsustainable
* **Multiple timeframe consensus:** When all three underlying periods agree, signals are typically more reliable
## Trading Applications
**Primary Uses:**
- **Divergence trading:** Identify when momentum diverges from price for reversal signals
- **Overbought/oversold identification:** Find potential entry/exit points at extreme levels
- **Trend confirmation:** Validate breakouts and trend continuations
- **Momentum analysis:** Assess the strength of current price movements
**Advanced Strategies:**
- **Multi-divergence confirmation:** Look for divergences across multiple timeframes
- **Momentum breakouts:** Trade when ULTOSC breaks above/below key levels with volume
- **Swing trading entries:** Use oversold/overbought levels for swing position entries
- **Trend strength assessment:** Evaluate trend quality using momentum consistency
## Signal Combinations
**Strong Bullish Signals:**
- ULTOSC rises from oversold territory (<30) with positive price divergence
- ULTOSC breaks above 50 after forming a base near 30
- All three underlying periods show increasing buying pressure
**Strong Bearish Signals:**
- ULTOSC falls from overbought territory (>70) with negative price divergence
- ULTOSC breaks below 50 after forming a top near 70
- All three underlying periods show decreasing buying pressure
**Divergence Signals:**
- **Bullish divergence:** Price makes lower lows while ULTOSC makes higher lows
- **Bearish divergence:** Price makes higher highs while ULTOSC makes lower highs
- **Hidden bullish divergence:** Price makes higher lows while ULTOSC makes lower lows (trend continuation)
- **Hidden bearish divergence:** Price makes lower highs while ULTOSC makes higher highs (trend continuation)
## Comparison with Related Oscillators
| Indicator | Periods | Focus | Best Use Case |
|-----------|---------|-------|---------------|
| **Ultimate Oscillator** | 3 periods | Buying pressure | Divergence detection |
| **Stochastic** | 1-2 periods | Price position | Overbought/oversold |
| **RSI** | 1 period | Price momentum | Momentum analysis |
| **Williams %R** | 1 period | Price position | Short-term signals |
## Advanced Configurations
**Fast Trading Setup:**
- Fast: 5, Medium: 10, Slow: 20
- Weights: 4/2/1, Thresholds: 75/25
**Standard Setup:**
- Fast: 7, Medium: 14, Slow: 28
- Weights: 4/2/1, Thresholds: 70/30
**Conservative Setup:**
- Fast: 14, Medium: 28, Slow: 56
- Weights: 3/2/1, Thresholds: 65/35
**Divergence Focused:**
- Fast: 7, Medium: 14, Slow: 28
- Weights: 2/2/2, Thresholds: 70/30
## Market-Specific Adjustments
**Volatile Markets:**
- Use longer periods (10/20/40) to reduce noise
- Consider higher threshold levels (75/25)
- Focus on extreme readings for signal quality
**Trending Markets:**
- Emphasize divergence analysis over absolute levels
- Look for momentum confirmation rather than reversal signals
- Use hidden divergences for trend continuation
**Range-Bound Markets:**
- Standard overbought/oversold levels work well
- Trade reversals from extreme levels
- Combine with support/resistance analysis
## Limitations and Considerations
* **Lagging component:** Contains inherent lag due to multiple moving average calculations
* **Complex calculation:** More computationally intensive than single-period oscillators
* **Parameter sensitivity:** Performance varies significantly with different period/weight combinations
* **Market dependency:** Most effective in trending markets with clear momentum patterns
* **False divergences:** Not all divergences lead to significant price reversals
* **Whipsaw potential:** Can generate conflicting signals in choppy markets
## Best Practices
**Effective Usage:**
- Focus on divergences rather than absolute overbought/oversold levels
- Combine with trend analysis for context
- Use multiple timeframe analysis for confirmation
- Pay attention to the speed of momentum changes
**Common Mistakes:**
- Over-relying on overbought/oversold levels in strong trends
- Ignoring the underlying trend direction
- Using inappropriate period settings for the market being analyzed
- Trading every divergence without additional confirmation
**Signal Enhancement:**
- Combine with volume analysis for confirmation
- Use price action context (support/resistance levels)
- Consider market volatility when setting thresholds
- Look for convergence across multiple momentum indicators
## Historical Context and Development
The Ultimate Oscillator was developed by Larry Williams and introduced in his 1985 article "The Ultimate Oscillator" in Technical Analysis of Stocks and Commodities magazine. Williams designed it to address the limitations of single-period oscillators by:
- Reducing false signals through multi-timeframe analysis
- Maintaining sensitivity to short-term momentum changes
- Providing more reliable divergence signals
- Creating a more robust momentum measurement tool
The indicator has become a standard tool in technical analysis, particularly valued for its divergence detection capabilities and its balanced approach to momentum measurement.
## References
* Williams, L. R. (1985). The Ultimate Oscillator. Technical Analysis of Stocks and Commodities, 3(4).
* Williams, L. R. (1999). Long-Term Secrets to Short-Term Trading. Wiley Trading.
The indicator addresses the common problem of oscillators being either too sensitive (generating many false signals) or too slow (missing opportunities). By incorporating multiple timeframes with decreasing weights for longer periods, ULTOSC attempts to capture both short-term momentum shifts and longer-term trend strength, making it particularly valuable for identifying divergences and potential reversal points.
## Core Concepts
* **Multi-timeframe analysis:** Combines three different periods (typically 7, 14, 28) to capture various momentum cycles
* **Weighted averaging:** Assigns higher weights to shorter periods for responsiveness while including longer periods for stability
* **Buying pressure focus:** Measures the relationship between closing price and the true range rather than just high-low range
* **Divergence detection:** Particularly effective at identifying momentum divergences that precede price reversals
* **Normalized scale:** Oscillates between 0 and 100, with clear overbought/oversold levels
## Common Settings and Parameters
| Parameter | Default | Function | When to Adjust |
|-----------|---------|----------|---------------|
| Fast Period | 7 | Short-term momentum calculation | Lower (5-6) for more sensitivity, higher (9-12) for smoother signals |
| Medium Period | 14 | Medium-term momentum calculation | Adjust based on typical swing duration in the market |
| Slow Period | 28 | Long-term momentum calculation | Higher values (35-42) for longer-term position trading |
| Fast Weight | 4.0 | Weight applied to fast period | Higher weight increases short-term sensitivity |
| Medium Weight | 2.0 | Weight applied to medium period | Adjust to balance medium-term influence |
| Slow Weight | 1.0 | Weight applied to slow period | Usually kept at 1.0 as the baseline weight |
**Pro Tip:** The classic 7/14/28 periods with 4/2/1 weights work well for most markets, but consider using 5/10/20 with adjusted weights for faster markets or 14/28/56 for longer-term analysis.
## Calculation and Mathematical Foundation
**Simplified explanation:**
The Ultimate Oscillator calculates three separate "buying pressure" ratios using different time periods, then combines them using weighted averaging. Buying pressure is defined as the close minus the true low, divided by the true range.
**Technical formula:**
```
BP = Close - Min(Low, Previous Close)
TR = Max(High, Previous Close) - Min(Low, Previous Close)
BP_Sum_Fast = Sum(BP, Fast Period)
TR_Sum_Fast = Sum(TR, Fast Period)
Raw_Fast = 100 × (BP_Sum_Fast / TR_Sum_Fast)
BP_Sum_Medium = Sum(BP, Medium Period)
TR_Sum_Medium = Sum(TR, Medium Period)
Raw_Medium = 100 × (BP_Sum_Medium / TR_Sum_Medium)
BP_Sum_Slow = Sum(BP, Slow Period)
TR_Sum_Slow = Sum(TR, Slow Period)
Raw_Slow = 100 × (BP_Sum_Slow / TR_Sum_Slow)
ULTOSC = 100 × [(Raw_Fast × Fast_Weight) + (Raw_Medium × Medium_Weight) + (Raw_Slow × Slow_Weight)] / (Fast_Weight + Medium_Weight + Slow_Weight)
```
Where:
- BP = Buying Pressure
- TR = True Range
- Fast Period = 7, Medium Period = 14, Slow Period = 28 (defaults)
- Fast Weight = 4, Medium Weight = 2, Slow Weight = 1 (defaults)
> 🔍 **Technical Note:** The implementation uses efficient circular buffers for all three period calculations, maintaining O(1) time complexity per bar. The algorithm properly handles true range calculations including gaps and ensures accurate buying pressure measurements across all timeframes.
## Interpretation Details
ULTOSC provides several analytical perspectives:
* **Overbought/Oversold conditions:** Values above 70 suggest overbought conditions, below 30 suggest oversold conditions
* **Momentum direction:** Rising ULTOSC indicates increasing buying pressure, falling indicates increasing selling pressure
* **Divergence analysis:** Divergences between ULTOSC and price often precede significant reversals
* **Trend confirmation:** ULTOSC direction can confirm or question the prevailing price trend
* **Signal quality:** Extreme readings (>80 or <20) indicate strong momentum that may be unsustainable
* **Multiple timeframe consensus:** When all three underlying periods agree, signals are typically more reliable
## Trading Applications
**Primary Uses:**
- **Divergence trading:** Identify when momentum diverges from price for reversal signals
- **Overbought/oversold identification:** Find potential entry/exit points at extreme levels
- **Trend confirmation:** Validate breakouts and trend continuations
- **Momentum analysis:** Assess the strength of current price movements
**Advanced Strategies:**
- **Multi-divergence confirmation:** Look for divergences across multiple timeframes
- **Momentum breakouts:** Trade when ULTOSC breaks above/below key levels with volume
- **Swing trading entries:** Use oversold/overbought levels for swing position entries
- **Trend strength assessment:** Evaluate trend quality using momentum consistency
## Signal Combinations
**Strong Bullish Signals:**
- ULTOSC rises from oversold territory (<30) with positive price divergence
- ULTOSC breaks above 50 after forming a base near 30
- All three underlying periods show increasing buying pressure
**Strong Bearish Signals:**
- ULTOSC falls from overbought territory (>70) with negative price divergence
- ULTOSC breaks below 50 after forming a top near 70
- All three underlying periods show decreasing buying pressure
**Divergence Signals:**
- **Bullish divergence:** Price makes lower lows while ULTOSC makes higher lows
- **Bearish divergence:** Price makes higher highs while ULTOSC makes lower highs
- **Hidden bullish divergence:** Price makes higher lows while ULTOSC makes lower lows (trend continuation)
- **Hidden bearish divergence:** Price makes lower highs while ULTOSC makes higher highs (trend continuation)
## Comparison with Related Oscillators
| Indicator | Periods | Focus | Best Use Case |
|-----------|---------|-------|---------------|
| **Ultimate Oscillator** | 3 periods | Buying pressure | Divergence detection |
| **Stochastic** | 1-2 periods | Price position | Overbought/oversold |
| **RSI** | 1 period | Price momentum | Momentum analysis |
| **Williams %R** | 1 period | Price position | Short-term signals |
## Advanced Configurations
**Fast Trading Setup:**
- Fast: 5, Medium: 10, Slow: 20
- Weights: 4/2/1, Thresholds: 75/25
**Standard Setup:**
- Fast: 7, Medium: 14, Slow: 28
- Weights: 4/2/1, Thresholds: 70/30
**Conservative Setup:**
- Fast: 14, Medium: 28, Slow: 56
- Weights: 3/2/1, Thresholds: 65/35
**Divergence Focused:**
- Fast: 7, Medium: 14, Slow: 28
- Weights: 2/2/2, Thresholds: 70/30
## Market-Specific Adjustments
**Volatile Markets:**
- Use longer periods (10/20/40) to reduce noise
- Consider higher threshold levels (75/25)
- Focus on extreme readings for signal quality
**Trending Markets:**
- Emphasize divergence analysis over absolute levels
- Look for momentum confirmation rather than reversal signals
- Use hidden divergences for trend continuation
**Range-Bound Markets:**
- Standard overbought/oversold levels work well
- Trade reversals from extreme levels
- Combine with support/resistance analysis
## Limitations and Considerations
* **Lagging component:** Contains inherent lag due to multiple moving average calculations
* **Complex calculation:** More computationally intensive than single-period oscillators
* **Parameter sensitivity:** Performance varies significantly with different period/weight combinations
* **Market dependency:** Most effective in trending markets with clear momentum patterns
* **False divergences:** Not all divergences lead to significant price reversals
* **Whipsaw potential:** Can generate conflicting signals in choppy markets
## Best Practices
**Effective Usage:**
- Focus on divergences rather than absolute overbought/oversold levels
- Combine with trend analysis for context
- Use multiple timeframe analysis for confirmation
- Pay attention to the speed of momentum changes
**Common Mistakes:**
- Over-relying on overbought/oversold levels in strong trends
- Ignoring the underlying trend direction
- Using inappropriate period settings for the market being analyzed
- Trading every divergence without additional confirmation
**Signal Enhancement:**
- Combine with volume analysis for confirmation
- Use price action context (support/resistance levels)
- Consider market volatility when setting thresholds
- Look for convergence across multiple momentum indicators
## Historical Context and Development
The Ultimate Oscillator was developed by Larry Williams and introduced in his 1985 article "The Ultimate Oscillator" in Technical Analysis of Stocks and Commodities magazine. Williams designed it to address the limitations of single-period oscillators by:
- Reducing false signals through multi-timeframe analysis
- Maintaining sensitivity to short-term momentum changes
- Providing more reliable divergence signals
- Creating a more robust momentum measurement tool
The indicator has become a standard tool in technical analysis, particularly valued for its divergence detection capabilities and its balanced approach to momentum measurement.
## References
* Williams, L. R. (1985). The Ultimate Oscillator. Technical Analysis of Stocks and Commodities, 3(4).
* Williams, L. R. (1999). Long-Term Secrets to Short-Term Trading. Wiley Trading.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, penulis skrip ini telah menjadikannya sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Hormat untuk penulisnya! Meskipun anda dapat menggunakannya secara gratis, ingatlah bahwa penerbitan ulang kode tersebut tunduk pada Tata Tertib kami.
github.com/mihakralj/pinescript
A collection of mathematically rigorous technical indicators for Pine Script 6, featuring defensible math, optimized implementations, proper state initialization, and O(1) constant time efficiency where possible.
A collection of mathematically rigorous technical indicators for Pine Script 6, featuring defensible math, optimized implementations, proper state initialization, and O(1) constant time efficiency where possible.
Pernyataan Penyangkalan
Informasi dan publikasi tidak dimaksudkan untuk menjadi, dan bukan merupakan saran keuangan, investasi, perdagangan, atau rekomendasi lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Persyaratan Penggunaan.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, penulis skrip ini telah menjadikannya sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Hormat untuk penulisnya! Meskipun anda dapat menggunakannya secara gratis, ingatlah bahwa penerbitan ulang kode tersebut tunduk pada Tata Tertib kami.
github.com/mihakralj/pinescript
A collection of mathematically rigorous technical indicators for Pine Script 6, featuring defensible math, optimized implementations, proper state initialization, and O(1) constant time efficiency where possible.
A collection of mathematically rigorous technical indicators for Pine Script 6, featuring defensible math, optimized implementations, proper state initialization, and O(1) constant time efficiency where possible.
Pernyataan Penyangkalan
Informasi dan publikasi tidak dimaksudkan untuk menjadi, dan bukan merupakan saran keuangan, investasi, perdagangan, atau rekomendasi lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Persyaratan Penggunaan.