Awesome Oscillator (AO)

Haiyue
9min

I. What is the Awesome Oscillator

The Awesome Oscillator (AO) is an oscillator used to measure market momentum. It evaluates the current market driving force by comparing the difference between short-period and long-period Simple Moving Averages (SMA) of the Median Price, displayed as a histogram that visually reflects the direction and changes in momentum.

Historical Background

AO was invented by legendary trader Bill Williams, first published in his books Trading Chaos and New Trading Dimensions. Bill Williams was a pioneer in applying chaos theory to financial trading and developed a complete trading system based on chaos theory, with AO being one of its core components. Williams’ trading philosophy emphasizes that markets are fundamentally non-linear, and AO attempts to capture the essential changes in market momentum.

Indicator Classification

  • Type: Oscillator, displayed as a histogram in a separate panel
  • Category: Momentum
  • Default Parameters: Short period =5= 5, Long period =34= 34
  • Value Range: Unbounded, oscillates around the zero line
Why Use Median Price?

Bill Williams believed that the Median Price (H+L)/2(H+L)/2 represents the “fair price” of a bar better than the closing price, as it reflects the midpoint of the bull-bear battle during that period and is not affected by the randomness of the last trade at the close.


II. Mathematical Principles and Calculation

Core Formulas

Step 1: Calculate Median Price

MPt=Ht+Lt2MP_t = \frac{H_t + L_t}{2}

Step 2: Calculate short-period and long-period SMAs

SMA5,t=15i=04MPtiSMA_{5,t} = \frac{1}{5}\sum_{i=0}^{4} MP_{t-i}

SMA34,t=134i=033MPtiSMA_{34,t} = \frac{1}{34}\sum_{i=0}^{33} MP_{t-i}

Step 3: Calculate AO

AOt=SMA(MP,5)tSMA(MP,34)tAO_t = SMA(MP, 5)_t - SMA(MP, 34)_t

Histogram Coloring Rules

  • When AOt>AOt1AO_t > AO_{t-1} — bar is green (momentum increasing)
  • When AOt<AOt1AO_t < AO_{t-1} — bar is red (momentum decreasing)

Step-by-Step Calculation Logic

  1. Calculate the Median Price for each bar: (High + Low) / 2
  2. Calculate 5-period SMA: Simple moving average of the Median Price over 5 periods
  3. Calculate 34-period SMA: Simple moving average of the Median Price over 34 periods
  4. Subtract: AO = Short SMA - Long SMA
  5. Color: Compare current AO with the previous period’s AO
Difference from MACD

AO and MACD share a similar concept (both are short-term average minus long-term average), but differ in two key ways:

  1. AO uses SMA; MACD uses EMA
  2. AO uses Median Price as input; MACD uses Close price as input This makes AO’s response smoother but more stable.

III. Python Implementation

import numpy as np
import pandas as pd


def awesome_oscillator(high: pd.Series,
                       low: pd.Series,
                       short_period: int = 5,
                       long_period: int = 34) -> pd.DataFrame:
    """
    Calculate the Awesome Oscillator (AO)

    Parameters
    ----------
    high : pd.Series
        High price series
    low : pd.Series
        Low price series
    short_period : int
        Short SMA period, default 5
    long_period : int
        Long SMA period, default 34

    Returns
    -------
    pd.DataFrame
        DataFrame with AO values and histogram color
    """
    median_price = (high + low) / 2

    sma_short = median_price.rolling(window=short_period, min_periods=short_period).mean()
    sma_long = median_price.rolling(window=long_period, min_periods=long_period).mean()

    ao = sma_short - sma_long

    # Histogram color
    color = np.where(ao > ao.shift(1), "green", "red")

    return pd.DataFrame({
        "AO": ao,
        "Color": color
    }, index=high.index)


