Indicator · Pine Script v6 · Own pane

Awesome Oscillator (AO)

by mihakralj

This indicator calculates Bill Williams' Awesome Oscillator in a separate pane.

View on GitHub

GitHub stars99on the repository
Pine versionv6current
Lines of code54
Settings2inputs
LicenceApache-2.0
Last update4 weeks ago27 Sep 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

54 lines of Pine Script v6 from lib/oscillators/ao/ao.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

ao.pine
// Licensed under the Apache License, Version 2.0
// © mihakralj
//@version=6
indicator("Awesome Oscillator (AO)", "AO", overlay=false)

//@function Calculates Bill Williams' Awesome Oscillator
//@param fastLength Period for fast MA calculation
//@param slowLength Period for slow MA calculation
//@returns AO value measuring market momentum
ao(simple int fastLength, simple int slowLength) =>
    if fastLength <= 0 or slowLength <= 0
        runtime.error("Lengths must be greater than 0")
    if fastLength >= slowLength
        runtime.error("Fast length must be less than slow length")
    float mp = (high + low) / 2.0
    var array<float> fastBuf = array.new_float(fastLength, na)
    var array<float> slowBuf = array.new_float(slowLength, na)
    var int fastHead = 0, var int slowHead = 0
    var float fastSum = 0.0, var float slowSum = 0.0
    var int fastCount = 0, var int slowCount = 0
    float fastOldest = array.get(fastBuf, fastHead)
    if not na(fastOldest)
        fastSum -= fastOldest
        fastCount -= 1
    if not na(mp)
        fastSum += mp
        fastCount += 1
    array.set(fastBuf, fastHead, mp)
    fastHead := (fastHead + 1) % fastLength
    float slowOldest = array.get(slowBuf, slowHead)
    if not na(slowOldest)
        slowSum -= slowOldest
        slowCount -= 1
    if not na(mp)
        slowSum += mp
        slowCount += 1
    array.set(slowBuf, slowHead, mp)
    slowHead := (slowHead + 1) % slowLength
    float fastMA = fastCount > 0 ? fastSum / fastCount : na
    float slowMA = slowCount > 0 ? slowSum / slowCount : na
    fastMA - slowMA

// ---------- Main loop ----------

// Inputs
i_fastLength = input.int(5, "Fast Length", minval=1)
i_slowLength = input.int(34, "Slow Length", minval=1)

// Calculation
ao_value = ao(i_fastLength, i_slowLength)
ao_prev = ao_value[1]

// Plot
plot(ao_value, "AO", ao_value >= ao_prev ? color.green : color.red, linewidth=2)

Overview

Awesome Oscillator (AO) forms the bar midpoint from high and low, then subtracts a slow simple moving average of that midpoint from a faster one. Default periods are 5 and 34. The histogram is green when the current value is at or above the previous bar and red when it falls. Fast and slow lengths are the main settings, and the function rejects a fast length that is not shorter than the slow length. It does not generate trade entries or exits.

Details

Published by

mihakralj on GitHub

Type

Indicator, Pine Script v6

Draws

Separate pane below the chart

Category

Oscillators & momentum, Moving averages

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

algorithmic-tradingcsharpdotnetpinescriptpythonquantitative-financesimdta-libtechnical-analysistechnical-indicators

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Fast Lengthint5i_fastLength
Slow Lengthint34i_slowLength
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

948 stars

The Derivative Oscillator calculates a double-exponentially smoothed Relative Strength Index (RSI) and subtracts its Simple Moving Average (SMA) to form the main oscillator line. A secondary signal line is plotted using an SMA of the main oscillator values. Th

Indicator v4 Oscillators & momentumMoving averages
Updated 10 days ago · GPL-3.0 GitHub repository of Derivative Oscillator

Beep Boop

by magic8bot
409 stars

This indicator calculates a modified MACD oscillator and signal line alongside a trend EMA filter, plotting the output as a stylized column histogram in a separate pane. Instead of plotting true MACD distance, it quantifies positive and negative histogram mome

Indicator v4 Oscillators & momentumTrend
Updated 3 years ago · MIT GitHub repository of Beep Boop

MACD

by Alorse
330 stars

This indicator calculates and plots the standard Moving Average Convergence Divergence oscillator in a separate pane. It computes the difference between a fast and slow moving average, derives a signal line through smoothing, and plots a histogram representing

Indicator v4 Oscillators & momentumMoving averages
Updated 2 months ago · None stated GitHub repository of MACD

MACD-V

by harryguiacorn
219 stars

MACD-V is a volatility-normalized momentum indicator based on research by Alex Spiroglou. It calculates the standard MACD histogram and normalizes it by dividing by the Average True Range (ATR). Plotted in a separate pane as a colored histogram, it includes us

Indicator v5 Oscillators & momentumVolatility & bands
Updated 1 year ago · None stated GitHub repository of MACD-V
218 stars

Multi-Timeframe Analysis Suite calculates trend direction and momentum conditions across five user-selected timeframes using moving averages, RSI, and Stochastic oscillators. It evaluates moving average slope and oscillator levels to compute trend alignment, m

Indicator v6 Screeners & dashboardsTrend
Updated 3 months ago · None stated GitHub repository of Multi-Timeframe Analysis Suite

KamaFama

by Mastaaa1987
141 stars

KamaFama is an indicator that translates a Freqtrade trading strategy into Pine Script for visualization. It combines Kaufman Adaptive Moving Average (KAMA), MAMA/FAMA calculations derived via Hilbert Transform, Williams %R, and correlation trend filters to ev

Indicator v6 Moving averagesOscillators & momentum
Updated 6 weeks ago · MIT GitHub repository of KamaFama

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers