Logo
OFFLINEPIXEL
/ pinescript-strategies / pine-script-awesome-oscillator

$ Pinescript Awesome Oscillator

Master this unique momentum indicator by Bill Williams in TradingView's Pinescript for identifying market momentum, trend shifts, and reversal signals.

500+ Clients Helped
100% Satisfaction
Live Trading Ready
⚠️
Trading financial markets carries risk. All content (PineScript code, indicators, strategies) on this website is for educational purposes only. Past performance is not indicative of future results. By using any code or information from this site, you agree that you are solely responsible for your trading decisions. The author disclaims all liability for any losses incurred. To gain from experts experiences, You can always try our Invite Only Scripts
01

What is the Awesome Oscillator (AO)?

The Awesome Oscillator (AO) is a momentum indicator developed by Bill Williams, the creator of the Alligator Indicator and Fractals. Unlike most oscillators that compare closing prices, the AO compares the recent market momentum (5-period simple moving average of midpoints) with the broader market momentum (34-period simple moving average of midpoints). It is typically plotted as a histogram, with bars colored green (momentum up) or red (momentum down).

The Awesome Oscillator is designed to reflect the underlying driving force of the price, helping traders identify changes in momentum, confirm trends, and spot potential reversal signals based on specific patterns.

02

Components and Calculation

The calculation of the Awesome Oscillator is based on two Simple Moving Averages (SMAs) of the midpoint price (which is (High + Low) / 2):

  1. Short Period SMA: Calculate a 5-period SMA of the midpoint price.
  2. Long Period SMA: Calculate a 34-period SMA of the midpoint price.
  3. AO Formula:
    AO = Short Period SMA of Midpoint - Long Period SMA of Midpoint
    The resulting value oscillates around a zero line. Bars are colored based on their relation to the previous bar: green if current AO > previous AO, red if current AO < previous AO.
03

Basic Awesome Oscillator Implementation in Pinescript

pine-script@terminal
//@version=5
indicator("My Awesome Oscillator", overlay=false)

// Calculate Awesome Oscillator using the built-in function
// ta.ao uses (high+low)/2 as source and default lengths 5 and 34
aoValue = ta.ao()

// Plot the Awesome Oscillator as a histogram
// Color based on whether current AO is greater than previous AO
plot(aoValue, title="AO", style=plot.style_columns, color=aoValue >= aoValue[1] ? color.green : color.red)

// Plot the Zero Line
hline(0, "Zero Line", color.gray, linestyle=hline.style_solid)
$ ✓ Compiled successfully
04

Histogram Colors

Histogram Colors

Green bars indicate rising momentum; red bars indicate falling momentum. This is key for interpreting signals.

05

Practical Awesome Oscillator Trading Strategies

1. Zero Line Crossover

The zero line is a crucial level for the Awesome Oscillator, indicating a shift in momentum from bearish to bullish or vice versa. It's often used as a primary signal for trend initiation.

  • Buy Signal: AO crosses above the zero line. This indicates a shift from bearish to bullish momentum.
  • Sell Signal: AO crosses below the zero line. This indicates a shift from bullish to bearish momentum.
//@version=5
strategy("AO Zero Line Crossover Strategy", overlay=true)

// Calculate Awesome Oscillator
aoValue = ta.ao()

// Define conditions for entries
longSignal = ta.crossover(aoValue, 0)
shortSignal = ta.crossunder(aoValue, 0)

// Strategy entries/exits
if (longSignal)
    strategy.entry("Long", strategy.long)

if (shortSignal)
    strategy.entry("Short", strategy.short)

2. Twin Peaks Strategy

The Twin Peaks strategy uses two peaks (or troughs) on the Awesome Oscillator for reversal signals. This is considered a more reliable signal than simple zero-line crossovers.

  • Bullish Twin Peaks: Occurs below the zero line.
    1. A trough (lowest point) forms below the zero line.
    2. AO rises but stays below the zero line, then forms a second, higher trough.
    3. AO then crosses above the zero line.
    This indicates weakening bearish momentum.
  • Bearish Twin Peaks: Occurs above the zero line.
    1. A peak (highest point) forms above the zero line.
    2. AO falls but stays above the zero line, then forms a second, lower peak.
    3. AO then crosses below the zero line.
    This indicates weakening bullish momentum.
//@version=5
indicator("AO Twin Peaks Scanner", overlay=true)

// Calculate Awesome Oscillator
aoValue = ta.ao()

// Plot AO as a histogram
plot(aoValue, title="AO", style=plot.style_columns, color=aoValue >= aoValue[1] ? color.new(color.green, 0) : color.new(color.red, 0))
hline(0, "Zero Line", color.gray, linestyle=hline.style_solid)

// Simplified Bullish Twin Peak (AO makes higher low below zero, then crosses zero)
bullishTwinPeakSignal = aoValue[2] < 0 and aoValue[1] < 0 and aoValue > 0 and aoValue[1] > aoValue[2]

// Simplified Bearish Twin Peak (AO makes lower high above zero, then crosses zero)
bearishTwinPeakSignal = aoValue[2] > 0 and aoValue[1] > 0 and aoValue < 0 and aoValue[1] < aoValue[2]