# ========== Usage Example ==========
if __name__ == "__main__":
    np.random.seed(42)
    dates = pd.date_range("2024-01-01", periods=120, freq="D")
    base = 100 + np.cumsum(np.random.randn(120) * 1.0)

    df = pd.DataFrame({
        "date": dates,
        "open":  base + np.random.randn(120) * 0.3,
        "high":  base + np.abs(np.random.randn(120) * 0.8),
        "low":   base - np.abs(np.random.randn(120) * 0.8),
        "close": base,
        "volume": np.random.randint(1000, 10000, size=120),
    })
    df.set_index("date", inplace=True)

    # Calculate AO
    ao_df = awesome_oscillator(df["high"], df["low"])
    df = pd.concat([df, ao_df], axis=1)

    print("=== Awesome Oscillator Results (last 15 rows) ===")
    print(df[["close", "AO", "Color"]].tail(15).to_string())

    # Zero line crossover signals
    df["cross"] = np.where(
        (df["AO"] > 0) & (df["AO"].shift(1) <= 0), "bullish_cross",
        np.where(
            (df["AO"] < 0) & (df["AO"].shift(1) >= 0), "bearish_cross", ""
        )
    )

    crosses = df[df["cross"] != ""]
    print("\n=== Zero Line Crossover Signals ===")
    print(crosses[["close", "AO", "cross"]].to_string())

    # Saucer signal detection (simplified)
    df["saucer_buy"] = (
        (df["AO"] > 0) &
        (df["AO"].shift(1) < df["AO"].shift(2)) &
        (df["AO"] > df["AO"].shift(1))
    )
    saucer = df[df["saucer_buy"]]
    print("\n=== Saucer Buy Signals (V-shaped reversal in AO > 0 zone) ===")
    print(saucer[["close", "AO"]].head(10).to_string())

IV. Problems the Indicator Solves

1. Zero Line Crossover

The most basic signal:

  • AO crosses above zero — Short-term momentum exceeds long-term momentum, buy signal
  • AO crosses below zero — Short-term momentum weaker than long-term momentum, sell signal

2. Saucer Signal

Bill Williams’ most favored AO signal:

Saucer Buy (above zero line):

  1. AO is above the zero line
  2. A red bar appears (AO declines)
  3. A green bar follows (AO recovers) — Buy

Saucer Sell (below zero line):

  1. AO is below the zero line
  2. A green bar appears (AO rises)
  3. A red bar follows (AO declines) — Sell

3. Twin Peaks Signal

Twin Peaks Buy:

  • AO forms two troughs below the zero line
  • The second trough is higher than the first (less negative)
  • Green bars appear between the two troughs
  • Buy when a green bar appears after the second trough

Twin Peaks Sell:

  • AO forms two peaks above the zero line
  • The second peak is lower than the first
  • Red bars appear between the two peaks
  • Sell when a red bar appears after the second peak

4. Momentum Direction Assessment

Histogram color changes visually reflect momentum direction:

  • Consecutive green bars — upward momentum continues to strengthen
  • Consecutive red bars — downward momentum continues to strengthen
Caution

Bill Williams’ trading system requires AO to be used in conjunction with other Williams indicators (such as Alligator and Fractal). Using AO signals alone can generate many false signals in ranging markets.


V. Advantages, Disadvantages, and Use Cases

Advantages

AdvantageDescription
Visually intuitiveColor-coded histogram makes momentum changes instantly visible
Complete signal systemZero line crossover + Saucer + Twin Peaks complement each other
Uses Median PriceMore robust than close price, reduces closing noise
Simple calculationDifference of two SMAs, easy to implement

Disadvantages

DisadvantageDescription
SMA lagUses SMA rather than EMA, slower response than MACD
Many false signals in ranging marketsZero line crossovers are frequent and unreliable without trends
Signal subjectivityIdentifying Saucer and Twin Peaks patterns involves some subjectivity
No overbought/oversold boundsCannot clearly define extreme zones like RSI

Use Cases

  • Trending markets: AO produces high-quality signals in markets with clear trends
  • Combined with Williams system: Works best with Alligator and Fractal indicators
  • Medium to long-term trading: The 34-period long SMA makes AO better suited for medium to long-term use
ComparisonAOMACDMomentum
Moving Average TypeSMAEMANone
Data SourceMedian PriceClose PriceClose Price
Signal LineNoneYes (9 EMA)None
HistogramAO itselfMACD - SignalNone
Suited StyleMedium to longMediumShort-term
Practical Tips
  1. Use Alligator for direction first: Focus on AO signals only when the Alligator indicator is open (three lines diverging).
  2. Saucer signals are most reliable: Within a confirmed trend, the Saucer signal has a far higher win rate than zero line crossovers.
  3. Twin Peaks require patience: Twin Peaks signals take time to form, but once triggered, they usually indicate a significant move.
  4. Watch histogram color changes: After 5 or more consecutive same-color bars, a color change is often an early signal of a momentum shift.