plotshape(bullishTwinPeakSignal, title="Bullish Twin Peak", location=location.belowbar, color=color.new(color.green, 0), style=shape.triangleup, size=size.small)
plotshape(bearishTwinPeakSignal, title="Bearish Twin Peak", location=location.abovebar, color=color.new(color.red, 0), style=shape.triangledown, size=size.small)

alertcondition(bullishTwinPeakSignal, "Bullish AO Twin Peaks", "Potential bullish reversal based on AO Twin Peaks.")
alertcondition(bearishTwinPeakSignal, "Bearish AO Twin Peaks", "Potential bearish reversal based on AO Twin Peaks.")

3. Saucer Strategy

The Saucer strategy is a short-term momentum signal that uses three consecutive bars of the Awesome Oscillator (or two for the bearish signal) that are on the same side of the zero line but change color, indicating a subtle shift in momentum.

  • Bullish Saucer: Occurs above the zero line.
    1. AO is above the zero line.
    2. The first bar is red (AO[2] < AO[1]).
    3. The second bar is red and lower than the first red bar (AO[1] < AO[2]).
    4. The third bar is green (AO > AO[1]).
    This implies a brief dip in positive momentum followed by a resumption of strength.
  • Bearish Saucer: Occurs below the zero line.
    1. AO is below the zero line.
    2. The first bar is green (AO[2] > AO[1]).
    3. The second bar is green and higher than the first green bar (AO[1] > AO[2]).
    4. The third bar is red (AO < AO[1]).
    This implies a brief rally in negative momentum followed by a resumption of weakness.
//@version=5
strategy("AO Saucer Strategy", overlay=true)

// Calculate Awesome Oscillator
aoValue = ta.ao()

// Plot AO as a histogram in a separate pane
plot(aoValue, title="AO", style=plot.style_columns, color=aoValue >= aoValue[1] ? color.new(color.green, 0) : color.new(color.red, 0), display=display.pane_only)
hline(0, "Zero Line", color=color.new(color.gray, 0), linestyle=hline.style_solid, display=display.pane_only)

// Bullish Saucer condition
// AO is above zero, previous two bars are red and decreasing, current bar is green
bullishSaucer = aoValue > 0 and aoValue[1] < aoValue[2] and aoValue[1] < aoValue and aoValue > aoValue[1]

// Bearish Saucer condition
// AO is below zero, previous two bars are green and increasing, current bar is red
bearishSaucer = aoValue < 0 and aoValue[1] > aoValue[2] and aoValue[1] > aoValue and aoValue < aoValue[1]

// Strategy entries/exits
if (bullishSaucer)
    strategy.entry("Long", strategy.long)

if (bearishSaucer)
    strategy.entry("Short", strategy.short)
06

Optimizing Awesome Oscillator Performance

To get the most from the Awesome Oscillator in Pinescript:

  • Understand Bill Williams' Philosophy: The AO is best understood within Bill Williams' broader trading system, which focuses on market fractal geometry and the psychology of trading. It's often used in conjunction with his other indicators like Fractals and Alligator.
  • Combine Signals: Do not rely on a single AO signal in isolation. For higher probability trades, look for confluence between AO signals (e.g., zero line crossover + saucer), or combine them with price action and other indicators.
  • Multi-Timeframe Analysis: Confirm AO signals on a higher timeframe for broader trend context. A strong AO signal on a lower timeframe gains credibility if it aligns with the momentum bias of a higher timeframe.
  • Market Conditions: AO tends to perform well in trending markets. In sideways or extremely choppy markets, its signals might be less reliable.
07

Zero Line as Equilibrium

Zero Line as Equilibrium

Think of the zero line as the balance point between bullish and bearish forces. Crossing it signifies a shift in who is currently dominating the market.

08

Common Awesome Oscillator Pitfalls

  • Lag: Despite being a momentum indicator, AO uses SMAs, which inherently introduce some lag. It's not a leading indicator.
  • False Signals in Ranging Markets: In consolidations, AO can frequently cross the zero line or produce false saucer/twin peaks signals.
  • Subjectivity in Twin Peaks/Saucers: While the general rules are defined, precisely identifying peaks and troughs for the Twin Peaks strategy can sometimes be subjective without robust swing point detection.
  • Not a Standalone Indicator: AO is part of a larger system. Using it in isolation without other tools can lead to less effective trading.
  • No Fixed Overbought/Oversold Zones: Unlike RSI or Stochastic, AO doesn't have fixed overbought/oversold levels. Its extremes are relative to its own historical range.
09

Conclusion

Conclusion

The Awesome Oscillator is a powerful and visually intuitive momentum indicator available in Pinescript for TradingView. Developed by Bill Williams, it offers a unique perspective on market momentum by comparing short-term and long-term price midpoint averages. Whether used for identifying shifts across the zero line, spotting the nuanced Twin Peaks pattern, or leveraging the short-term Saucer signal, the AO provides valuable insights into the underlying forces driving price. By understanding its calculation and characteristic patterns, and integrating it strategically within your broader technical analysis framework, you can leverage the Awesome Oscillator to enhance your trading decisions and gain a clearer view of market dynamics.

Enhance Your Trading

Get a high-performance Pinescript analysis tool for actionable market insights, designed for traders on the move.

This strategy runs in live mode on TradingView, helping you identify potential opportunities.

Get Pinescript Strategy